LibreOffice Module sw (master)  1
wrtw8esh.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 <memory>
21 #include <com/sun/star/embed/Aspects.hpp>
22 
23 #include <hintids.hxx>
24 
25 #include <officecfg/Office/Common.hxx>
26 #include <o3tl/any.hxx>
27 #include <com/sun/star/drawing/XShape.hpp>
28 #include <vcl/svapp.hxx>
29 #include <sot/storage.hxx>
30 #include <svl/itemiter.hxx>
31 #include <svl/stritem.hxx>
32 #include <svl/whiter.hxx>
33 #include <svx/svdobj.hxx>
34 #include <svx/svdotext.hxx>
35 #include <svx/svdpage.hxx>
36 #include <editeng/outlobj.hxx>
37 #include <editeng/editobj.hxx>
38 #include <editeng/brushitem.hxx>
39 #include <editeng/boxitem.hxx>
40 #include <editeng/lrspitem.hxx>
41 #include <editeng/ulspitem.hxx>
42 #include <editeng/fontitem.hxx>
43 #include <editeng/frmdiritem.hxx>
44 #include <editeng/flditem.hxx>
45 #include <editeng/shaditem.hxx>
46 #include <editeng/eeitem.hxx>
48 #include <svx/svdouno.hxx>
49 #include <svx/unoapi.hxx>
50 #include <svx/svdview.hxx>
51 #include <svx/unopage.hxx>
52 #include <fmtcnct.hxx>
53 #include <fmtanchr.hxx>
54 #include <fmtsrnd.hxx>
55 #include <fmtornt.hxx>
56 #include <fmtfsize.hxx>
57 #include <fmtfollowtextflow.hxx>
58 #include <frmfmt.hxx>
59 #include <fmtcntnt.hxx>
60 #include <ndindex.hxx>
61 #include <doc.hxx>
62 #include <drawdoc.hxx>
65 #include <pam.hxx>
66 #include <swrect.hxx>
67 #include <ndgrf.hxx>
68 #include <grfatr.hxx>
69 #include <ndole.hxx>
70 #include <pagedesc.hxx>
71 #include <poolfmt.hxx>
72 #include "ww8par.hxx"
73 #include <breakit.hxx>
74 #include <com/sun/star/i18n/XBreakIterator.hpp>
75 #include <com/sun/star/lang/XServiceInfo.hpp>
76 #include "attributeoutputbase.hxx"
77 #include "writerhelper.hxx"
78 #include "writerwordglue.hxx"
79 #include "wrtww8.hxx"
80 #include "escher.hxx"
81 #include <ndtxt.hxx>
82 #include "WW8FFData.hxx"
83 #include <com/sun/star/beans/XPropertySet.hpp>
84 #include <com/sun/star/form/XFormComponent.hpp>
86 #include <oox/ole/olehelper.hxx>
87 #include <fmturl.hxx>
88 #include <frameformats.hxx>
89 #include <sfx2/sfxsids.hrc>
90 #include <unotools/saveopt.hxx>
91 #include <o3tl/enumrange.hxx>
92 #include <o3tl/enumarray.hxx>
93 #include <sfx2/docfile.hxx>
94 #include <tools/UnitConversion.hxx>
95 
96 #include <algorithm>
97 
98 using ::editeng::SvxBorderLine;
99 using namespace com::sun::star;
100 using namespace sw::util;
101 using namespace sw::types;
102 using ::com::sun::star::beans::XPropertySet;
103 using ::com::sun::star::drawing::XShape;
104 
106 {
107  bool bRelUrl = false;
108  SfxMedium * pMedium = rWrt.GetWriter().GetMedia();
109  if ( pMedium )
110  bRelUrl = pMedium->IsRemote()
113  return bRelUrl;
114 }
115 
117 {
118  OUString sDocUrl;
119  SfxMedium * pMedium = rWrt.GetWriter().GetMedia();
120  if (pMedium)
121  {
122  const SfxItemSet* pPItemSet = pMedium->GetItemSet();
123  if( pPItemSet )
124  {
125  const SfxStringItem* pPItem = dynamic_cast< const SfxStringItem* >( pPItemSet->GetItem( SID_FILE_NAME ) );
126  if ( pPItem )
127  sDocUrl = pPItem->GetValue();
128  }
129  }
130 
131  return sDocUrl.copy(0, sDocUrl.lastIndexOf('/') + 1);
132 }
133 
134 OUString SwBasicEscherEx::BuildFileName(sal_uInt16& rnLevel, bool& rbRel, const OUString& rUrl)
135 {
136  OUString aDosName( INetURLObject( rUrl ).getFSysPath( FSysStyle::Dos ) );
137  rnLevel = 0;
138  rbRel = IsRelUrl();
139 
140  if (rbRel)
141  {
142  // try to convert to relative file name
143  OUString aTmpName( aDosName );
144  aDosName = INetURLObject::GetRelURL( GetBasePath(), rUrl,
146 
147  if (aDosName.startsWith(INET_FILE_SCHEME))
148  {
149  // not converted to rel -> back to old, return absolute flag
150  aDosName = aTmpName;
151  rbRel = false;
152  }
153  else if (aDosName.startsWith("./"))
154  {
155  aDosName = aDosName.copy(2);
156  }
157  else
158  {
159  while (aDosName.startsWith("../"))
160  {
161  ++rnLevel;
162  aDosName = aDosName.copy(3);
163  }
164  }
165  }
166  return aDosName;
167 }
168 
170 {
171  if ( !pINetFormatArg ) return;
172 
173  const sal_uInt8 aGuidStdLink[ 16 ] ={
174  0xD0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B };
175  const sal_uInt8 aGuidUrlMoniker[ 16 ] = {
176  0xE0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE, 0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9, 0x0B };
177 
178  const sal_uInt8 aGuidFileMoniker[ 16 ] = {
179  0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 };
180  const sal_uInt8 aGuidFileTail[] = {
181  0xFF, 0xFF, 0xAD, 0xDE, 0x00, 0x00, 0x00, 0x00,
182  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
183  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
184  };
185  //const sal_uInt18 WW8_ID_HLINK = 0x01B8;
186  constexpr sal_uInt32 WW8_HLINK_BODY = 0x00000001;
187  constexpr sal_uInt32 WW8_HLINK_ABS = 0x00000002;
188  //const sal_uInt32 WW8_HLINK_DESCR = 0x00000014; /// Description.
189  constexpr sal_uInt32 WW8_HLINK_MARK = 0x00000008;
190  constexpr sal_uInt32 WW8_HLINK_FRAME = 0x00000080;
191  //const sal_uInt32 WW8_HLINK_UNC = 0x00000100; /// UNC path.
192  SvMemoryStream tmpStrm;
193  OUString tmpTextMark;
194 
195  OUString rUrl = pINetFormatArg->GetURL();
196  OUString rTarFrame = pINetFormatArg->GetTargetFrameName();
197  sal_uInt32 nFlags = 0;
198 
199  INetURLObject aUrlObj( rUrl );
200  const INetProtocol eProtocol = aUrlObj.GetProtocol();
201 
202  //Target Frame
203  if (!rTarFrame.isEmpty())
204  {
205  SwWW8Writer::WriteLong(tmpStrm, rTarFrame.getLength()+1);
206  SwWW8Writer::WriteString16(tmpStrm, rTarFrame, false);
207 
208  tmpStrm.WriteUInt16( 0 );
209 
210  nFlags |= WW8_HLINK_FRAME;
211  }
212 
213  // file link or URL
214  if (eProtocol == INetProtocol::File || (eProtocol == INetProtocol::NotValid && rUrl[0] != '#'))
215  {
216  sal_uInt16 nLevel;
217  bool bRel;
218  OUString aFileName( BuildFileName( nLevel, bRel, rUrl ));
219 
220  if( !bRel )
221  nFlags |= WW8_HLINK_ABS;
222 
223  nFlags |= WW8_HLINK_BODY;
224 
225  tmpStrm.WriteBytes(aGuidFileMoniker, sizeof(aGuidFileMoniker));
226  tmpStrm.WriteUInt16( nLevel );
227  SwWW8Writer::WriteLong(tmpStrm, aFileName.getLength()+1);
228  SwWW8Writer::WriteString8( tmpStrm, aFileName, true, RTL_TEXTENCODING_MS_1252 );
229  tmpStrm.WriteBytes(aGuidFileTail, sizeof(aGuidFileTail));
230 
231  //For UNICODE
232  SwWW8Writer::WriteLong(tmpStrm, 2*aFileName.getLength()+6);
233  SwWW8Writer::WriteLong(tmpStrm, 2*aFileName.getLength());
234  tmpStrm.WriteUInt16( 0x0003 );
235  SwWW8Writer::WriteString16(tmpStrm, aFileName, false);
236  }
237  else if( eProtocol != INetProtocol::NotValid )
238  {
239  tmpStrm.WriteBytes(aGuidUrlMoniker, sizeof(aGuidUrlMoniker));
240  SwWW8Writer::WriteLong(tmpStrm, 2*(rUrl.getLength()+1));
241 
242  SwWW8Writer::WriteString16(tmpStrm, rUrl, true);
243  nFlags |= WW8_HLINK_BODY | WW8_HLINK_ABS;
244  }
245  else if (rUrl[0] == '#' )
246  {
247  OUString aTextMark(rUrl.copy( 1 ));
248  aTextMark = aTextMark.replaceFirst(".", "!");
249  tmpTextMark = aTextMark;
250  }
251 
252  if (tmpTextMark.isEmpty() && aUrlObj.HasMark())
253  {
254  tmpTextMark = aUrlObj.GetMark();
255  }
256 
257  if (!tmpTextMark.isEmpty())
258  {
259  SwWW8Writer::WriteLong(tmpStrm, tmpTextMark.getLength()+1);
260  SwWW8Writer::WriteString16(tmpStrm, tmpTextMark, true);
261 
262  nFlags |= WW8_HLINK_MARK;
263  }
264 
265  rStrm.WriteBytes(aGuidStdLink, 16);
266  rStrm .WriteUInt32( 2 )
267  .WriteUInt32( nFlags );
268  tmpStrm.Seek( STREAM_SEEK_TO_BEGIN );
269  sal_uInt32 const nLen = tmpStrm.remainingSize();
270  if(nLen >0)
271  {
272  std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[ nLen ] );
273  tmpStrm.ReadBytes(pBuffer.get(), nLen);
274  rStrm.WriteBytes(pBuffer.get(), nLen);
275  }
276 }
278 {
279  const SfxPoolItem* pItem;
280  const SwAttrSet& rAttrSet = rFormat.GetAttrSet();
281  if (SfxItemState::SET != rAttrSet.GetItemState(RES_URL, true, &pItem))
282  return;
283 
284  const SwFormatURL *pINetFormat = dynamic_cast<const SwFormatURL*>(pItem);
285  if (!pINetFormat || pINetFormat->GetURL().isEmpty())
286  return;
287 
288  SvMemoryStream aStrm;
289  WriteHyperlinkWithinFly( aStrm, pINetFormat );
290  rPropOpt.AddOpt(ESCHER_Prop_pihlShape, true, 0, aStrm);
291  sal_uInt32 nValue;
292  OUString aNamestr = pINetFormat->GetName();
293  if (!aNamestr.isEmpty())
294  {
295  rPropOpt.AddOpt(ESCHER_Prop_wzName, aNamestr );
296  }
297  if(rPropOpt.GetOpt( ESCHER_Prop_fPrint, nValue))
298  {
299  nValue|=0x03080008;
300  rPropOpt.AddOpt(ESCHER_Prop_fPrint, nValue );
301  }
302  else
303  rPropOpt.AddOpt(ESCHER_Prop_fPrint, 0x03080008 );
304 }
305 
306 namespace
307 {
312  sal_uLong lcl_getSdrOrderNumber(const WW8Export& rWrt, DrawObj const *pObj)
313  {
314  return rWrt.GetSdrOrdNum(pObj->maContent.GetFrameFormat());
315  };
316 
319  class CompareDrawObjs
320  {
321  private:
322  const WW8Export& wrt;
323 
324  public:
325  explicit CompareDrawObjs(const WW8Export& rWrt) : wrt(rWrt) {};
326  bool operator()(DrawObj const *a, DrawObj const *b) const
327  {
328  sal_uLong aSort = lcl_getSdrOrderNumber(wrt, a);
329  sal_uLong bSort = lcl_getSdrOrderNumber(wrt, b);
330  return aSort < bSort;
331  }
332  };
333 
338  void lcl_makeZOrderArray(const WW8Export& rWrt,
339  std::vector<DrawObj> &rSrcArr,
340  std::vector<DrawObj*> &rDstArr)
341  {
342  rDstArr.clear();
343  rDstArr.reserve(rSrcArr.size());
344  for(DrawObj & i : rSrcArr)
345  {
346  rDstArr.push_back( &i );
347  }
348  std::sort(rDstArr.begin(), rDstArr.end(), CompareDrawObjs(rWrt));
349  }
350 
351 }
352 
353 // get a part fix for this type of element
355 {
356  const SdrObject *pObject = rFrameFormat.FindRealSdrObject();
357  if (!pObject || pObject->GetObjInventor() != SdrInventor::FmForm)
358  return false;
359 
360  const SdrUnoObj *pFormObj = dynamic_cast< const SdrUnoObj* >(pObject);
361  if (!pFormObj)
362  return false;
363 
364  uno::Reference< awt::XControlModel > xControlModel =
365  pFormObj->GetUnoControlModel();
366  uno::Reference< lang::XServiceInfo > xInfo(xControlModel,
367  uno::UNO_QUERY);
368  uno::Reference<beans::XPropertySet> xPropSet(xControlModel, uno::UNO_QUERY);
369  if (!xInfo.is())
370  return false;
371 
372  if (xInfo->supportsService("com.sun.star.form.component.ComboBox"))
373  {
374  DoComboBox(xPropSet);
375  return true;
376  }
377 
378  return false;
379 }
380 
381 void WW8Export::DoComboBox(uno::Reference<beans::XPropertySet> const & xPropSet)
382 {
383  OUString sSelected;
384  uno::Sequence<OUString> aListItems;
385  xPropSet->getPropertyValue("StringItemList") >>= aListItems;
386  if (aListItems.hasElements())
387  {
388  uno::Any aTmp = xPropSet->getPropertyValue("DefaultText");
389  auto pStr = o3tl::tryAccess<OUString>(aTmp);
390  if (pStr)
391  sSelected = *pStr;
392  }
393 
394  OUString sName;
395  {
396  uno::Any aTmp = xPropSet->getPropertyValue("Name");
397  auto pStr = o3tl::tryAccess<OUString>(aTmp);
398  if (pStr)
399  sName = *pStr;
400  }
401 
402  OUString sHelp;
403  {
404  // property "Help" does not exist and due to the no-existence an exception is thrown.
405  try
406  {
407  uno::Any aTmp = xPropSet->getPropertyValue("HelpText");
408  auto pStr = o3tl::tryAccess<OUString>(aTmp);
409  if (pStr)
410  sHelp = *pStr;
411  }
412  catch( const uno::Exception& )
413  {}
414  }
415 
416  OUString sToolTip;
417  {
418  uno::Any aTmp = xPropSet->getPropertyValue("Name");
419  auto pStr = o3tl::tryAccess<OUString>(aTmp);
420  if (pStr)
421  sToolTip = *pStr;
422  }
423 
424  DoComboBox(sName, sHelp, sToolTip, sSelected, aListItems);
425 }
426 
427 void WW8Export::DoComboBox(const OUString &rName,
428  const OUString &rHelp,
429  const OUString &rToolTip,
430  const OUString &rSelected,
431  const uno::Sequence<OUString> &rListItems)
432 {
433  OutputField(nullptr, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN),
435  // write the reference to the "picture" structure
436  sal_uLong nDataStt = pDataStrm->Tell();
437  m_pChpPlc->AppendFkpEntry( Strm().Tell() );
438 
439  WriteChar( 0x01 );
440 
441  static sal_uInt8 aArr1[] =
442  {
443  0x03, 0x6a, 0,0,0,0, // sprmCPicLocation
444  0x06, 0x08, 0x01, // sprmCFData
445  0x55, 0x08, 0x01, // sprmCFSpec
446  0x02, 0x08, 0x01 // sprmCFFieldVanish
447  };
448  sal_uInt8* pDataAdr = aArr1 + 2;
449  Set_UInt32( pDataAdr, nDataStt );
450 
451  m_pChpPlc->AppendFkpEntry(Strm().Tell(), sizeof(aArr1), aArr1);
452 
453  OutputField(nullptr, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN),
455 
456  ::sw::WW8FFData aFFData;
457 
458  aFFData.setType(2);
459  aFFData.setName(rName);
460  aFFData.setHelp(rHelp);
461  aFFData.setStatus(rToolTip);
462 
463  sal_uInt32 nListItems = rListItems.getLength();
464 
465  for (sal_uInt32 i = 0; i < nListItems; i++)
466  {
467  if (i < 0x20 && rSelected == rListItems[i])
468  aFFData.setResult(::sal::static_int_cast<sal_uInt8>(i));
469  aFFData.addListboxEntry(rListItems[i]);
470  }
471 
472  aFFData.Write(pDataStrm);
473 }
474 
476 {
477  OutputField(nullptr, ww::eFORMTEXT, FieldString(ww::eFORMTEXT),
479  // write the reference to the "picture" structure
480  sal_uLong nDataStt = pDataStrm->Tell();
481  m_pChpPlc->AppendFkpEntry( Strm().Tell() );
482 
483  WriteChar( 0x01 );
484  static sal_uInt8 aArr1[] = {
485  0x02, 0x08, 0x81, // sprmCFFieldVanish
486  0x03, 0x6a, 0,0,0,0, // sprmCPicLocation
487 
488  0x06, 0x08, 0x01, // sprmCFData
489  0x55, 0x08, 0x01 // sprmCFSpec
490  };
491  sal_uInt8* pDataAdr = aArr1 + 5;
492  Set_UInt32( pDataAdr, nDataStt );
493 
494  m_pChpPlc->AppendFkpEntry(Strm().Tell(),
495  sizeof( aArr1 ), aArr1 );
496 
497  ::sw::WW8FFData aFFData;
498 
499  aFFData.setType(0);
500  aFFData.setName(pField->GetPar2());
501  aFFData.setHelp(pField->GetHelp());
502  aFFData.setStatus(pField->GetToolTip());
503  aFFData.Write(pDataStrm);
504 
505  OutputField(nullptr, ww::eFORMTEXT, OUString(), FieldFlags::CmdEnd);
506 
507  const OUString fieldStr( pField->ExpandField(true, nullptr) );
508  SwWW8Writer::WriteString16(Strm(), fieldStr, false);
509 
510  static sal_uInt8 aArr2[] = {
511  0x55, 0x08, 0x01, // sprmCFSpec
512  0x75, 0x08, 0x01 // ???
513  };
514 
515  pDataAdr = aArr2 + 2;
516  Set_UInt32( pDataAdr, nDataStt );
517  m_pChpPlc->AppendFkpEntry(Strm().Tell(),
518  sizeof( aArr2 ), aArr2 );
519 
520  OutputField(nullptr, ww::eFORMTEXT, OUString(), FieldFlags::Close);
521 }
522 
524 {
525 }
526 
527 //It's irritating to have to change the RTL frames position into LTR ones
528 //so that word will have to place them in the right place. Doubly so that
529 //the SO drawings and writer frames have different ideas themselves as to
530 //how to be positioned when in RTL mode!
531 bool RTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
532 sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft,
533  SwTwips nPageRight, SwTwips nPageSize)
534 {
535  bool bRet = false;
536  if (eHoriOri == text::HoriOrientation::NONE)
537  {
538  if (eHoriRel == text::RelOrientation::PAGE_FRAME)
539  {
540  rLeft = nPageSize - rLeft;
541  bRet = true;
542  }
543  else if (
544  (eHoriRel == text::RelOrientation::PAGE_PRINT_AREA) ||
545  (eHoriRel == text::RelOrientation::FRAME) ||
546  (eHoriRel == text::RelOrientation::PRINT_AREA)
547  )
548  {
549  rLeft = nPageSize - nPageLeft - nPageRight - rLeft;
550  bRet = true;
551  }
552  }
553  if (bRet)
554  rLeft -= nWidth;
555  return bRet;
556 }
557 
558 static bool RTLDrawingsHack(SwTwips &rLeft,
559  sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft,
560  SwTwips nPageRight, SwTwips nPageSize)
561 {
562  bool bRet = false;
563  if (eHoriOri == text::HoriOrientation::NONE)
564  {
565  if (eHoriRel == text::RelOrientation::PAGE_FRAME)
566  {
567  rLeft = nPageSize + rLeft;
568  bRet = true;
569  }
570  else if (
571  (eHoriRel == text::RelOrientation::PAGE_PRINT_AREA) ||
572  (eHoriRel == text::RelOrientation::FRAME) ||
573  (eHoriRel == text::RelOrientation::PRINT_AREA)
574  )
575  {
576  rLeft = nPageSize - nPageLeft - nPageRight + rLeft;
577  bRet = true;
578  }
579  }
580  return bRet;
581 }
582 
584  const ww8::Frame &rFrameFormat)
585 {
586  //Require nasty bidi swap
587  if (SvxFrameDirection::Horizontal_RL_TB != m_rDoc.GetTextDirection(rFrameFormat.GetPosition()))
588  return;
589 
590  SwTwips nWidth = rRight - rLeft;
591  SwTwips nPageLeft, nPageRight;
592  SwTwips nPageSize = CurrentPageWidth(nPageLeft, nPageRight);
593 
594  const SwFormatHoriOrient& rHOr = rFrameFormat.GetFrameFormat().GetHoriOrient();
595 
596  bool bRet = false;
597  ww8::Frame::WriterSource eSource = rFrameFormat.GetWriterType();
598  if (eSource == ww8::Frame::eDrawing || eSource == ww8::Frame::eFormControl)
599  {
600  if (RTLDrawingsHack(rLeft, rHOr.GetHoriOrient(),
601  rHOr.GetRelationOrient(), nPageLeft, nPageRight, nPageSize))
602  {
603  bRet = true;
604  }
605  }
606  else
607  {
608  if (RTLGraphicsHack(rLeft, nWidth, rHOr.GetHoriOrient(),
609  rHOr.GetRelationOrient(), nPageLeft, nPageRight, nPageSize))
610  {
611  bRet = true;
612  }
613  }
614  if (bRet)
615  rRight = rLeft + nWidth;
616 }
617 
618 void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
619 {
620  if (8 > rWrt.pFib->m_nVersion) // Cannot export drawobject in vers 7-
621  return;
622 
623  sal_uInt32 nFcStart = rWrt.pTableStrm->Tell();
624 
625  if (maDrawObjs.empty())
626  return;
627 
628  // write CPs
629  WW8Fib& rFib = *rWrt.pFib;
630  WW8_CP nCpOffs = GetCpOffset(rFib);
631 
632  for (const auto& rDrawObj : maDrawObjs)
633  SwWW8Writer::WriteLong(*rWrt.pTableStrm, rDrawObj.mnCp - nCpOffs);
634 
636  rFib.m_ccpHdr + rFib.m_ccpEdn + rFib.m_ccpTxbx + rFib.m_ccpHdrTxbx + 1);
637 
638  for (const auto& rDrawObj : maDrawObjs)
639  {
640  // write the fspa-struct
641  const ww8::Frame &rFrameFormat = rDrawObj.maContent;
642  const SwFrameFormat &rFormat = rFrameFormat.GetFrameFormat();
643  const SdrObject* pObj = rFormat.FindRealSdrObject();
644 
645  tools::Rectangle aRect;
646  SwFormatVertOrient rVOr = rFormat.GetVertOrient();
647  SwFormatHoriOrient rHOr = rFormat.GetHoriOrient();
648  // #i30669# - convert the positioning attributes.
649  // Most positions are converted, if layout information exists.
650  const bool bPosConverted =
651  WinwordAnchoring::ConvertPosition( rHOr, rVOr, rFormat );
652 
653  Point aObjPos;
654  bool bHasHeightWidthSwapped(false);
655  if (RES_FLYFRMFMT == rFormat.Which())
656  {
657  SwRect aLayRect(rFormat.FindLayoutRect(false, &aObjPos));
658  // the Object is not visible - so get the values from
659  // the format. The Position may not be correct.
660  if( aLayRect.IsEmpty() )
661  aRect.SetSize( rFormat.GetFrameSize().GetSize() );
662  else
663  {
664  // #i56090# Do not only consider the first client
665  // Note that we actually would have to find the maximum size of the
666  // frame format clients. However, this already should work in most cases.
667  const SwRect aSizeRect(rFormat.FindLayoutRect());
668  if ( aSizeRect.Width() > aLayRect.Width() )
669  aLayRect.Width( aSizeRect.Width() );
670 
671  aRect = aLayRect.SVRect();
672  }
673  }
674  else
675  {
676  OSL_ENSURE(pObj, "Where is the SDR-Object?");
677  if (pObj)
678  {
679  aRect = pObj->GetLogicRect();
680 
681  // rotating to vertical means swapping height and width as seen in SvxMSDffManager::ImportShape
682  const Degree100 nAngle = NormAngle36000( pObj->GetRotateAngle() );
683  const bool bAllowSwap = pObj->GetObjIdentifier() != OBJ_LINE && pObj->GetObjIdentifier() != OBJ_GRUP;
684  if ( bAllowSwap && (( nAngle > 4500_deg100 && nAngle <= 13500_deg100 ) || ( nAngle > 22500_deg100 && nAngle <= 31500_deg100 )) )
685  {
686  const tools::Long nWidth = aRect.getWidth();
687  const tools::Long nHeight = aRect.getHeight();
688  aRect.setWidth( nHeight );
689  aRect.setHeight( nWidth );
690  bHasHeightWidthSwapped = true;
691  }
692  }
693  }
694 
695  // #i30669# - use converted position, if conversion is performed.
696  // Unify position determination of Writer fly frames
697  // and drawing objects.
698  if ( bPosConverted )
699  {
700  aRect.SetPos( Point( rHOr.GetPos(), rVOr.GetPos() ) );
701  }
702  else
703  {
704  aRect -= rDrawObj.maParentPos;
705  aObjPos = aRect.TopLeft();
707  {
708  // #i22673#
709  sal_Int16 eOri = rVOr.GetRelationOrient();
710  if (eOri == text::RelOrientation::CHAR || eOri == text::RelOrientation::TEXT_LINE)
711  aObjPos.setY( -rVOr.GetPos() );
712  else
713  aObjPos.setY( rVOr.GetPos() );
714  }
716  aObjPos.setX( rHOr.GetPos() );
717  aRect.SetPos( aObjPos );
718  }
719 
720  sal_Int32 nThick = rDrawObj.mnThick;
721 
722  //If we are being exported as an inline hack, set
723  //corner to 0 and forget about border thickness for positioning
724  if (rFrameFormat.IsInline())
725  {
726  aRect.SetPos(Point(0,0));
727  nThick = 0;
728  }
729 
730  // spid
731  SwWW8Writer::WriteLong(*rWrt.pTableStrm, rDrawObj.mnShapeId);
732 
733  SwTwips nLeft = aRect.Left() + nThick;
734  SwTwips nRight = aRect.Right() - nThick;
735  SwTwips nTop = aRect.Top() + nThick;
736  SwTwips nBottom = aRect.Bottom() - nThick;
737 
738  // tdf#93675, 0 below line/paragraph and/or top line/paragraph with
739  // wrap top+bottom or other wraps is affecting the line directly
740  // above the anchor line, which seems odd, but a tiny adjustment
741  // here to bring the top down convinces msoffice to wrap like us
742  if (nTop == 0 && !rFrameFormat.IsInline() &&
744  rVOr.GetRelationOrient() == text::RelOrientation::FRAME)
745  {
746  nTop = 8;
747  }
748 
749  //Nasty swap for bidi if necessary
750  rWrt.MiserableRTLFrameFormatHack(nLeft, nRight, rFrameFormat);
751 
752  // tdf#70838. Word relates the position to the unrotated rectangle,
753  // Writer to the rotated one. Because the rotation is around center,
754  // the difference counts half.
755  if(pObj && pObj->GetRotateAngle())
756  {
757  SwTwips nXOff;
758  SwTwips nYOff;
759  SwTwips nSnapWidth = pObj->GetSnapRect().getWidth();
760  SwTwips nSnapHeight = pObj->GetSnapRect().getHeight();
761  SwTwips nLogicWidth = pObj->GetLogicRect().getWidth();
762  SwTwips nLogicHeight = pObj->GetLogicRect().getHeight();
763  // +1 for to compensate integer arithmetic rounding errors
764  if(bHasHeightWidthSwapped)
765  {
766  nXOff = (nSnapWidth - nLogicHeight + 1) / 2;
767  nYOff = (nSnapHeight - nLogicWidth + 1) / 2;
768  }
769  else
770  {
771  nXOff = (nSnapWidth - nLogicWidth + 1) / 2;
772  nYOff = (nSnapHeight - nLogicHeight + 1) / 2;
773  }
774  nLeft += nXOff;
775  nRight += nXOff;
776  nTop += nYOff;
777  nBottom += nYOff;
778  }
779 
780  //xaLeft/yaTop/xaRight/yaBottom - rel. to anchor
781  //(most of) the border is outside the graphic is word, so
782  //change dimensions to fit
783  SwWW8Writer::WriteLong(*rWrt.pTableStrm, nLeft);
784  SwWW8Writer::WriteLong(*rWrt.pTableStrm, nTop);
785  SwWW8Writer::WriteLong(*rWrt.pTableStrm, nRight);
786  SwWW8Writer::WriteLong(*rWrt.pTableStrm, nBottom);
787 
788  //fHdr/bx/by/wr/wrk/fRcaSimple/fBelowText/fAnchorLock
789  sal_uInt16 nFlags=0;
790  //If nFlags isn't 0x14 its overridden by the escher properties
791  if (RndStdIds::FLY_AT_PAGE == rFormat.GetAnchor().GetAnchorId())
792  nFlags = 0x0000;
793  else
794  nFlags = 0x0014; // x-rel to text, y-rel to text
795 
796  const SwFormatSurround& rSurr = rFormat.GetSurround();
797  sal_uInt16 nContour = rSurr.IsContour() ? 0x0080 : 0x0040;
798  css::text::WrapTextMode eSurround = rSurr.GetSurround();
799 
800  /*
801  #i3958#
802  The inline elements being export as anchored to character inside
803  the shape field hack are required to be wrap through so as to flow
804  over the following dummy 0x01 graphic
805  */
806  if (rFrameFormat.IsInline())
807  eSurround = css::text::WrapTextMode_THROUGH;
808 
809  switch (eSurround)
810  {
811  case css::text::WrapTextMode_NONE:
812  nFlags |= 0x0020;
813  break;
814  case css::text::WrapTextMode_THROUGH:
815  nFlags |= 0x0060;
816  break;
817  case css::text::WrapTextMode_PARALLEL:
818  nFlags |= 0x0000 | nContour;
819  break;
820  case css::text::WrapTextMode_DYNAMIC:
821  nFlags |= 0x0600 | nContour;
822  break;
823  case css::text::WrapTextMode_LEFT:
824  nFlags |= 0x0200 | nContour;
825  break;
826  case css::text::WrapTextMode_RIGHT:
827  nFlags |= 0x0400 | nContour;
828  break;
829  default:
830  OSL_ENSURE(false, "Unsupported surround type for export");
831  break;
832  }
833  if (pObj && (pObj->GetLayer() == rWrt.m_rDoc.getIDocumentDrawModelAccess().GetHellId() ||
835  {
836  nFlags |= 0x4000;
837  }
838 
839  /*
840  #i3958# Required to make this inline stuff work in WordXP, not
841  needed for 2003 interestingly
842  */
843  if (rFrameFormat.IsInline())
844  nFlags |= 0x8000;
845 
846  SwWW8Writer::WriteShort(*rWrt.pTableStrm, nFlags);
847 
848  // cTxbx
850  }
851 
852  RegisterWithFib(rFib, nFcStart, rWrt.pTableStrm->Tell() - nFcStart);
853 }
854 
855 void MainTextPlcDrawObj::RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
856  sal_uInt32 nLen) const
857 {
858  rFib.m_fcPlcfspaMom = nStart;
859  rFib.m_lcbPlcfspaMom = nLen;
860 }
861 
863 {
864  return 0;
865 }
866 
867 void HdFtPlcDrawObj::RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
868  sal_uInt32 nLen) const
869 {
870  rFib.m_fcPlcfspaHdr = nStart;
871  rFib.m_lcbPlcfspaHdr = nLen;
872 }
873 
875 {
876  return rFib.m_ccpText + rFib.m_ccpFootnote;
877 }
878 
879 bool PlcDrawObj::Append( WW8Export const & rWrt, WW8_CP nCp, const ww8::Frame& rFormat,
880  const Point& rNdTopLeft )
881 {
882  bool bRet = false;
883  const SwFrameFormat &rFrameFormat = rFormat.GetFrameFormat();
884  if (TXT_HDFT == rWrt.m_nTextTyp || TXT_MAINTEXT == rWrt.m_nTextTyp)
885  {
886  if (RES_FLYFRMFMT == rFrameFormat.Which())
887  {
888  // check for textflyframe and if it is the first in a Chain
889  if (rFrameFormat.GetContent().GetContentIdx())
890  bRet = true;
891  }
892  else
893  bRet = true;
894  }
895 
896  if (bRet)
897  {
898  DrawObj aObj(rFormat, nCp, rNdTopLeft, rWrt.TrueFrameDirection(rFrameFormat),
899  rWrt.GetHdFtIndex());
900  maDrawObjs.push_back(aObj);
901  }
902  return bRet;
903 }
904 
905 void DrawObj::SetShapeDetails(sal_uInt32 nId, sal_Int32 nThick)
906 {
907  mnShapeId = nId;
908  mnThick = nThick;
909 }
910 
912 {
913  rWrt.m_bInWriteEscher = true;
914  WW8_CP& rccp=TXT_TXTBOX == nTyp ? rWrt.pFib->m_ccpTxbx : rWrt.pFib->m_ccpHdrTxbx;
915 
916  bool bRet = WriteGenericText( rWrt, nTyp, rccp );
917 
918  WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() );
919  WW8Fib& rFib = *rWrt.pFib;
920  WW8_CP nMyOffset = rFib.m_ccpText + rFib.m_ccpFootnote + rFib.m_ccpHdr + rFib.m_ccpAtn
921  + rFib.m_ccpEdn;
922  if( TXT_TXTBOX == nTyp )
923  rWrt.m_pFieldTextBxs->Finish( nCP, nMyOffset );
924  else
925  rWrt.m_pFieldHFTextBxs->Finish( nCP, nMyOffset + rFib.m_ccpTxbx );
926  rWrt.m_bInWriteEscher = false;
927  return bRet;
928 }
929 
930 void WW8_WrPlcTextBoxes::Append( const SdrObject& rObj, sal_uInt32 nShapeId )
931 {
932  aContent.push_back( &rObj );
933  aShapeIds.push_back( nShapeId );
934  //save NULL, if we have an actual SdrObject
935  aSpareFormats.push_back(nullptr);
936 }
937 
938 void WW8_WrPlcTextBoxes::Append( const SwFrameFormat* pFormat, sal_uInt32 nShapeId )
939 {
940  //no sdr object, we insert a NULL in the aContent and save the real fmt in aSpareFormats.
941  aContent.push_back( nullptr );
942  aShapeIds.push_back( nShapeId );
943  aSpareFormats.push_back(pFormat);
944 }
945 
946 const std::vector<sal_uInt32>* WW8_WrPlcTextBoxes::GetShapeIdArr() const
947 {
948  return &aShapeIds;
949 }
950 
951 sal_uInt32 WW8Export::GetSdrOrdNum( const SwFrameFormat& rFormat ) const
952 {
953  sal_uInt32 nOrdNum;
954  const SdrObject* pObj = rFormat.FindRealSdrObject();
955  if( pObj )
956  nOrdNum = pObj->GetOrdNum();
957  else
958  {
959  // no Layout for this format, then recalc the ordnum
960  SwFrameFormat* pFormat = const_cast<SwFrameFormat*>(&rFormat);
961  nOrdNum = std::distance(m_rDoc.GetSpzFrameFormats()->begin(),
962  m_rDoc.GetSpzFrameFormats()->find( pFormat ) );
963 
965  if( pModel )
966  nOrdNum += pModel->GetPage( 0 )->GetObjCount();
967  }
968  return nOrdNum;
969 }
970 
971 void WW8Export::AppendFlyInFlys(const ww8::Frame& rFrameFormat,
972  const Point& rNdTopLeft)
973 {
974  OSL_ENSURE(!m_pEscher, "the EscherStream was already written!");
975  if (m_pEscher)
976  return ;
977  PlcDrawObj *pDrwO;
978  if (TXT_HDFT == m_nTextTyp)
979  pDrwO = m_pHFSdrObjs.get();
980  else
981  pDrwO = m_pSdrObjs.get();
982 
983  if (rFrameFormat.IsInline())
984  {
985  OutputField(nullptr, ww::eSHAPE, FieldString(ww::eSHAPE),
987  }
988 
989  WW8_CP nCP = Fc2Cp(Strm().Tell());
990  bool bSuccess = pDrwO->Append(*this, nCP, rFrameFormat, rNdTopLeft);
991  OSL_ENSURE(bSuccess, "Couldn't export a graphical element!");
992 
993  if (bSuccess)
994  {
995  static const sal_uInt8 aSpec8[] =
996  {
997  0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation
998  0x55, 0x08, 1 // sprmCFSpec
999  };
1000  // fSpec-Attribute true
1001 
1002  // A special character is required in the text for DrawObjects,
1003  // therefore a fSpec-Attribute
1004  m_pChpPlc->AppendFkpEntry( Strm().Tell() );
1005  WriteChar( 0x8 );
1006  m_pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aSpec8 ), aSpec8 );
1007 
1008  //Need dummy picture frame
1009  if (rFrameFormat.IsInline())
1010  OutGrf(rFrameFormat);
1011  }
1012 
1013  if (rFrameFormat.IsInline())
1014  OutputField(nullptr, ww::eSHAPE, OUString(), FieldFlags::Close);
1015 }
1016 
1018  const EditTextObject& rEditObj, sal_uInt8 nTyp )
1019  : MSWordAttrIter( rWr ), pEditObj(&rEditObj), pEditPool(nullptr), mnTyp(nTyp)
1020 {
1021  NextPara( 0 );
1022 }
1023 
1024 void MSWord_SdrAttrIter::NextPara( sal_Int32 nPar )
1025 {
1026  nPara = nPar;
1027  // Ignore change of attribute at position 0, because we expect that
1028  // the attributes are outputted at start of a paragraph anyway.
1029  aChrTextAtrArr.clear();
1030  aChrSetArr.clear();
1031  nCurrentSwPos = nTmpSwPos = 0;
1032 
1034  pEditPool = aSet.GetPool();
1035  eNdChrSet = ItemGet<SvxFontItem>(aSet,EE_CHAR_FONTINFO).GetCharSet();
1036 
1037  assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
1038  nScript = g_pBreakIt->GetBreakIter()->getScriptType( pEditObj->GetText(nPara), 0);
1039 
1041  nCurrentSwPos = SearchNext( 1 );
1042 }
1043 
1044 rtl_TextEncoding MSWord_SdrAttrIter::GetNextCharSet() const
1045 {
1046  if( !aChrSetArr.empty() )
1047  return aChrSetArr.back();
1048  return eNdChrSet;
1049 }
1050 
1051 // the first parameter in SearchNext() returns if it's a TextAtr
1052 sal_Int32 MSWord_SdrAttrIter::SearchNext( sal_Int32 nStartPos )
1053 {
1054  sal_Int32 nMinPos = SAL_MAX_INT32;
1055  for(const auto& rTextAtr : aTextAtrArr)
1056  {
1057  sal_Int32 nPos = rTextAtr.nStart; // first character attribute
1058  if( nPos >= nStartPos && nPos <= nMinPos )
1059  {
1060  nMinPos = nPos;
1061  SetCharSet(rTextAtr, true);
1062  }
1063 
1064  nPos = rTextAtr.nEnd; // last character attribute + 1
1065  if( nPos >= nStartPos && nPos < nMinPos )
1066  {
1067  nMinPos = nPos;
1068  SetCharSet(rTextAtr, false);
1069  }
1070  }
1071  return nMinPos;
1072 }
1073 
1074 void MSWord_SdrAttrIter::SetCharSet(const EECharAttrib& rAttr, bool bStart)
1075 {
1076  const SfxPoolItem& rItem = *rAttr.pAttr;
1077  if( rItem.Which() != EE_CHAR_FONTINFO )
1078  {
1079  return;
1080  }
1081 
1082  if( bStart )
1083  {
1084  rtl_TextEncoding eChrSet = static_cast<const SvxFontItem&>(rItem).GetCharSet();
1085  aChrSetArr.push_back( eChrSet );
1086  aChrTextAtrArr.push_back( &rAttr );
1087  }
1088  else
1089  {
1090  std::vector<const EECharAttrib*>::iterator it =
1091  std::find( aChrTextAtrArr.begin(), aChrTextAtrArr.end(), &rAttr );
1092  if ( it != aChrTextAtrArr.end() )
1093  {
1094  aChrSetArr.erase( aChrSetArr.begin() + (it - aChrTextAtrArr.begin()) );
1095  aChrTextAtrArr.erase( it );
1096  }
1097  }
1098 }
1099 
1101 {
1102  const SvxFieldItem &rField = static_cast<const SvxFieldItem &>(rHt);
1103  const SvxFieldData *pField = rField.GetField();
1104  if (auto pURL = dynamic_cast< const SvxURLField *>( pField ))
1105  {
1106  sal_uInt8 nOldTextTyp = m_rExport.m_nTextTyp;
1108  m_rExport.AttrOutput().StartURL( pURL->GetURL(), pURL->GetTargetFrame() );
1109 
1110  const OUString &rStr = pURL->GetRepresentation();
1112 
1113  m_rExport.AttrOutput().EndURL(false);
1114  m_rExport.m_nTextTyp = nOldTextTyp;
1115  }
1116 }
1117 
1118 void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos )
1119 {
1120  //Collect the which ids belong to the run that we will export after
1121  //outputting the underlying paragraph attributes. We will exclude
1122  //writing these from the underlying paragraph attributes to avoid
1123  //duplicate attributes in docx export. Doesn't matter in doc
1124  //export as later props just override earlier ones.
1125  std::set<sal_uInt16> aUsedRunWhichs;
1126  for(const auto& rTextAtr : aTextAtrArr)
1127  {
1128  if (nSwPos >= rTextAtr.nStart && nSwPos < rTextAtr.nEnd)
1129  {
1130  sal_uInt16 nWhich = rTextAtr.pAttr->Which();
1131  aUsedRunWhichs.insert(nWhich);
1132  }
1133 
1134  if( nSwPos < rTextAtr.nStart )
1135  break;
1136  }
1137 
1138  OutParaAttr(true, &aUsedRunWhichs);
1139 
1140  if (aTextAtrArr.empty())
1141  return;
1142 
1144  m_rExport.m_pOutFormatNode = nullptr;
1145 
1146  const SfxItemPool* pSrcPool = pEditPool;
1147  const SfxItemPool& rDstPool = m_rExport.m_rDoc.GetAttrPool();
1148 
1149  nTmpSwPos = nSwPos;
1150  // Did we already produce a <w:sz> element?
1151  m_rExport.m_bFontSizeWritten = false;
1152  for(const auto& rTextAtr : aTextAtrArr)
1153  {
1154  if (nSwPos >= rTextAtr.nStart && nSwPos < rTextAtr.nEnd)
1155  {
1156  sal_uInt16 nWhich = rTextAtr.pAttr->Which();
1157  if (nWhich == EE_FEATURE_FIELD)
1158  {
1159  OutEEField(*(rTextAtr.pAttr));
1160  continue;
1161  }
1162  if (nWhich == EE_FEATURE_TAB)
1163  {
1164  m_rExport.WriteChar(0x9);
1165  continue;
1166  }
1167 
1168  const sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
1169  if (nSlotId && nWhich != nSlotId)
1170  {
1171  nWhich = rDstPool.GetWhich(nSlotId);
1172  if (nWhich && nWhich != nSlotId &&
1173  nWhich < RES_UNKNOWNATR_BEGIN &&
1175  {
1176  // use always the SW-Which Id !
1177  std::unique_ptr<SfxPoolItem> pI(rTextAtr.pAttr->Clone());
1178  pI->SetWhich( nWhich );
1179  // Will this item produce a <w:sz> element?
1180  bool bFontSizeItem = nWhich == RES_CHRATR_FONTSIZE || nWhich == RES_CHRATR_CJK_FONTSIZE;
1181  if (!m_rExport.m_bFontSizeWritten || !bFontSizeItem)
1182  m_rExport.AttrOutput().OutputItem( *pI );
1183  if (bFontSizeItem)
1185  }
1186  }
1187  }
1188 
1189  if( nSwPos < rTextAtr.nStart )
1190  break;
1191  }
1192  m_rExport.m_bFontSizeWritten = false;
1193 
1194  nTmpSwPos = 0; // HasTextItem only allowed in the above area
1195  m_rExport.m_pOutFormatNode = pOldMod;
1196 }
1197 
1198 bool MSWord_SdrAttrIter::IsTextAttr(sal_Int32 nSwPos)
1199 {
1200  return std::any_of(aTextAtrArr.begin(), aTextAtrArr.end(),
1201  [nSwPos](const EECharAttrib& rTextAtr) {
1202  return (nSwPos >= rTextAtr.nStart && nSwPos < rTextAtr.nEnd) &&
1203  (rTextAtr.pAttr->Which() == EE_FEATURE_FIELD ||
1204  rTextAtr.pAttr->Which() == EE_FEATURE_TAB);
1205  }
1206  );
1207 }
1208 
1209 // HasItem is used for the consolidation of the double attribute Underline and
1210 // WordLineMode as a TextItem. OutAttr() calls the output function, which can
1211 // query for other items at the start position of attribute via HasItem().
1212 // Only attributes with an end can be queried.
1213 // The search is done with bDeep.
1214 const SfxPoolItem* MSWord_SdrAttrIter::HasTextItem(sal_uInt16 nWhich) const
1215 {
1217  m_rExport.m_rDoc.GetAttrPool(), nWhich);
1218  if (nWhich)
1219  {
1220  for (const auto& rTextAtr : aTextAtrArr)
1221  {
1222  if (nWhich == rTextAtr.pAttr->Which() && nTmpSwPos >= rTextAtr.nStart && nTmpSwPos < rTextAtr.nEnd)
1223  return rTextAtr.pAttr; // Found
1224  if (nTmpSwPos < rTextAtr.nStart)
1225  return nullptr;
1226  }
1227  }
1228  return nullptr;
1229 }
1230 
1231 const SfxPoolItem& MSWord_SdrAttrIter::GetItem( sal_uInt16 nWhich ) const
1232 {
1234  const SfxPoolItem* pRet = HasTextItem(nWhich);
1235  if (!pRet)
1236  {
1238  nWhich = GetSetWhichFromSwDocWhich(aSet, m_rExport.m_rDoc, nWhich);
1239  OSL_ENSURE(nWhich, "Impossible, catastrophic failure imminent");
1240  pRet = &aSet.Get(nWhich);
1241  }
1242  return *pRet;
1243 }
1244 
1245 //Drawing shapes properties inherit from a different pool that the document
1246 //styles. On export to .doc[x] they will default to style "Normal". Here explicitly
1247 //set any items which are not already set, but differ from "Normal".
1249 {
1251  (RES_POOLCOLL_STANDARD, false);
1252 
1253  SfxWhichIter aWhichIter(rSet);
1254  for (sal_uInt16 nEEWhich = aWhichIter.FirstWhich(); nEEWhich; nEEWhich = aWhichIter.NextWhich())
1255  {
1256  if (SfxItemState::SET != rSet.GetItemState(nEEWhich, false))
1257  {
1259  *pEditPool, nEEWhich);
1260  if (!nSwWhich)
1261  continue;
1262  bool bWanted = ( bCharAttr ? ( nSwWhich >= RES_CHRATR_BEGIN && nSwWhich < RES_TXTATR_END )
1263  : ( nSwWhich >= RES_PARATR_BEGIN && nSwWhich < RES_FRMATR_END ) );
1264  if (!bWanted)
1265  continue;
1266 
1267  const SfxPoolItem& rDrawItem = rSet.Get(nEEWhich);
1268  const SfxPoolItem& rStandardItem = pC->GetFormatAttr(nSwWhich);
1269  if (rDrawItem != rStandardItem)
1270  rSet.Put(rDrawItem);
1271  }
1272  }
1273 }
1274 
1275 void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>* pWhichsToIgnore)
1276 {
1278 
1279  SetItemsThatDifferFromStandard(bCharAttr, aSet);
1280 
1281  if (!aSet.Count())
1282  return;
1283 
1284  const SfxItemSet* pOldSet = m_rExport.GetCurItemSet();
1285  m_rExport.SetCurItemSet( &aSet );
1286 
1287  SfxItemIter aIter( aSet );
1288  const SfxPoolItem* pItem = aIter.GetCurItem();
1289 
1290  const SfxItemPool* pSrcPool = pEditPool,
1291  * pDstPool = &m_rExport.m_rDoc.GetAttrPool();
1292 
1293  do
1294  {
1295  sal_uInt16 nWhich = pItem->Which();
1296  if (pWhichsToIgnore && pWhichsToIgnore->find(nWhich) != pWhichsToIgnore->end())
1297  continue;
1298 
1299  sal_uInt16 nSlotId = pSrcPool->GetSlotId(nWhich);
1300 
1301  if ( nSlotId && nWhich != nSlotId &&
1302  0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) &&
1303  nWhich != nSlotId &&
1304  ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_TXTATR_END )
1305  : ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END ) ) )
1306  {
1307  // use always the SW-Which Id !
1308  std::unique_ptr<SfxPoolItem> pI(pItem->Clone());
1309  pI->SetWhich( nWhich );
1312  }
1313  } while ((pItem = aIter.NextItem()));
1314  m_rExport.SetCurItemSet( pOldSet );
1315 }
1316 
1318 {
1320 
1321  /*
1322  #i13885#
1323  When the object is actively being edited, that text is not set into
1324  the objects normal text object, but lives in a separate object.
1325  */
1326  if (rTextObj.IsTextEditActive())
1327  {
1328  pParaObj = rTextObj.CreateEditOutlinerParaObject();
1329  }
1330  else if (rTextObj.GetOutlinerParaObject())
1331  {
1332  pParaObj = *rTextObj.GetOutlinerParaObject();
1333  }
1334 
1335  if( pParaObj )
1336  {
1337  WriteOutliner(*pParaObj, nTyp);
1338  }
1339 }
1340 
1342 {
1343  bool bAnyWrite = false;
1344  const EditTextObject& rEditObj = rParaObj.GetTextObject();
1345  MSWord_SdrAttrIter aAttrIter( *this, rEditObj, nTyp );
1346 
1347  sal_Int32 nPara = rEditObj.GetParagraphCount();
1348  sal_uInt8 bNul = 0;
1349  for( sal_Int32 n = 0; n < nPara; ++n )
1350  {
1351  if( n )
1352  aAttrIter.NextPara( n );
1353 
1354  OSL_ENSURE( pO->empty(), " pO is not empty at start of line" );
1355 
1356  OUString aStr( rEditObj.GetText( n ));
1357  sal_Int32 nCurrentPos = 0;
1358  const sal_Int32 nEnd = aStr.getLength();
1359 
1360  const SfxItemSet& aSet(rEditObj.GetParaAttribs(n));
1361  bool bIsRTLPara = false;
1362  const SfxPoolItem *pItem;
1363  if(SfxItemState::SET == aSet.GetItemState(EE_PARA_WRITINGDIR, true, &pItem))
1364  {
1365  SvxFrameDirection nDir = static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue();
1366  bIsRTLPara = SvxFrameDirection::Horizontal_RL_TB == nDir;
1367  }
1368 
1369  do {
1370  const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd);
1371 
1372  bool bTextAtr = aAttrIter.IsTextAttr( nCurrentPos );
1373  if( !bTextAtr )
1374  OutSwString(aStr, nCurrentPos, nNextAttr - nCurrentPos);
1375 
1376  // At the end of the line the attributes are extended over the CR.
1377  // exception: foot note at line end
1378  if( nNextAttr == nEnd && !bTextAtr )
1379  WriteCR(); // CR after it
1380 
1381  // output of character attributes
1382  aAttrIter.OutAttr( nCurrentPos ); // nCurrentPos - 1 ??
1383 
1384  if (bIsRTLPara)
1385  {
1386  // This is necessary to make word order correct in MS Word.
1387  // In theory we should do this for complex-script runs only,
1388  // but Outliner does not split runs like Writer core did.
1389  // Fortunately, both MS Word and Writer seems to tolerate
1390  // that we turn it on for non complex-script runs.
1392  }
1393 
1394  m_pChpPlc->AppendFkpEntry( Strm().Tell(),
1395  pO->size(), pO->data() );
1396  pO->clear();
1397 
1398  // exception: foot note at line end
1399  if( nNextAttr == nEnd && bTextAtr )
1400  WriteCR(); // CR after it
1401  nCurrentPos = nNextAttr;
1402  aAttrIter.NextPos();
1403  }
1404  while( nCurrentPos < nEnd );
1405 
1406  OSL_ENSURE( pO->empty(), " pO is not empty at start of line" );
1407 
1408  pO->push_back( bNul ); // Style # as short
1409  pO->push_back( bNul );
1410 
1411  aAttrIter.OutParaAttr(false);
1412 
1413  sal_uLong nPos = Strm().Tell();
1414  m_pPapPlc->AppendFkpEntry( Strm().Tell(),
1415  pO->size(), pO->data() );
1416  pO->clear();
1417  m_pChpPlc->AppendFkpEntry( nPos );
1418  }
1419 
1420  bAnyWrite = 0 != nPara;
1421  if( !bAnyWrite )
1422  WriteStringAsPara( OUString() );
1423 }
1424 
1426 {
1427  //Toplevel groups get their winword extra data attached, and sub elements
1428  //use the defaults
1429  if (rEx.GetGroupLevel() > 1)
1430  return;
1431 
1432  SvStream& rSt = rEx.GetStream();
1433  //The last argument denotes the number of sub properties in this atom
1434  if (mbInline)
1435  {
1436  rEx.AddAtom(18, DFF_msofbtUDefProp, 3, 3); //Prop id is 0xF122
1437  rSt.WriteUInt16( 0x0390 ).WriteUInt32( 3 );
1438  rSt.WriteUInt16( 0x0392 ).WriteUInt32( 3 );
1439  //This sub property is required to be in the dummy inline frame as
1440  //well
1441  rSt.WriteUInt16( 0x053F ).WriteUInt32( nInlineHack );
1442  }
1443  else
1444  {
1445  rEx.AddAtom(24, DFF_msofbtUDefProp, 3, 4 ); //Prop id is 0xF122
1446  rSt.WriteUInt16( 0x038F ).WriteUInt32( mnXAlign );
1447  rSt.WriteUInt16( 0x0390 ).WriteUInt32( mnXRelTo );
1448  rSt.WriteUInt16( 0x0391 ).WriteUInt32( mnYAlign );
1449  rSt.WriteUInt16( 0x0392 ).WriteUInt32( mnYRelTo );
1450  }
1451 }
1452 
1454 {
1455  SfxItemState eBackSet = m_rDoc.GetPageDesc(0).GetMaster().
1456  GetItemState(RES_BACKGROUND);
1457  if (m_pHFSdrObjs->size() || m_pSdrObjs->size() || SfxItemState::SET == eBackSet)
1458  {
1459  OSL_ENSURE( !m_pEscher, "Who did not deleted the pointer?" );
1460  SvMemoryStream* pEscherStrm = new SvMemoryStream;
1461  pEscherStrm->SetEndian(SvStreamEndian::LITTLE);
1462  m_pEscher = new SwEscherEx(pEscherStrm, *this);
1463  }
1464 }
1465 
1467 {
1468  if (m_pEscher)
1469  {
1470  sal_uLong nStart = pTableStrm->Tell();
1471 
1474 
1475  pFib->m_fcDggInfo = nStart;
1476  pFib->m_lcbDggInfo = pTableStrm->Tell() - nStart;
1477  delete m_pEscher;
1478  m_pEscher = nullptr;
1479  }
1480 }
1481 
1483 {
1484  if( SvStream* pPicStrm = static_cast< SwEscherExGlobal& >( *mxGlobal ).GetPictureStream() )
1485  {
1486  // set the blip - entries to the correct stream pos
1487  sal_Int32 nEndPos = rWrt.Strm().Tell();
1488  mxGlobal->SetNewBlipStreamOffset( nEndPos );
1489 
1490  pPicStrm->Seek( 0 );
1491  rWrt.Strm().WriteStream( *pPicStrm );
1492  }
1493  Flush();
1494 }
1495 
1496 // Output- Routines for Escher Export
1497 
1499 {
1500 }
1501 
1503 {
1504 }
1505 
1507 {
1508  // this function will be called exactly once
1509  mxPicStrm = std::make_shared<SvMemoryStream>();
1510  mxPicStrm->SetEndian(SvStreamEndian::LITTLE);
1511  return mxPicStrm.get();
1512 }
1513 
1515  : EscherEx( std::make_shared<SwEscherExGlobal>(), pStrm), rWrt(rWW8Wrt), pEscherStrm(pStrm)
1516 {
1517  Init();
1518 }
1519 
1521 {
1522 }
1523 
1525 {
1527  GetStream().WriteUInt32( 0x80000000 );
1528 }
1529 
1530 void SwBasicEscherEx::WriteEmptyFlyFrame(const SwFrameFormat& rFormat, sal_uInt32 nShapeId)
1531 {
1533  AddShape(ESCHER_ShpInst_PictureFrame, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, nShapeId);
1534  // store anchor attribute
1535  WriteFrameExtraData(rFormat);
1536 
1537  AddAtom(6, DFF_msofbtUDefProp, 3, 1); //Prop id is 0xF122
1539 
1540  CloseContainer(); // ESCHER_SpContainer
1541 }
1542 
1543 static ShapeFlag AddMirrorFlags(ShapeFlag nFlags, const SwMirrorGrf &rMirror)
1544 {
1545  switch (rMirror.GetValue())
1546  {
1547  default:
1548  case MirrorGraph::Dont:
1549  break;
1550  case MirrorGraph::Vertical:
1551  nFlags |= ShapeFlag::FlipH;
1552  break;
1554  nFlags |= ShapeFlag::FlipV;
1555  break;
1556  case MirrorGraph::Both:
1557  nFlags |= ShapeFlag::FlipH | ShapeFlag::FlipV;
1558  break;
1559 
1560  }
1561  return nFlags;
1562 }
1563 //For i120928,this function is added to export graphic of bullet
1565 {
1567  AddShape(ESCHER_ShpInst_PictureFrame, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, 0x401);
1568  EscherPropertyContainer aPropOpt;
1569  GraphicObject aGraphicObject( rGrf );
1570  OString aUniqueId = aGraphicObject.GetUniqueID();
1571  if ( !aUniqueId.isEmpty() )
1572  {
1573  sal_uInt32 nBlibId = mxGlobal->GetBlibID( *(mxGlobal->QueryPictureStream()), aGraphicObject );
1574  if (nBlibId)
1575  aPropOpt.AddOpt(ESCHER_Prop_pib, nBlibId, true);
1576  }
1582  aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
1583  aPropOpt.AddOpt( ESCHER_Prop_dyTextTop, 0 );
1584  aPropOpt.AddOpt( ESCHER_Prop_dyTextBottom, 0 );
1585  aPropOpt.AddOpt( ESCHER_Prop_dxTextLeft, 0 );
1586  aPropOpt.AddOpt( ESCHER_Prop_dxTextRight, 0 );
1587  const Color aTmpColor( COL_WHITE );
1588  std::shared_ptr<SvxBrushItem> aBrush(std::make_shared<SvxBrushItem>(aTmpColor, RES_BACKGROUND));
1589  const SvxBrushItem* pRet = rWrt.GetCurrentPageBgBrush();
1590  if (pRet && (pRet->GetGraphic() ||( pRet->GetColor() != COL_TRANSPARENT)))
1591  aBrush.reset(pRet->Clone());
1592  WriteBrushAttr(*aBrush, aPropOpt);
1593 
1594  aPropOpt.AddOpt( ESCHER_Prop_pictureActive, 0 );
1595  aPropOpt.Commit( GetStream() );
1597  GetStream().WriteUInt32( 0x80000000 );
1598  CloseContainer();
1599 }
1600 
1601 sal_Int32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrameFormat& rFormat, sal_uInt32 nShapeId)
1602 {
1603  sal_Int32 nBorderThick=0;
1605  SwGrfNode *pGrfNd = pNd ? pNd->GetGrfNode() : nullptr;
1606  OSL_ENSURE(pGrfNd, "No SwGrfNode ?, suspicious");
1607  if (!pGrfNd)
1608  return nBorderThick;
1609 
1611 
1612  const SwMirrorGrf &rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
1614  AddMirrorFlags(ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, rMirror),
1615  nShapeId);
1616 
1617  EscherPropertyContainer aPropOpt;
1618 
1619  sal_uInt32 nFlags = ESCHER_BlipFlagDefault;
1620 
1621  if (pGrfNd->IsLinkedFile())
1622  {
1623  OUString sURL;
1624  pGrfNd->GetFileFilterNms( &sURL, nullptr );
1625 
1626  ww::bytes aBuf;
1627  SwWW8Writer::InsAsString16( aBuf, sURL );
1628  SwWW8Writer::InsUInt16( aBuf, 0 );
1629 
1630  aPropOpt.AddOpt(ESCHER_Prop_pibName, true, aBuf.size(), aBuf);
1633  }
1634  else
1635  {
1636  const Graphic& aGraphic(pGrfNd->GetGrf());
1637  GraphicObject aGraphicObject( aGraphic );
1638  OString aUniqueId = aGraphicObject.GetUniqueID();
1639 
1640  if (!aUniqueId.isEmpty())
1641  {
1642  sal_uInt32 nBlibId = mxGlobal->GetBlibID( *QueryPictureStream(), aGraphicObject);
1643  if (nBlibId)
1644  aPropOpt.AddOpt(ESCHER_Prop_pib, nBlibId, true);
1645  }
1646  }
1647 
1648  aPropOpt.AddOpt( ESCHER_Prop_pibFlags, nFlags );
1649  nBorderThick = WriteFlyFrameAttr(rFormat,mso_sptPictureFrame,aPropOpt);
1650  WriteGrfAttr(*pGrfNd, rFormat, aPropOpt);
1651 
1652  aPropOpt.Commit( GetStream() );
1653 
1654  // store anchor attribute
1655  WriteFrameExtraData( rFormat );
1656 
1657  CloseContainer(); // ESCHER_SpContainer
1658  return nBorderThick;
1659 }
1660 
1662  EscherPropertyContainer& rPropOpt)
1663 {
1664  const SfxPoolItem* pItem;
1665  GraphicDrawMode nMode = GraphicDrawMode::Standard;
1666  sal_Int32 nContrast = 0;
1667  sal_Int16 nBrightness = 0;
1668 
1669  if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_CONTRAST,
1670  true, &pItem))
1671  {
1672  nContrast = static_cast<const SfxInt16Item*>(pItem)->GetValue();
1673  }
1674 
1675  if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_LUMINANCE,
1676  true, &pItem))
1677  {
1678  nBrightness = static_cast<const SfxInt16Item*>(pItem)->GetValue();
1679  }
1680 
1681  if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_DRAWMODE,
1682  true, &pItem))
1683  {
1684  nMode = static_cast<GraphicDrawMode>(static_cast<const SfxEnumItemInterface*>(pItem)->GetEnumValue());
1685  if (nMode == GraphicDrawMode::Watermark)
1686  {
1687  /*
1688  There is no real watermark mode in word, we must use standard
1689  mode and modify our ones by 70% extra brightness and 70% less
1690  contrast. This means that unmodified default OOo watermark
1691  will turn back into watermark, and modified OOo watermark will
1692  change into a close visual representation in standardmode
1693  */
1694  nBrightness += 70;
1695  if (nBrightness > 100)
1696  nBrightness = 100;
1697  nContrast -= 70;
1698  if (nContrast < -100)
1699  nContrast = -100;
1700  nMode = GraphicDrawMode::Standard;
1701  }
1702  }
1703 
1704  sal_uInt32 nPictureMode;
1705  if (nMode == GraphicDrawMode::Greys)
1706  nPictureMode = 0x40004;
1707  else if (nMode == GraphicDrawMode::Mono)
1708  nPictureMode = 0x60006;
1709  else
1710  nPictureMode = 0;
1711  rPropOpt.AddOpt( ESCHER_Prop_pictureActive, nPictureMode );
1712 
1713  if (nContrast != 0)
1714  {
1715  nContrast+=100;
1716  if (nContrast == 100)
1717  nContrast = 0x10000;
1718  else if (nContrast < 100)
1719  {
1720  nContrast *= 0x10000;
1721  nContrast /= 100;
1722  }
1723  else if (nContrast < 200)
1724  nContrast = (100 * 0x10000) / (200-nContrast);
1725  else
1726  nContrast = 0x7fffffff;
1727  rPropOpt.AddOpt( ESCHER_Prop_pictureContrast, nContrast);
1728  }
1729 
1730  if (nBrightness != 0)
1731  rPropOpt.AddOpt( ESCHER_Prop_pictureBrightness, nBrightness * 327 );
1732 
1733  sal_Int32 nCropL = 0;
1734  sal_Int32 nCropR = 0;
1735  sal_Int32 nCropT = 0;
1736  sal_Int32 nCropB = 0;
1737  if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_CROPGRF,
1738  true, &pItem))
1739  {
1740  const SwCropGrf& rCrop = *static_cast<const SwCropGrf*>(pItem);
1741  nCropL += rCrop.GetLeft();
1742  nCropR += rCrop.GetRight();
1743  nCropT += rCrop.GetTop();
1744  nCropB += rCrop.GetBottom();
1745  }
1746 
1747  // simulate border padding as a negative crop.
1748  if (SfxItemState::SET == rFormat.GetItemState(RES_BOX, false, &pItem))
1749  {
1750  const SvxBoxItem& rBox = *static_cast<const SvxBoxItem*>(pItem);
1751  nCropL -= rBox.GetDistance( SvxBoxItemLine::LEFT );
1752  nCropR -= rBox.GetDistance( SvxBoxItemLine::RIGHT );
1753  nCropT -= rBox.GetDistance( SvxBoxItemLine::TOP );
1754  nCropB -= rBox.GetDistance( SvxBoxItemLine::BOTTOM );
1755  }
1756 
1757  const Size aSz( rNd.GetTwipSize() );
1758  if( 0 != nCropL )
1759  rPropOpt.AddOpt( ESCHER_Prop_cropFromLeft, ToFract16( nCropL, aSz.Width()) );
1760  if( 0 != nCropR )
1761  rPropOpt.AddOpt( ESCHER_Prop_cropFromRight, ToFract16( nCropR, aSz.Width()));
1762  if( 0 != nCropT )
1763  rPropOpt.AddOpt( ESCHER_Prop_cropFromTop, ToFract16( nCropT, aSz.Height()));
1764  if( 0 != nCropB )
1765  rPropOpt.AddOpt( ESCHER_Prop_cropFromBottom, ToFract16( nCropB, aSz.Height()));
1766 }
1767 
1768 void SwBasicEscherEx::SetPicId(const SdrObject &, sal_uInt32,
1770 {
1771 }
1772 
1773 void SwEscherEx::SetPicId(const SdrObject &rSdrObj, sal_uInt32 nShapeId,
1774  EscherPropertyContainer &rPropOpt)
1775 {
1776  pTextBxs->Append(rSdrObj, nShapeId);
1777  sal_uInt32 nPicId = pTextBxs->Count();
1778  nPicId *= 0x10000;
1779  rPropOpt.AddOpt( ESCHER_Prop_pictureId, nPicId );
1780 }
1781 
1782 sal_Int32 SwBasicEscherEx::WriteOLEFlyFrame(const SwFrameFormat& rFormat, sal_uInt32 nShapeId)
1783 {
1784  sal_Int32 nBorderThick = 0;
1785  if (const SdrObject* pSdrObj = rFormat.FindRealSdrObject())
1786  {
1787  SwNodeIndex aIdx(*rFormat.GetContent().GetContentIdx(), 1);
1788  SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
1789  sal_Int64 nAspect = rOLENd.GetAspect();
1790 
1791  uno::Reference < embed::XEmbeddedObject > xObj(rOLENd.GetOLEObj().GetOleRef());
1792 
1793  // the rectangle is used to transport the size of the object
1794  // the left, top corner is set to ( 0, 0 ) by default constructor,
1795  // if the width and height are set correctly bRectIsSet should be set to true
1796  awt::Rectangle aRect;
1797  bool bRectIsSet = false;
1798 
1799  // TODO/LATER: should the icon size be stored in case of iconified object?
1800  if ( xObj.is() && nAspect != embed::Aspects::MSOLE_ICON )
1801  {
1802  try
1803  {
1804  awt::Size aSize = xObj->getVisualAreaSize( nAspect );
1805  aRect.Width = aSize.Width;
1806  aRect.Height = aSize.Height;
1807  bRectIsSet = true;
1808  }
1809  catch( const uno::Exception& )
1810  {}
1811  }
1812 
1813  /*
1814  #i5970#
1815  Export floating ole2 .doc ver 8+ wmf ole2 previews as emf previews
1816  instead ==> allows unicode text to be preserved
1817  */
1818 #ifdef OLE_PREVIEW_AS_EMF
1819  const Graphic* pGraphic = rOLENd.GetGraphic();
1820 #endif
1822 
1823  EscherPropertyContainer aPropOpt;
1824  const SwMirrorGrf &rMirror = rOLENd.GetSwAttrSet().GetMirrorGrf();
1825  WriteOLEPicture(aPropOpt,
1826  AddMirrorFlags(ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::OLEShape, rMirror),
1827  pGraphic ? *pGraphic : Graphic(), *pSdrObj, nShapeId, bRectIsSet ? &aRect : nullptr );
1828 
1829  nBorderThick = WriteFlyFrameAttr(rFormat, mso_sptPictureFrame, aPropOpt);
1830  WriteGrfAttr(rOLENd, rFormat, aPropOpt);
1831  aPropOpt.Commit(GetStream());
1832 
1833  // store anchor attribute
1834  WriteFrameExtraData( rFormat );
1835 
1836  CloseContainer(); // ESCHER_SpContainer
1837  }
1838  return nBorderThick;
1839 }
1840 
1842  EscherPropertyContainer& rPropOpt)
1843 {
1844  bool bSetOpacity = false;
1845  sal_uInt32 nOpaque = 0;
1846  if (const GraphicObject *pGraphicObject = rBrush.GetGraphicObject())
1847  {
1848  OString aUniqueId = pGraphicObject->GetUniqueID();
1849  if (!aUniqueId.isEmpty())
1850  {
1851  sal_uInt32 nBlibId = mxGlobal->GetBlibID(*QueryPictureStream(), *pGraphicObject);
1852  if (nBlibId)
1853  rPropOpt.AddOpt(ESCHER_Prop_fillBlip,nBlibId,true);
1854  }
1855 
1856  nOpaque = 255 - pGraphicObject->GetAttr().GetAlpha();
1857  if (0 != nOpaque)
1858  bSetOpacity = true;
1859 
1861  rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
1862  rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0 );
1863  }
1864  else
1865  {
1866  sal_uInt32 nFillColor = GetColor(rBrush.GetColor());
1867  rPropOpt.AddOpt( ESCHER_Prop_fillColor, nFillColor );
1868  rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, nFillColor ^ 0xffffff );
1869  rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 );
1870 
1871  nOpaque = 255 - rBrush.GetColor().GetAlpha();
1872  if (0 != nOpaque)
1873  bSetOpacity = true;
1874  }
1875 
1876  if (bSetOpacity)
1877  {
1878  nOpaque = (nOpaque * 100) / 0xFE;
1879  nOpaque = ((100 - nOpaque) << 16) / 100;
1880  rPropOpt.AddOpt(ESCHER_Prop_fillOpacity, nOpaque);
1881  }
1882 }
1883 
1885  MSO_SPT eShapeType, EscherPropertyContainer& rPropOpt)
1886 {
1887  sal_Int32 nLineWidth=0;
1888  const SfxPoolItem* pItem;
1889  bool bFirstLine = true;
1890  if (SfxItemState::SET == rFormat.GetItemState(RES_BOX, true, &pItem))
1891  {
1892  static const o3tl::enumarray<SvxBoxItemLine, sal_uInt16> aExhperProp =
1893  {
1896  };
1897  const SvxBorderLine* pLine;
1898 
1900  {
1901  pLine = static_cast<const SvxBoxItem*>(pItem)->GetLine( n );
1902  if( nullptr != pLine )
1903  {
1904  if( bFirstLine )
1905  {
1906  sal_uInt32 nLineColor = GetColor(pLine->GetColor());
1907  rPropOpt.AddOpt( ESCHER_Prop_lineColor, nLineColor );
1909  nLineColor ^ 0xffffff );
1910 
1911  MSO_LineStyle eStyle;
1912  if( pLine->isDouble() )
1913  {
1914  // double line
1915  nLineWidth = pLine->GetWidth();
1916  if( pLine->GetInWidth() == pLine->GetOutWidth() )
1917  eStyle = mso_lineDouble;
1918  else if( pLine->GetInWidth() < pLine->GetOutWidth() )
1919  eStyle = mso_lineThickThin;
1920  else
1921  eStyle = mso_lineThinThick;
1922  }
1923  else
1924  {
1925  // simple line
1926  eStyle = mso_lineSimple;
1927  nLineWidth = pLine->GetWidth();
1928  }
1929 
1930  rPropOpt.AddOpt( ESCHER_Prop_lineStyle, eStyle );
1931  rPropOpt.AddOpt( ESCHER_Prop_lineWidth,
1932  DrawModelToEmu( nLineWidth ));
1933 
1934  MSO_LineDashing eDashing = mso_lineSolid;
1935  switch (pLine->GetBorderLineStyle())
1936  {
1937  case SvxBorderLineStyle::DASHED:
1938  eDashing = mso_lineDashGEL;
1939  break;
1940  case SvxBorderLineStyle::DOTTED:
1941  eDashing = mso_lineDotGEL;
1942  break;
1943  case SvxBorderLineStyle::SOLID:
1944  default:
1945  break;
1946  }
1947  rPropOpt.AddOpt( ESCHER_Prop_lineDashing, eDashing );
1948  rPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x8000E );
1949 
1950  //Use import logic to determine how much of border will go
1951  //outside graphic
1953  eStyle,eShapeType,nLineWidth);
1954  bFirstLine = false;
1955  }
1956  rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(
1957  static_cast<const SvxBoxItem*>(pItem)->GetDistance( n ) ));
1958  }
1959  else
1960  rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(static_cast<const SvxBoxItem*>(pItem)->GetDistance( n )) );
1961  }
1962  }
1963  else
1964  {
1965  rPropOpt.AddOpt( ESCHER_Prop_dyTextTop, 0 );
1966  rPropOpt.AddOpt( ESCHER_Prop_dyTextBottom, 0 );
1967  rPropOpt.AddOpt( ESCHER_Prop_dxTextLeft, 0 );
1968  rPropOpt.AddOpt( ESCHER_Prop_dxTextRight, 0 );
1969  }
1970 
1971  if( bFirstLine ) // no valid line found
1972  {
1973  rPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
1974  }
1975  const SwAttrSet& rAttrSet = rFormat.GetAttrSet();
1976  if (SfxItemState::SET == rAttrSet.GetItemState(RES_BOX, false, &pItem))
1977  {
1978  const SvxBoxItem* pBox = static_cast<const SvxBoxItem*>(pItem);
1979  if( pBox )
1980  {
1981  const SfxPoolItem* pShadItem;
1982  if (SfxItemState::SET
1983  == rAttrSet.GetItemState(RES_SHADOW, true, &pShadItem))
1984  {
1985  const SvxShadowItem* pSI = static_cast<const SvxShadowItem*>(pShadItem);
1986 
1987  constexpr sal_uInt32 nShadowType = 131074; // shadow type of ms word. need to set the default value.
1988 
1989  Color nColor = pSI->GetColor();
1990  sal_Int32 nOffX
1992  sal_Int32 nOffY
1994 
1995  SvxShadowLocation eLocation = pSI->GetLocation();
1996  if( (eLocation!=SvxShadowLocation::NONE) && (pSI->GetWidth()!=0) )
1997  {
1998  switch( eLocation )
1999  {
2000  case SvxShadowLocation::TopLeft:
2001  {
2002  nOffX = -nOffX;
2003  nOffY = -nOffY;
2004  }
2005  break;
2006  case SvxShadowLocation::TopRight:
2007  {
2008  nOffY = -nOffY;
2009  }
2010  break;
2011  case SvxShadowLocation::BottomLeft:
2012  {
2013  nOffX = -nOffX;
2014  }
2015  break;
2016  case SvxShadowLocation::BottomRight:
2017  break;
2018  default:
2019  break;
2020  }
2021 
2022  rPropOpt.AddOpt( DFF_Prop_shadowColor, wwUtility::RGBToBGR(nColor));
2023  rPropOpt.AddOpt( DFF_Prop_shadowOffsetX, nOffX );
2024  rPropOpt.AddOpt( DFF_Prop_shadowOffsetY, nOffY );
2025  rPropOpt.AddOpt( DFF_Prop_fshadowObscured, nShadowType );
2026  }
2027  }
2028  }
2029  }
2030 
2031  // SwWW8ImplReader::Read_GrafLayer() imports these as opaque
2032  // unconditionally, so if both are true, don't export the property.
2033  const bool bIsInHeader = sw::IsFlyFrameFormatInHeader(rFormat);
2034  const bool bIsThrough = rFormat.GetSurround().GetValue() == css::text::WrapTextMode_THROUGH;
2035 
2036  // Anything (like a transparent image) that allows text to wrap through should not force a non-transparent background,
2037  // and neither should the commonly seen backgrounds anchored in headers.
2038  if (bIsInHeader || bIsThrough)
2039  {
2040  std::unique_ptr<SvxBrushItem> aBrush(rFormat.makeBackgroundBrushItem());
2041 
2042  if(aBrush)
2043  {
2044  WriteBrushAttr(*aBrush, rPropOpt);
2045  }
2046  }
2047  else
2048  {
2049  // for unknown reasons, force exporting a non-transparent background on fly frames.
2050  std::shared_ptr<SvxBrushItem> aBrush(rWrt.TrueFrameBgBrush(rFormat));
2051 
2052  if(aBrush)
2053  {
2054  WriteBrushAttr(*aBrush, rPropOpt);
2055  }
2056  }
2057 
2058  const SdrObject* pObj = rFormat.FindRealSdrObject();
2059 
2060  if( pObj && (pObj->GetLayer() == GetHellLayerId() ||
2061  pObj->GetLayer() == GetInvisibleHellId() ) && !(bIsInHeader && bIsThrough))
2062  {
2063  rPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x200020 );
2064  }
2065 
2066  PreWriteHyperlinkWithinFly(rFormat,rPropOpt);
2067 
2068  return nLineWidth;
2069 }
2070 
2071 sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, MSO_SPT eShapeType,
2072  EscherPropertyContainer& rPropOpt)
2073 {
2074  sal_Int32 nLineWidth = SwBasicEscherEx::WriteFlyFrameAttr(rFormat, eShapeType,
2075  rPropOpt);
2076 
2077  /*
2078  These are not in SwBasicEscherEx::WriteFlyFrameAttr because inline objs
2079  can't do it in word and it hacks it in by stretching the graphic that
2080  way, perhaps we should actually draw in this space into the graphic we
2081  are exporting!
2082  */
2083  const SfxPoolItem* pItem;
2084  if (SfxItemState::SET == rFormat.GetItemState(RES_LR_SPACE, true, &pItem))
2085  {
2087  DrawModelToEmu( static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft() ) );
2089  DrawModelToEmu( static_cast<const SvxLRSpaceItem*>(pItem)->GetRight() ) );
2090  }
2091  else
2092  {
2093  rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistLeft, 0 );
2094  rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistRight, 0 );
2095  }
2096 
2097  if (SfxItemState::SET == rFormat.GetItemState(RES_UL_SPACE, true, &pItem))
2098  {
2100  DrawModelToEmu( static_cast<const SvxULSpaceItem*>(pItem)->GetUpper() ) );
2102  DrawModelToEmu( static_cast<const SvxULSpaceItem*>(pItem)->GetLower() ) );
2103  }
2104 
2105  if (rFormat.GetSurround().IsContour())
2106  {
2107  if (const SwNoTextNode *pNd = GetNoTextNodeFromSwFrameFormat(rFormat))
2108  {
2109  const tools::PolyPolygon *pPolyPoly = pNd->HasContour();
2110  if (pPolyPoly && pPolyPoly->Count())
2111  {
2112  tools::Polygon aPoly = CorrectWordWrapPolygonForExport(*pPolyPoly, pNd, /*bCorrectCrop=*/false);
2113  SvMemoryStream aPolyDump;
2114  aPolyDump.SetEndian(SvStreamEndian::LITTLE);
2115 
2116  sal_uInt16 nLen = aPoly.GetSize();
2117  aPolyDump.WriteUInt16( nLen );
2118  aPolyDump.WriteUInt16( nLen );
2119  aPolyDump.WriteUInt16( 8 );
2120  for (sal_uInt16 nI = 0; nI < nLen; ++nI)
2121  {
2122  aPolyDump.WriteUInt32( aPoly[nI].X() );
2123  aPolyDump.WriteUInt32( aPoly[nI].Y() );
2124  }
2125 
2126  rPropOpt.AddOpt(DFF_Prop_pWrapPolygonVertices, false, 0, aPolyDump);
2127  }
2128  }
2129  }
2130 
2131  PreWriteHyperlinkWithinFly(rFormat,rPropOpt);
2132 
2133  return nLineWidth;
2134 }
2135 
2137 {
2138  MapUnit eMap = MapUnit::MapTwip;
2140  {
2141  // PPT works only with units of 576DPI
2142  // WW however is using twips, i.e 1440DPI.
2143  eMap = pModel->GetScaleUnit();
2144  }
2145 
2146  // MS-DFF-Properties mostly are in EMU (English Metric Units)
2148  aFact /= GetMapFactor(MapUnit::Map100thMM, eMap).X();
2149  mnEmuMul = aFact.GetNumerator();
2150  mnEmuDiv = aFact.GetDenominator();
2151 
2153 }
2154 
2155 sal_Int32 SwBasicEscherEx::ToFract16(sal_Int32 nVal, sal_uInt32 nMax)
2156 {
2157  if (nMax)
2158  {
2159  if (nVal >= 0)
2160  {
2161  sal_Int32 nMSVal = (nVal / 65536) * nMax;
2162  nMSVal += (nVal * 65536) / nMax;
2163  return nMSVal;
2164  } else {
2165  // negative fraction does not have "-0", fractional part is always
2166  // positive: -0.4 represented as -1 + 0.6
2167  sal_Int32 const nDiv = (nVal / sal_Int32(nMax)) - 1;
2168  sal_uInt32 nMSVal = (sal_uInt32(nDiv) << 16) & 0xffff0000;
2169  nMSVal += (nVal * 65536) / sal_Int32(nMax) + (-nDiv * 65536);
2170  return nMSVal;
2171  }
2172  }
2173  return 0;
2174 }
2175 
2177 {
2179 }
2180 
2182 {
2183  if( SvStream* pPicStrm = static_cast< SwEscherExGlobal& >( *mxGlobal ).GetPictureStream() )
2184  {
2185  // set the blip - entries to the correct stream pos
2186  sal_Int32 nEndPos = pPicStrm->Tell();
2187  mxGlobal->WriteBlibStoreEntry(*pEscherStrm, 1, nEndPos);
2188 
2189  pPicStrm->Seek(0);
2190  pEscherStrm->WriteStream( *pPicStrm );
2191  }
2192 }
2193 
2195  : SwBasicEscherEx(pStrm, rWW8Wrt),
2196  pTextBxs(nullptr)
2197 {
2200 
2201  sal_uInt16 nColorCount = 4;
2202  pStrm ->WriteUInt16( nColorCount << 4 ) // instance
2203  .WriteUInt16( ESCHER_SplitMenuColors ) // record type
2204  .WriteUInt32( nColorCount * 4 ) // size
2205  .WriteUInt32( 0x08000004 )
2206  .WriteUInt32( 0x08000001 )
2207  .WriteUInt32( 0x08000002 )
2208  .WriteUInt32( 0x100000f7 );
2209 
2210  CloseContainer(); // ESCHER_DggContainer
2211 
2212  sal_uInt8 i = 2; // for header/footer and the other
2213  PlcDrawObj *pSdrObjs = rWrt.m_pHFSdrObjs.get();
2214  pTextBxs = rWrt.m_pHFTextBxs.get();
2215 
2216  // if no header/footer -> skip over
2217  if (!pSdrObjs->size())
2218  {
2219  --i;
2220  pSdrObjs = rWrt.m_pSdrObjs.get();
2221  pTextBxs = rWrt.m_pTextBxs.get();
2222  }
2223 
2224  for( ; i--; pSdrObjs = rWrt.m_pSdrObjs.get(), pTextBxs = rWrt.m_pTextBxs.get() )
2225  {
2226  // "dummy char" (or any Count ?) - why? Only Microsoft knows it.
2227  GetStream().WriteChar( i );
2228 
2230 
2231  EnterGroup();
2232 
2233  sal_uLong nSecondShapeId = pSdrObjs == rWrt.m_pSdrObjs.get() ? GenerateShapeId() : 0;
2234 
2235  // write now all Writer-/DrawObjects
2236  DrawObjPointerVector aSorted;
2237  MakeZOrderArrAndFollowIds(pSdrObjs->GetObjArr(), aSorted);
2238 
2239  sal_uInt32 nShapeId=0;
2240  for (auto& pObj : aSorted)
2241  {
2242  sal_Int32 nBorderThick=0;
2243  OSL_ENSURE(pObj, "impossible");
2244  if (!pObj)
2245  continue;
2246  const ww8::Frame &rFrame = pObj->maContent;
2247  const SwFrameFormat& rFormat = rFrame.GetFrameFormat();
2248 
2249  switch (rFrame.GetWriterType())
2250  {
2251  case ww8::Frame::eTextBox:
2252  case ww8::Frame::eOle:
2253  case ww8::Frame::eGraphic:
2254  nBorderThick = WriteFlyFrame(*pObj, nShapeId, aSorted);
2255  break;
2257  nShapeId = GenerateShapeId();
2258  WriteOCXControl(rFormat, nShapeId);
2259  break;
2260  case ww8::Frame::eDrawing:
2261  {
2263  const SdrObject* pSdrObj = rFormat.FindRealSdrObject();
2264  if (pSdrObj)
2265  {
2266  nShapeId = AddSdrObject(*pSdrObj);
2267  }
2268 #if OSL_DEBUG_LEVEL > 0
2269  else
2270  OSL_ENSURE( false, "Where is the SDR-Object?" );
2271 #endif
2272  }
2273  break;
2274  default:
2275  break;
2276  }
2277 
2278  if( !nShapeId )
2279  {
2280  nShapeId = AddDummyShape();
2281  }
2282 
2283  pObj->SetShapeDetails(nShapeId, nBorderThick);
2284  }
2285 
2286  EndSdrObjectPage(); // ???? Bugfix for 74724
2287 
2288  if( nSecondShapeId )
2289  {
2291 
2293  ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::Background,
2294  nSecondShapeId );
2295 
2296  EscherPropertyContainer aPropOpt;
2297  const SwFrameFormat &rFormat = rWrt.m_rDoc.GetPageDesc(0).GetMaster();
2298  const SfxPoolItem* pItem = nullptr;
2299  SfxItemState eState = rFormat.GetItemState(RES_BACKGROUND, true,
2300  &pItem);
2301  if (SfxItemState::SET == eState && pItem)
2302  {
2303  const SvxBrushItem* pBrush = static_cast<const SvxBrushItem*>(pItem);
2304  WriteBrushAttr(*pBrush, aPropOpt);
2305 
2307  if( ePos != GPOS_NONE && ePos != GPOS_AREA )
2308  {
2309  /* #i56806# 0x033F parameter specifies a 32-bit field of shape boolean properties.
2310  0x10001 means fBackground and fUsefBackground flag are true thus background
2311  picture will be shown as "tiled" fill.*/
2312  aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 );
2313  }
2314  }
2315  aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
2316  aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080008 );
2317  aPropOpt.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
2318  aPropOpt.AddOpt( ESCHER_Prop_lineWidth, 0 );
2319 
2320  aPropOpt.Commit( *pStrm );
2321 
2322  AddAtom( 4, ESCHER_ClientData );
2323  GetStream().WriteInt32( 1 );
2324 
2325  CloseContainer(); // ESCHER_SpContainer
2326  }
2327  CloseContainer(); // ESCHER_DgContainer
2328  }
2329 }
2330 
2332 {
2333 }
2334 
2336 {
2337  pEscherStrm->Seek(0);
2339  delete pEscherStrm;
2340  pEscherStrm = nullptr;
2341 }
2342 
2343 
2344 namespace
2345 {
2346  template<typename OrientType>
2347  void lcl_SetRelationOrient(OrientType& rOrient, const sw::WW8AnchorConv eConv, const std::function<void()>& fDefault)
2348  {
2349  switch(eConv)
2350  {
2352  // #i33818#
2353  rOrient.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA);
2354  break;
2356  rOrient.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
2357  break;
2359  rOrient.SetRelationOrient(text::RelOrientation::FRAME);
2360  break;
2362  rOrient.SetRelationOrient(text::RelOrientation::CHAR);
2363  break;
2365  rOrient.SetRelationOrient(text::RelOrientation::TEXT_LINE);
2366  break;
2367  default:
2368  fDefault();
2369  }
2370  }
2371 }
2398  SwFormatVertOrient& _iorVertOri,
2399  const SwFrameFormat& _rFrameFormat )
2400 {
2401  const RndStdIds eAnchor = _rFrameFormat.GetAnchor().GetAnchorId();
2402 
2403  if ( (RndStdIds::FLY_AS_CHAR == eAnchor) || (RndStdIds::FLY_AT_FLY == eAnchor) )
2404  {
2405  // no conversion for as-character or at frame anchored objects
2406  return false;
2407  }
2408 
2409  // determine value of attribute 'Follow text flow', because positions aligned
2410  // at page areas have to be converted, if it's set.
2411  const bool bFollowTextFlow = _rFrameFormat.GetFollowTextFlow().GetValue();
2412 
2413  // check, if horizontal and vertical position have to be converted due to
2414  // the fact, that the object is anchored at a paragraph, which has a "column
2415  // break before" attribute
2416  bool bConvDueToAnchoredAtColBreakPara( false );
2417  if ( ( (eAnchor == RndStdIds::FLY_AT_PARA) || (eAnchor == RndStdIds::FLY_AT_CHAR) ) &&
2418  _rFrameFormat.GetAnchor().GetContentAnchor() &&
2419  _rFrameFormat.GetAnchor().GetContentAnchor()->nNode.GetNode().IsTextNode() )
2420  {
2421  SwTextNode& rAnchorTextNode =
2422  dynamic_cast<SwTextNode&>(_rFrameFormat.GetAnchor().GetContentAnchor()->nNode.GetNode());
2423  const SvxFormatBreakItem& rBreak = ItemGet<SvxFormatBreakItem>(rAnchorTextNode, RES_BREAK);
2424  if (rBreak.GetBreak() == SvxBreak::ColumnBefore)
2425  {
2426  bConvDueToAnchoredAtColBreakPara = true;
2427  }
2428  }
2429 
2432  // convert horizontal position, if needed
2433  {
2434 
2435  // determine, if conversion has to be performed due to the position orientation
2436  bool bConvDueToOrientation( false );
2437  {
2438  const sal_Int16 eHOri = _iorHoriOri.GetHoriOrient();
2439  bConvDueToOrientation = eHOri == text::HoriOrientation::LEFT || eHOri == text::HoriOrientation::RIGHT ||
2440  eHOri == text::HoriOrientation::INSIDE || eHOri == text::HoriOrientation::OUTSIDE ||
2441  ( eHOri != text::HoriOrientation::CENTER && _iorHoriOri.IsPosToggle() );
2442  }
2443 
2444  // determine conversion type due to the position relation
2445  if ( bConvDueToAnchoredAtColBreakPara )
2446  {
2447  eHoriConv = sw::WW8AnchorConv::CONV2PG;
2448  }
2449  else if ( _iorHoriOri.IsPosToggle()
2450  && _iorHoriOri.GetHoriOrient() == text::HoriOrientation::RIGHT )
2451  {
2452  eHoriConv = sw::WW8AnchorConv::NO_CONV;
2453  _iorHoriOri.SetHoriOrient( text::HoriOrientation::OUTSIDE );
2454  }
2455  else
2456  {
2457  switch ( _iorHoriOri.GetRelationOrient() )
2458  {
2459  case text::RelOrientation::PAGE_FRAME:
2460  case text::RelOrientation::PAGE_PRINT_AREA:
2461  {
2462  if ( bConvDueToOrientation || bFollowTextFlow )
2463  eHoriConv = sw::WW8AnchorConv::CONV2PG;
2464  }
2465  break;
2466  case text::RelOrientation::PAGE_LEFT:
2467  case text::RelOrientation::PAGE_RIGHT:
2468  {
2469  // relation not supported by WW8. Thus, conversion always needed.
2470  eHoriConv = sw::WW8AnchorConv::CONV2PG;
2471  }
2472  break;
2473  case text::RelOrientation::FRAME:
2474  {
2475  if ( bConvDueToOrientation )
2477  }
2478  break;
2479  case text::RelOrientation::PRINT_AREA:
2480  case text::RelOrientation::FRAME_LEFT:
2481  case text::RelOrientation::FRAME_RIGHT:
2482  {
2483  // relation not supported by WW8. Thus, conversion always needed.
2485  }
2486  break;
2487  case text::RelOrientation::CHAR:
2488  {
2489  if ( bConvDueToOrientation )
2490  eHoriConv = sw::WW8AnchorConv::CONV2CHAR;
2491  }
2492  break;
2493  default:
2494  OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown horizontal relation" );
2495  }
2496  }
2497  }
2498 
2499  // convert vertical position, if needed
2500  {
2501 
2502  // determine, if conversion has to be performed due to the position orientation
2503  bool bConvDueToOrientation( false );
2504  {
2505  const sal_Int16 eVOri = _iorVertOri.GetVertOrient();
2506  bConvDueToOrientation = ( eVOri == text::VertOrientation::TOP ||
2507  eVOri == text::VertOrientation::BOTTOM ||
2508  eVOri == text::VertOrientation::CHAR_TOP ||
2509  eVOri == text::VertOrientation::CHAR_BOTTOM ||
2510  eVOri == text::VertOrientation::CHAR_CENTER ||
2511  eVOri == text::VertOrientation::LINE_TOP ||
2512  eVOri == text::VertOrientation::LINE_BOTTOM ||
2513  eVOri == text::VertOrientation::LINE_CENTER );
2514  }
2515 
2516  // determine conversion type due to the position relation
2517  if ( bConvDueToAnchoredAtColBreakPara )
2518  {
2519  eVertConv = sw::WW8AnchorConv::CONV2PG;
2520  }
2521  else
2522  {
2523  switch ( _iorVertOri.GetRelationOrient() )
2524  {
2525  case text::RelOrientation::PAGE_FRAME:
2526  case text::RelOrientation::PAGE_PRINT_AREA:
2527  {
2528  if ( bConvDueToOrientation || bFollowTextFlow )
2529  eVertConv = sw::WW8AnchorConv::CONV2PG;
2530  }
2531  break;
2532  case text::RelOrientation::FRAME:
2533  {
2534  if ( bConvDueToOrientation ||
2535  _iorVertOri.GetVertOrient() == text::VertOrientation::CENTER )
2536  {
2538  }
2539  }
2540  break;
2541  case text::RelOrientation::PRINT_AREA:
2542  {
2543  // relation not supported by WW8. Thus, conversion always needed.
2545  }
2546  break;
2547  case text::RelOrientation::CHAR:
2548  {
2549  // relation not supported by WW8. Thus, conversion always needed.
2551  }
2552  break;
2553  case text::RelOrientation::TEXT_LINE:
2554  {
2555  if ( bConvDueToOrientation ||
2556  _iorVertOri.GetVertOrient() == text::VertOrientation::NONE )
2557  {
2558  eVertConv = sw::WW8AnchorConv::CONV2LINE;
2559  }
2560  }
2561  break;
2562  case text::RelOrientation::PAGE_LEFT:
2563  case text::RelOrientation::PAGE_RIGHT:
2564  case text::RelOrientation::FRAME_LEFT:
2565  case text::RelOrientation::FRAME_RIGHT:
2566  default:
2567  OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown vertical relation" );
2568  }
2569  }
2570 
2571  }
2572  if (eVertConv != sw::WW8AnchorConv::NO_CONV || eHoriConv != sw::WW8AnchorConv::NO_CONV)
2573  {
2574  sw::WW8AnchorConvResult aResult(eHoriConv, eVertConv);
2575  _rFrameFormat.CallSwClientNotify(sw::WW8AnchorConvHint(aResult));
2576  if(!aResult.m_bConverted)
2577  return false;
2578  if (eHoriConv != sw::WW8AnchorConv::NO_CONV)
2579  {
2580  lcl_SetRelationOrient(_iorHoriOri, eHoriConv, [&_iorHoriOri]() {_iorHoriOri.SetHoriOrient(text::HoriOrientation::NONE);} );
2581  _iorHoriOri.SetPos(aResult.m_aPos.X());
2582  }
2583  if (eVertConv != sw::WW8AnchorConv::NO_CONV)
2584  {
2585  lcl_SetRelationOrient(_iorVertOri, eVertConv, [&_iorVertOri]() {_iorVertOri.SetVertOrient(text::VertOrientation::NONE);} );
2586  _iorVertOri.SetPos(aResult.m_aPos.Y());
2587  }
2588  return true;
2589  }
2590  return false;
2591 }
2592 
2594 {
2595  const RndStdIds eAnchor = rFormat.GetAnchor().GetAnchorId();
2596  mbInline = (eAnchor == RndStdIds::FLY_AS_CHAR);
2597 
2598  SwFormatHoriOrient rHoriOri = rFormat.GetHoriOrient();
2599  SwFormatVertOrient rVertOri = rFormat.GetVertOrient();
2600 
2601  // #i30669# - convert the positioning attributes.
2602  // Most positions are converted, if layout information exists.
2603  const bool bPosConverted = ConvertPosition( rHoriOri, rVertOri, rFormat );
2604 
2605  const sal_Int16 eHOri = rHoriOri.GetHoriOrient();
2606  const sal_Int16 eVOri = rVertOri.GetVertOrient(); // #i22673#
2607 
2608  const sal_Int16 eHRel = rHoriOri.GetRelationOrient();
2609  const sal_Int16 eVRel = rVertOri.GetRelationOrient();
2610 
2611  // horizontal Adjustment
2612  switch (eHOri)
2613  {
2614  default:
2616  mnXAlign = 0;
2617  break;
2618  case text::HoriOrientation::LEFT:
2619  mnXAlign = 1;
2620  break;
2621  case text::HoriOrientation::CENTER:
2622  mnXAlign = 2;
2623  break;
2624  case text::HoriOrientation::RIGHT:
2625  mnXAlign = 3;
2626  break;
2627  case text::HoriOrientation::INSIDE:
2628  mnXAlign = 4;
2629  break;
2630  case text::HoriOrientation::OUTSIDE:
2631  mnXAlign = 5;
2632  break;
2633  }
2634 
2635  // vertical Adjustment
2636  // #i22673#
2637  // When adjustment is vertically relative to line or to char
2638  // bottom becomes top and vice versa
2639  const bool bVertSwap = !bPosConverted &&
2640  ( (eVRel == text::RelOrientation::CHAR) ||
2641  (eVRel == text::RelOrientation::TEXT_LINE) );
2642  switch (eVOri)
2643  {
2644  default:
2646  mnYAlign = 0;
2647  break;
2648  case text::VertOrientation::TOP:
2649  case text::VertOrientation::LINE_TOP:
2650  case text::VertOrientation::CHAR_TOP:
2651  mnYAlign = bVertSwap ? 3 : 1;
2652  break;
2653  case text::VertOrientation::CENTER:
2654  case text::VertOrientation::LINE_CENTER:
2655  mnYAlign = 2;
2656  break;
2657  case text::VertOrientation::BOTTOM:
2658  case text::VertOrientation::LINE_BOTTOM:
2659  case text::VertOrientation::CHAR_BOTTOM:
2660  mnYAlign = bVertSwap ? 1 : 3;
2661  break;
2662  }
2663 
2664  // Adjustment is horizontally relative to...
2665  switch (eHRel)
2666  {
2667  case text::RelOrientation::PAGE_PRINT_AREA:
2668  mnXRelTo = 0;
2669  break;
2670  case text::RelOrientation::PAGE_FRAME:
2671  case text::RelOrientation::PAGE_LEFT: //:-(
2672  case text::RelOrientation::PAGE_RIGHT: //:-(
2673  mnXRelTo = 1;
2674  break;
2675  case text::RelOrientation::FRAME:
2676  case text::RelOrientation::FRAME_LEFT: //:-(
2677  case text::RelOrientation::FRAME_RIGHT: //:-(
2678  if (eAnchor == RndStdIds::FLY_AT_PAGE)
2679  mnXRelTo = 1;
2680  else
2681  mnXRelTo = 2;
2682  break;
2683  case text::RelOrientation::PRINT_AREA:
2684  if (eAnchor == RndStdIds::FLY_AT_PAGE)
2685  mnXRelTo = 0;
2686  else
2687  mnXRelTo = 2;
2688  break;
2689  case text::RelOrientation::CHAR:
2690  mnXRelTo = 3;
2691  break;
2692  case text::RelOrientation::TEXT_LINE:
2693  break;
2694  }
2695 
2696  // Adjustment is vertically relative to...
2697  switch (eVRel)
2698  {
2699  case text::RelOrientation::PAGE_PRINT_AREA:
2700  mnYRelTo = 0;
2701  break;
2702  case text::RelOrientation::PAGE_FRAME:
2703  mnYRelTo = 1;
2704  break;
2705  case text::RelOrientation::PRINT_AREA:
2706  if (eAnchor == RndStdIds::FLY_AT_PAGE)
2707  mnYRelTo = 0;
2708  else
2709  mnYRelTo = 2;
2710  break;
2711  case text::RelOrientation::FRAME:
2712  if (eAnchor == RndStdIds::FLY_AT_PAGE)
2713  mnYRelTo = 1;
2714  else
2715  mnYRelTo = 2;
2716  break;
2717  case text::RelOrientation::CHAR:
2718  case text::RelOrientation::TEXT_LINE: // #i22673# - vertical alignment at top of line
2719  case text::RelOrientation::PAGE_LEFT: //nonsense
2720  case text::RelOrientation::PAGE_RIGHT: //nonsense
2721  case text::RelOrientation::FRAME_LEFT: //nonsense
2722  case text::RelOrientation::FRAME_RIGHT: //nonsense
2723  mnYRelTo = 3;
2724  break;
2725  }
2726 }
2727 
2729 {
2732 
2734  GetStream().WriteInt32( 0 );
2735 
2737  GetStream().WriteInt32( 1 );
2738 }
2739 
2740 sal_Int32 SwEscherEx::WriteFlyFrame(const DrawObj &rObj, sal_uInt32 &rShapeId,
2741  DrawObjPointerVector &rPVec)
2742 {
2743  const SwFrameFormat &rFormat = rObj.maContent.GetFrameFormat();
2744 
2745  // check for textflyframe and if it is the first in a Chain
2746  sal_Int32 nBorderThick = 0;
2747  const SwNodeIndex* pNdIdx = rFormat.GetContent().GetContentIdx();
2748  if( pNdIdx )
2749  {
2750  SwNodeIndex aIdx( *pNdIdx, 1 );
2751  switch( aIdx.GetNode().GetNodeType() )
2752  {
2753  case SwNodeType::Grf:
2754  rShapeId = GenerateShapeId();
2755  nBorderThick = WriteGrfFlyFrame( rFormat, rShapeId );
2756  break;
2757  case SwNodeType::Ole:
2758  rShapeId = GenerateShapeId();
2759  nBorderThick = WriteOLEFlyFrame( rFormat, rShapeId );
2760  break;
2761  default:
2762  if (const SdrObject* pObj = rFormat.FindRealSdrObject())
2763  {
2764  // check for the first in a Chain
2765  sal_uInt32 nTextId;
2766  sal_uInt16 nOff = 0;
2767  const SwFrameFormat* pFormat = &rFormat, *pPrev;
2768  while( nullptr != ( pPrev = pFormat->GetChain().GetPrev() ))
2769  {
2770  ++nOff;
2771  pFormat = pPrev;
2772  }
2773 
2774  rShapeId = GetFlyShapeId(rFormat, rObj.mnHdFtIndex, rPVec);
2775  if( !nOff )
2776  {
2777  nTextId = pTextBxs->GetPos( pObj );
2778  if( USHRT_MAX == nTextId )
2779  {
2780  pTextBxs->Append( *pObj, rShapeId );
2781  nTextId = pTextBxs->Count();
2782  }
2783  else
2784  ++nTextId;
2785  }
2786  else
2787  {
2788  const SdrObject* pPrevObj = pFormat->FindRealSdrObject();
2789  nTextId = pTextBxs->GetPos( pPrevObj );
2790  if( USHRT_MAX == nTextId )
2791  {
2792  sal_uInt32 nPrevShapeId =
2793  GetFlyShapeId(*pFormat, rObj.mnHdFtIndex, rPVec);
2794  pTextBxs->Append( *pPrevObj, nPrevShapeId );
2795  nTextId = pTextBxs->Count();
2796  }
2797  else
2798  ++nTextId;
2799  }
2800  nTextId *= 0x10000;
2801  nTextId += nOff;
2802 
2803  nBorderThick = WriteTextFlyFrame(rObj, rShapeId, nTextId, rPVec);
2804  }
2805 
2806  //In browse mode the sdr object doesn't always exist. For example, the
2807  //object is in the hidden header/footer. We save the fmt directly
2808  //in such cases; we copy most of the logic from the block above
2809  const bool bBrowseMode = rFormat.getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE);
2810  if( bBrowseMode && rFormat.GetDoc())
2811  {
2812  if( !rFormat.GetChain().GetPrev() )//obj in header/footer?
2813  {
2814  rShapeId = GetFlyShapeId(rFormat, rObj.mnHdFtIndex, rPVec);
2815  pTextBxs->Append( &rFormat, rShapeId );
2816  sal_uInt32 nTextId = pTextBxs->Count();
2817 
2818  nTextId *= 0x10000;
2819  nBorderThick = WriteTextFlyFrame(rObj, rShapeId, nTextId, rPVec);
2820  }
2821  }
2822 
2823  }
2824  }
2825  return nBorderThick;
2826 }
2827 
2828 static sal_uInt16 FindPos(const SwFrameFormat &rFormat, unsigned int nHdFtIndex,
2829  DrawObjPointerVector &rPVec)
2830 {
2831  auto aIter = std::find_if(rPVec.begin(), rPVec.end(),
2832  [&rFormat, nHdFtIndex](const DrawObj* pObj) {
2833  OSL_ENSURE(pObj, "Impossible");
2834  return pObj &&
2835  nHdFtIndex == pObj->mnHdFtIndex &&
2836  &rFormat == (&pObj->maContent.GetFrameFormat());
2837  });
2838  if (aIter != rPVec.end())
2839  return static_cast< sal_uInt16 >(aIter - rPVec.begin());
2840  return USHRT_MAX;
2841 }
2842 
2843 sal_Int32 SwEscherEx::WriteTextFlyFrame(const DrawObj &rObj, sal_uInt32 nShapeId,
2844  sal_uInt32 nTextBox, DrawObjPointerVector &rPVec)
2845 {
2846  const SwFrameFormat &rFormat = rObj.maContent.GetFrameFormat();
2847  SvxFrameDirection nDirection = rObj.mnDirection;
2848 
2849  sal_Int32 nBorderThick=0;
2851 
2852  AddShape( ESCHER_ShpInst_TextBox, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, nShapeId );
2853  EscherPropertyContainer aPropOpt;
2854  aPropOpt.AddOpt(ESCHER_Prop_lTxid, nTextBox);
2855  if (const SwFrameFormat *pNext = rFormat.GetChain().GetNext())
2856  {
2857  sal_uInt16 nPos = FindPos(*pNext, rObj.mnHdFtIndex, rPVec);
2858  if (USHRT_MAX != nPos && aFollowShpIds[nPos])
2859  aPropOpt.AddOpt(ESCHER_Prop_hspNext, aFollowShpIds[nPos]);
2860  }
2861  nBorderThick = WriteFlyFrameAttr( rFormat, mso_sptTextBox, aPropOpt );
2862 
2863  MSO_TextFlow nFlow;
2864 
2865  switch (nDirection)
2866  {
2867  default:
2868  OSL_ENSURE(false, "unknown direction type");
2869  [[fallthrough]];
2870  case SvxFrameDirection::Horizontal_LR_TB:
2871  nFlow=mso_txflHorzN;
2872  break;
2873  case SvxFrameDirection::Horizontal_RL_TB:
2874  nFlow=mso_txflHorzN;
2875  break;
2876  case SvxFrameDirection::Vertical_LR_TB: //not really possible in word
2877  case SvxFrameDirection::Vertical_RL_TB:
2878  nFlow=mso_txflTtoBA;
2879  break;
2880  case SvxFrameDirection::Vertical_LR_BT:
2881  nFlow = mso_txflBtoT;
2882  break;
2883  }
2884  aPropOpt.AddOpt( ESCHER_Prop_txflTextFlow, nFlow );
2885 
2886  aPropOpt.Commit( GetStream() );
2887 
2888  // store anchor attribute
2889  WriteFrameExtraData( rFormat );
2890 
2891  AddAtom( 4, ESCHER_ClientTextbox ); GetStream().WriteUInt32( nTextBox );
2892 
2893  CloseContainer(); // ESCHER_SpContainer
2894  return nBorderThick;
2895 }
2896 
2898  ShapeFlag nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj,
2899  sal_uInt32 nShapeId, const awt::Rectangle* pVisArea )
2900 {
2901  //nShapeFlags == 0xA00 + flips and ole active
2902  AddShape(ESCHER_ShpInst_PictureFrame, nShapeFlags, nShapeId);
2903 
2904  GraphicObject aGraphicObject(rGraphic);
2905  OString aId = aGraphicObject.GetUniqueID();
2906  if (!aId.isEmpty())
2907  {
2908  // SJ: the third parameter (pVisArea) should be set...
2909  sal_uInt32 nBlibId = mxGlobal->GetBlibID( *QueryPictureStream(), aGraphicObject, pVisArea);
2910  if (nBlibId)
2911  rPropOpt.AddOpt(ESCHER_Prop_pib, nBlibId, true);
2912  }
2913 
2914  SetPicId(rObj, nShapeId, rPropOpt);
2915  rPropOpt.AddOpt( ESCHER_Prop_pictureActive, 0x10000 );
2916 }
2917 
2918 void SwEscherEx::WriteOCXControl( const SwFrameFormat& rFormat, sal_uInt32 nShapeId )
2919 {
2920  const SdrObject* pSdrObj = rFormat.FindRealSdrObject();
2921  if (!pSdrObj)
2922  return;
2923 
2925 
2928  OSL_ENSURE(pModel && pDevice, "no model or device");
2929 
2930  // #i71538# use complete SdrViews
2931  // SdrExchangeView aExchange(pModel, pDevice);
2932  SdrView aExchange(*pModel, pDevice);
2933  const Graphic aGraphic(SdrExchangeView::GetObjGraphic(*pSdrObj));
2934  EscherPropertyContainer aPropOpt;
2935  WriteOLEPicture(aPropOpt,
2936  ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::OLEShape, aGraphic,
2937  *pSdrObj, nShapeId, nullptr );
2938 
2939  WriteFlyFrameAttr( rFormat, mso_sptPictureFrame , aPropOpt );
2940  aPropOpt.Commit( GetStream() );
2941 
2942  // store anchor attribute
2943  WriteFrameExtraData( rFormat );
2944 
2945  CloseContainer(); // ESCHER_SpContainer
2946 
2947 }
2948 
2950  std::vector<DrawObj>& rSrcArr, DrawObjPointerVector&rDstArr)
2951 {
2952  ::lcl_makeZOrderArray(rWrt, rSrcArr, rDstArr);
2953 
2954  //Now set up the follow IDs
2955  aFollowShpIds.clear();
2956 
2957  for (DrawObj* p : rDstArr)
2958  {
2959  const SwFrameFormat &rFormat = p->maContent.GetFrameFormat();
2960  bool bNeedsShapeId = false;
2961 
2962  if (RES_FLYFRMFMT == rFormat.Which())
2963  {
2964  const SwFormatChain &rChain = rFormat.GetChain();
2965  if (rChain.GetPrev() || rChain.GetNext())
2966  bNeedsShapeId = true;
2967  }
2968 
2969  sal_uLong nShapeId = bNeedsShapeId ? GenerateShapeId() : 0;
2970 
2971  aFollowShpIds.push_back(nShapeId);
2972  }
2973 }
2974 
2975 sal_uInt32 SwEscherEx::GetFlyShapeId(const SwFrameFormat& rFormat,
2976  unsigned int nHdFtIndex, DrawObjPointerVector &rpVec)
2977 {
2978  sal_uInt16 nPos = FindPos(rFormat, nHdFtIndex, rpVec);
2979  sal_uInt32 nShapeId;
2980  if (USHRT_MAX != nPos)
2981  {
2982  nShapeId = aFollowShpIds[nPos];
2983  if (0 == nShapeId)
2984  {
2985  nShapeId = GenerateShapeId();
2986  aFollowShpIds[ nPos ] = nShapeId;
2987  }
2988  }
2989  else
2990  nShapeId = GenerateShapeId();
2991  return nShapeId;
2992 }
2993 
2995  const uno::Reference< drawing::XShape>& xXShapeRef, sal_uInt32 nShapeId )
2996 {
2997  sal_uInt32 nId = 0;
2998  if (SdrObject* pObj = SdrObject::getSdrObjectFromXShape(xXShapeRef))
2999  {
3000  pTextBxs->Append( *pObj, nShapeId );
3001  nId = pTextBxs->Count();
3002  nId *= 0x10000;
3003  }
3004  return nId;
3005 }
3006 
3008 ::ole::MSConvertOCXControls( pDSh ? pDSh->GetModel() : nullptr ), pPaM( pP ), mnObjectId(0)
3009 {
3010 }
3011 
3012 
3013 // in transitioning away old filter for ole/ocx controls, ReadOCXStream has been made pure virtual in
3014 // filter/source/msocximex.cxx, so... we need an implementation here
3016  css::uno::Reference< css::drawing::XShape > *pShapeRef,
3017  bool bFloatingCtrl )
3018 {
3019  uno::Reference< form::XFormComponent > xFComp;
3020  bool bRes = oox::ole::MSConvertOCXControls::ReadOCXStorage( rSrc1, xFComp );
3021  if ( bRes && xFComp.is() )
3022  {
3023  css::awt::Size aSz; // not used in import
3024  bRes = InsertControl( xFComp, aSz,pShapeRef,bFloatingCtrl);
3025  }
3026  return bRes;
3027 }
3028 
3030 {
3031  const uno::Reference< awt::XControlModel >& xControlModel =
3032  rFormObj.GetUnoControlModel();
3033 
3034  //Why oh lord do we use so many different units ?
3035  //I think I painted myself into a little bit of a
3036  //corner by trying to use the uno interface for
3037  //controls export
3038  tools::Rectangle aRect = rFormObj.GetLogicRect();
3039  aRect.SetPos(Point(0,0));
3040  awt::Size aSize;
3041  aSize.Width = convertTwipToMm100(aRect.Right());
3042  aSize.Height = convertTwipToMm100(aRect.Bottom());
3043 
3044  //Open the ObjectPool
3046 
3047  //Create a destination storage for the microsoft control
3048  sal_uInt32 nObjId = ++mnObjectId;
3049  OUString sStorageName = "_" + OUString::number( static_cast<sal_Int64>( nObjId ));
3050  tools::SvRef<SotStorage> xOleStg = xObjPool->OpenSotStorage(sStorageName);
3051 
3052  if (!xOleStg.is())
3053  return;
3054 
3055  OUString sUName;
3056  if (!WriteOCXStream( mxModel, xOleStg,xControlModel,aSize,sUName))
3057  return;
3058 
3059  sal_uInt8 aSpecOLE[] =
3060  {
3061  0x03, 0x6a, 0xFF, 0xFF, 0xFF, 0xFF, // sprmCPicLocation
3062  0x0a, 0x08, 1, // sprmCFOLE2
3063  0x55, 0x08, 1, // sprmCFSpec
3064  0x56, 0x08, 1 // sprmCFObj
3065  };
3066  //Set the obj id into the sprmCPicLocation
3067  sal_uInt8 *pData = aSpecOLE+2;
3068  Set_UInt32(pData,nObjId );
3069 
3070  OUString sField = FieldString(ww::eCONTROL) + "Forms." + sUName + ".1 \\s ";
3071 
3072  rWW8Wrt.OutputField(nullptr, ww::eCONTROL, sField,
3074 
3075  rWW8Wrt.m_pChpPlc->AppendFkpEntry(rWW8Wrt.Strm().Tell(),sizeof(aSpecOLE),
3076  aSpecOLE);
3077  rWW8Wrt.WriteChar( 0x1 );
3078  rWW8Wrt.OutputField(nullptr, ww::eCONTROL, OUString(), FieldFlags::End | FieldFlags::Close);
3079 }
3080 
3081 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
mso_lineSolid
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
sal_uInt16 Count() const
bool GetValue() const
sal_Int32 nCurrentSwPos
Definition: wrtww8.hxx:1461
bool is() const
#define ESCHER_DgContainer
virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart, sal_uInt32 nLen) const override
Definition: wrtw8esh.cxx:855
void SetPos(const Point &rPoint)
bool IsContour() const
Definition: fmtsrnd.hxx:53
SvStream * pEscherStrm
Definition: escher.hxx:98
eFORMDROPDOWN
Exporter of the binary Word file formats.
Definition: wrtww8.hxx:988
sal_uInt32 mnObjectId
Definition: ww8par.hxx:747
void OutAttr(sal_Int32 nSwPos)
Definition: wrtw8esh.cxx:1118
virtual AttributeOutputBase & AttrOutput() const =0
Access to the attribute output class.
constexpr TypedWhichId< SfxInt16Item > RES_CHRATR_BIDIRTL(44)
sal_Int32 WhereNext() const
Definition: wrtww8.hxx:1488
const sw::BroadcastingModify * m_pOutFormatNode
Definition: wrtww8.hxx:537
SwNoTextNode * GetNoTextNodeFromSwFrameFormat(const SwFrameFormat &rFormat)
Get the SwNoTextNode associated with a SwFrameFormat if here is one.
sal_Int64 GetAspect() const
Definition: ndole.hxx:136
WW8AnchorConv
Definition: frmfmt.hxx:298
static ShapeFlag AddMirrorFlags(ShapeFlag nFlags, const SwMirrorGrf &rMirror)
Definition: wrtw8esh.cxx:1543
std::unique_ptr< ww::bytes > pO
Buffer.
Definition: wrtww8.hxx:991
SvStream * pTableStrm
Definition: wrtww8.hxx:993
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
unsigned int GetHdFtIndex() const
Definition: wrtww8.hxx:1132
sal_uInt8 GetAlpha() const
void OutSwString(const OUString &, sal_Int32 nStt, sal_Int32 nLen)
Definition: wrtww8.cxx:1833
bool RTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth, sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft, SwTwips nPageRight, SwTwips nPageSize)
Definition: wrtw8esh.cxx:531
sal_Int32 GetLeft() const
void OutEEField(const SfxPoolItem &rHt)
Definition: wrtw8esh.cxx:1100
std::unique_ptr< WW8_WrPlcField > m_pFieldHFTextBxs
Definition: wrtww8.hxx:530
std::unique_ptr< WW8Fib > pFib
File Information Block.
Definition: wrtww8.hxx:995
virtual AttributeOutputBase & AttrOutput() const override
memory leak #i120098#, to hold the reference to unnamed SotStorage obj
Definition: wrtww8.cxx:3935
sal_uInt32 GetSdrOrdNum(const SwFrameFormat &rFormat) const
Definition: wrtw8esh.cxx:951
#define ESCHER_Prop_dyWrapDistBottom
constexpr sal_uInt16 EE_FEATURE_TAB(EE_FEATURE_START+0)
mso_lineDouble
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
void WriteStringAsPara(const OUString &rText)
Definition: wrtww8.cxx:1777
#define ESCHER_Prop_pictureId
rtl_TextEncoding GetNodeCharSet() const
Definition: wrtww8.hxx:1490
#define ESCHER_Prop_pictureActive
#define ESCHER_Prop_dyTextTop
SvStream & WriteInt32(sal_Int32 nInt32)
#define ESCHER_Prop_cropFromBottom
std::vector< sal_uLong > aFollowShpIds
Definition: escher.hxx:143
WW8_WrPlcTextBoxes * pTextBxs
Definition: escher.hxx:146
std::unique_ptr< ContentProperties > pData
std::string GetValue
tools::Long getWidth() const
OBJ_GRUP
const SfxItemPool * pEditPool
Definition: wrtww8.hxx:1456
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
constexpr tools::Long Left() const
void OutParaAttr(bool bCharAttr, const std::set< sal_uInt16 > *pWhichsToIgnore=nullptr)
Definition: wrtw8esh.cxx:1275
const_iterator find(const value_type &x) const
Definition: docfmt.cxx:2081
#define ESCHER_Prop_pictureBrightness
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
SwNodeIndex nNode
Definition: pam.hxx:37
std::shared_ptr< SvStream > mxPicStrm
Definition: escher.hxx:89
GPOS_NONE
const_iterator begin() const
#define ESCHER_Prop_lineWidth
void WriteOCXControl(const SwFrameFormat &rFormat, sal_uInt32 nShapeId)
Definition: wrtw8esh.cxx:2918
SvxBreak GetBreak() const
static sal_uInt16 FindPos(const SwFrameFormat &rFormat, unsigned int nHdFtIndex, DrawObjPointerVector &rPVec)
Definition: wrtw8esh.cxx:2828
void SetShapeDetails(sal_uInt32 nId, sal_Int32 nThick)
Definition: wrtw8esh.cxx:905
std::vector< sal_uInt8 > bytes
Definition: types.hxx:29
virtual Size GetTwipSize() const =0
SwTwips GetPos() const
Definition: fmtornt.hxx:92
sal_uIntPtr sal_uLong
long Long
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
SwRect FindLayoutRect(const bool bPrtArea=false, const Point *pPoint=nullptr) const
Definition: atrfrm.cxx:2720
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
OBJ_LINE
void SetCharSet(const EECharAttrib &rTextAttr, bool bStart)
Definition: wrtw8esh.cxx:1074
void Commit(SvStream &rSt, sal_uInt16 nVersion=3, sal_uInt16 nRecType=ESCHER_OPT)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
#define ESCHER_Prop_pib
bool MiserableFormFieldExportHack(const SwFrameFormat &rFrameFormat)
Definition: wrtw8esh.cxx:354
sal_Int64 n
static sal_Int32 GetEscherLineMatch(MSO_LineStyle eStyle, MSO_SPT eShapeType, sal_Int32 &rThick)
Definition: ww8graf.cxx:1532
constexpr sal_uInt16 RES_FRMATR_END(133)
sal_uInt32 AddSdrObject(const SdrObject &rObj, bool ooxmlExport=false)
size_t GetObjCount() const
sal_Int32 nPara
Definition: wrtww8.hxx:1460
const GraphicObject * GetGraphicObject(OUString const &referer=OUString()) const
const EditTextObject * pEditObj
Definition: wrtww8.hxx:1455
virtual ~PlcDrawObj()
Definition: wrtw8esh.cxx:523
aBuf
#define ESCHER_ClientAnchor
#define ESCHER_Prop_lineStyle
virtual sal_Int32 WriteFlyFrameAttr(const SwFrameFormat &rFormat, MSO_SPT eShapeType, EscherPropertyContainer &rPropOpt) override
Definition: wrtw8esh.cxx:2071
#define ESCHER_Prop_cropFromLeft
const SfxPoolItem * pAttr
sal_Int16 nId
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
virtual bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich)=0
Guess the script (asian/western).
sal_uInt16 FirstWhich()
bool IsLinkedFile() const
Definition: ndgrf.hxx:164
css::uno::Reference< css::frame::XModel2 > mxModel
sal_uInt64 Seek(sal_uInt64 nPos)
virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const override
Definition: wrtw8esh.cxx:874
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
SwNode & GetNode() const
Definition: ndindex.hxx:119
static void WriteString8(SvStream &rStrm, std::u16string_view rStr, bool bAddZero, rtl_TextEncoding eCodeSet)
Definition: wrtww8.cxx:1764
#define ESCHER_Prop_txflTextFlow
void setResult(sal_uInt8 nResult)
Definition: WW8FFData.hxx:72
SvxFrameDirection
static OUString GetRelURL(OUString const &rTheBaseURIRef, OUString const &rTheAbsURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
SvxFrameDirection GetTextDirection(const SwPosition &rPos, const Point *pPt=nullptr) const
Definition: doclay.cxx:1611
sal_Int32 WriteOLEFlyFrame(const SwFrameFormat &rFormat, sal_uInt32 nShapeId)
Definition: wrtw8esh.cxx:1782
void addListboxEntry(const OUString &rEntry)
Definition: WW8FFData.cxx:63
constexpr TypedWhichId< SwContrastGrf > RES_GRFATR_CONTRAST(137)
void SetAnchoring(const SwFrameFormat &rFormat)
Definition: wrtw8esh.cxx:2593
WW8_CP Fc2Cp(sal_uLong nFc) const
Definition: wrtww8.hxx:1100
virtual void AddShape(sal_uInt32 nShpInstance, ShapeFlag nFlagIds, sal_uInt32 nShapeID=0)
eCONTROL
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
std::unique_ptr< WW8_WrPlcField > m_pFieldTextBxs
Definition: wrtww8.hxx:529
void Set_UInt32(sal_uInt8 *&p, sal_uInt32 n)
Definition: ww8struc.hxx:53
std::shared_ptr< T > make_shared(Args &&...args)
void AppendFlyInFlys(const ww8::Frame &rFrameFormat, const Point &rNdTopLeft)
Definition: wrtw8esh.cxx:971
DrawObjVector & GetObjArr()
Definition: wrtww8.hxx:376
virtual SdrObjKind GetObjIdentifier() const
virtual SvxBrushItem * Clone(SfxItemPool *pPool=nullptr) const override
Used to export formatted text associated to drawings.
Definition: wrtww8.hxx:1452
const sal_uInt32 nInlineHack
Definition: escher.hxx:27
bool IsTextEditActive() const
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:55
virtual void WriteFrameExtraData(const SwFrameFormat &rFormat) override
Definition: wrtw8esh.cxx:2728
EmbeddedObjectRef * pObject
std::shared_ptr< EscherExGlobal > mxGlobal
const SfxItemSet * GetCurItemSet() const
Getter for pISet.
Definition: wrtww8.hxx:729
#define ESCHER_ClientTextbox
css::chart::ChartAxisLabelPosition ePos
OUString FieldString(ww::eField eIndex)
Definition: ww8atr.cxx:2685
std::shared_ptr< SvxBrushItem > TrueFrameBgBrush(const SwFrameFormat &rFlyFormat) const
Definition: wrtw8nds.cxx:1707
bool ReadOCXStorage(tools::SvRef< SotStorage > const &rSrc1, css::uno::Reference< css::form::XFormComponent > &rxFormComp)
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:744
static bool WriteOCXStream(const css::uno::Reference< css::frame::XModel > &rxModel, tools::SvRef< SotStorage > const &rSrc1, const css::uno::Reference< css::awt::XControlModel > &rControlModel, const css::awt::Size &rSize, OUString &rName)
constexpr TypedWhichId< SwLuminanceGrf > RES_GRFATR_LUMINANCE(136)
const OUString & GetHelp() const
Definition: expfld.cxx:1409
constexpr TypedWhichId< SvxFrameDirectionItem > EE_PARA_WRITINGDIR(EE_PARA_START+0)
virtual WW8_CP GetCpOffset(const WW8Fib &) const override
Definition: wrtw8esh.cxx:862
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
sal_uInt16 NextWhich()
virtual void SetPicId(const SdrObject &rSdrObj, sal_uInt32 nShapeId, EscherPropertyContainer &rPropOpt) override
Definition: wrtw8esh.cxx:1773
virtual void SetPicId(const SdrObject &, sal_uInt32, EscherPropertyContainer &)
Definition: wrtw8esh.cxx:1768
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
virtual sal_uInt32 GenerateShapeId()
std::unique_ptr< HdFtPlcDrawObj > m_pHFSdrObjs
Definition: wrtww8.hxx:541
virtual const tools::Rectangle & GetSnapRect() const
constexpr auto convertTwipToMm100(N n)
static OutputDevice * GetDefaultDevice()
static bool ConvertPosition(SwFormatHoriOrient &_iorHoriOri, SwFormatVertOrient &_iorVertOri, const SwFrameFormat &_rFrameFormat)
method to perform conversion of positioning attributes with the help of corresponding layout informat...
Definition: wrtw8esh.cxx:2397
tools::Long getHeight() const
mso_lineThickThin
mso_sptPictureFrame
SwDoc & m_rDoc
Definition: docbm.cxx:1204
#define ESCHER_Prop_dxWrapDistLeft
SvStream & GetStream() const
SwEscherEx * m_pEscher
Definition: wrtww8.hxx:543
virtual sal_uInt32 QueryTextID(const css::uno::Reference< css::drawing::XShape > &, sal_uInt32) override
Definition: wrtw8esh.cxx:2994
const SfxPoolItem * NextItem()
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:742
SvxGraphicPosition GetGraphicPos() const
void WritePlc(WW8Export &rWrt) const
Definition: wrtw8esh.cxx:618
#define ESCHER_Prop_wzName
virtual sal_Int32 WriteFlyFrameAttr(const SwFrameFormat &rFormat, MSO_SPT eShapeType, EscherPropertyContainer &rPropOpt)
Definition: wrtw8esh.cxx:1884
MSO_LineDashing
SvxShadowLocation GetLocation() const
SotStorage * OpenSotStorage(const OUString &rEleName, StreamMode=StreamMode::STD_READWRITE, bool transacted=true)
virtual void OutputField(const SwField *pField, ww::eField eFieldType, const OUString &rFieldCmd, FieldFlags nMode=FieldFlags::All) override
Write the field.
Definition: ww8atr.cxx:1811
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:89
SwNodeType GetNodeType() const
Definition: node.hxx:145
MSWordExportBase & m_rExport
Definition: wrtww8.hxx:1442
MSO_SPT
void Flush(SvStream *pPicStreamMergeBSE=nullptr)
static Graphic GetObjGraphic(const SdrObject &rSdrObject)
OString GetUniqueID() const
#define INET_FILE_SCHEME
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:426
void WriteHyperlinkWithinFly(SvMemoryStream &rStrm, const SwFormatURL *pINetFormatArg)
Definition: wrtw8esh.cxx:169
SwBasicEscherEx(SvStream *pStrm, WW8Export &rWrt)
Definition: wrtw8esh.cxx:1514
SwMSConvertControls(SfxObjectShell const *pDSh, SwPaM *pP)
Definition: wrtw8esh.cxx:3007
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:33
#define DFF_msofbtUDefProp
const SvxBrushItem * GetCurrentPageBgBrush() const
Definition: wrtw8nds.cxx:1688
sal_Int32 SearchNext(sal_Int32 nStartPos)
Definition: wrtw8esh.cxx:1052
bool m_bInWriteEscher
Definition: wrtww8.hxx:558
void SetClientData(EscherExClientRecord_Base *p)
void Width(tools::Long nNew)
Definition: swrect.hxx:189
bool Append(WW8Export const &, WW8_CP nCp, const ww8::Frame &rFormat, const Point &rNdTopLeft)
Definition: wrtw8esh.cxx:879
sal_uInt32 RGBToBGR(::Color nColour)
Definition: ww8struc.hxx:1088
SvStream & WriteUInt32(sal_uInt32 nUInt32)
sal_uInt32 mnXAlign
Definition: escher.hxx:71
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
Degree100 NormAngle36000(Degree100 deg100)
const Graphic * GetGraphic(OUString const &referer=OUString()) const
mso_txflHorzN
virtual const SfxItemSet & GetParaAttribs(sal_Int32 nPara) const =0
virtual void RawText(const OUString &rText, rtl_TextEncoding eCharSet)=0
Output text (without markup).
void WriteChar(sal_Unicode c) override
Definition: wrtww8.cxx:1870
INetProtocol
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Definition: ndgrf.cxx:492
sal_uInt64 remainingSize()
void WriteBrushAttr(const SvxBrushItem &rBrush, EscherPropertyContainer &rPropOpt)
Definition: wrtw8esh.cxx:1841
SdrLayerID GetInvisibleHellId() const
Definition: wrtw8esh.cxx:2176
static sal_Int32 ToFract16(sal_Int32 nVal, sal_uInt32 nMax)
Definition: wrtw8esh.cxx:2155
#define ESCHER_Prop_fillOpacity
void OutputItem(const SfxPoolItem &rHt)
Call the right virtual function according to the type of the item.
Definition: ww8atr.cxx:5359
OUString BuildFileName(sal_uInt16 &rnLevel, bool &rbRel, const OUString &rUrl)
Definition: wrtw8esh.cxx:134
void WriteGrfBullet(const Graphic &)
Definition: wrtw8esh.cxx:1564
OUString GetBasePath() const
Definition: wrtw8esh.cxx:116
const char * sName
sal_uInt32 AddDummyShape()
SvStream * QueryPictureStream()
sal_Int32 m_lcbPlcfspaMom
Definition: ww8scan.hxx:1388
const OUString & GetName() const
Definition: fmturl.hxx:71
const SwFrameFormat & GetFrameFormat() const
Get the writer SwFrameFormat that this object describes.
#define ESCHER_Prop_dyTextBottom
#define ESCHER_Prop_cropFromTop
SvxFrameDirection mnDirection
Definition: wrtww8.hxx:348
int size()
Definition: wrtww8.hxx:375
GraphicDrawMode
virtual SdrLayerID GetInvisibleHellId() const =0
#define ESCHER_Prop_fNoLineDrawDash
void ExportControl(WW8Export &rWrt, const SdrUnoObj &rFormObj)
Definition: wrtw8esh.cxx:3029
static void WriteString16(SvStream &rStrm, const OUString &rStr, bool bAddZero)
Definition: wrtww8.cxx:1741
#define ESCHER_Prop_lineDashing
const Color & GetColor() const
#define DFF_Prop_shadowOffsetX
Fraction conversionFract(o3tl::Length from, o3tl::Length to)
sal_Int32 nTmpSwPos
Definition: wrtww8.hxx:1462
ShapeFlag
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const Color & GetColor() const
#define ESCHER_Prop_lineBackColor
#define ESCHER_ShpInst_TextBox
std::unique_ptr< WW8_WrPlcPn > m_pPapPlc
Definition: wrtww8.hxx:498
const SwFormatFollowTextFlow & GetFollowTextFlow(bool=true) const
const EditTextObject & GetTextObject() const
tools::Polygon CorrectWordWrapPolygonForExport(const tools::PolyPolygon &rPolyPoly, const SwNoTextNode *pNd, bool bCorrectCrop)
Undo all scaling / move tricks of the wrap polygon done during import.
Style of a layout element.
Definition: frmfmt.hxx:59
void setName(const OUString &rName)
Definition: WW8FFData.hxx:74
#define ESCHER_Prop_pictureContrast
#define SAL_MAX_INT32
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetCurItemSet(const SfxItemSet *pS)
Setter for pISet.
Definition: wrtww8.hxx:732
EscherExHostAppData aHostData
Definition: escher.hxx:144
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
#define DFF_Prop_shadowOffsetY
ESCHER_BlipFlagDoNotSave
WW8_CP m_ccpHdrTxbx
Definition: ww8scan.hxx:1216
void SetVertOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:56
virtual const SfxPoolItem * HasTextItem(sal_uInt16 nWhich) const override
Definition: wrtw8esh.cxx:1214
mso_lineDashGEL
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:881
#define STREAM_SEEK_TO_BEGIN
#define ESCHER_Prop_dxWrapDistRight
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void WritePictures() override
Definition: wrtw8esh.cxx:1482
sal_uInt32 mnXRelTo
Definition: escher.hxx:73
std::unique_ptr< WW8_WrPlcTextBoxes > m_pHFTextBxs
Definition: wrtww8.hxx:504
constexpr TypedWhichId< SwFormatURL > RES_URL(111)
ESCHER_BlipFlagLinkToFile
bool IsRelUrl() const
Definition: wrtw8esh.cxx:105
OUString aId
constexpr TypedWhichId< SwCropGrf > RES_GRFATR_CROPGRF(134)
void SetSize(const Size &rSize)
sal_uInt16 GetPos(const void *p) const
Definition: wrtww8.hxx:1302
std::vector< rtl_TextEncoding > aChrSetArr
Definition: wrtww8.hxx:1459
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:60
virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart, sal_uInt32 nLen) const override
Definition: wrtw8esh.cxx:867
#define DFF_Prop_shadowColor
const OUString & GetValue() const
virtual OUString GetText(sal_Int32 nPara) const =0
static void WriteShort(SvStream &rStrm, sal_Int16 nVal)
Definition: wrtww8.hxx:961
const Fraction & X() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
void FinishEscher()
Definition: wrtw8esh.cxx:2335
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
rtl_TextEncoding eNdChrSet
Definition: wrtww8.hxx:1463
constexpr tools::Long Right() const
std::size_t WriteBytes(const void *pData, std::size_t nSize)
sal_Int32 DrawModelToEmu(sal_Int32 nVal) const
Definition: escher.hxx:110
SvxGraphicPosition
virtual bool InsertControl(const css::uno::Reference< css::form::XFormComponent > &rFComp, const css::awt::Size &rSize, css::uno::Reference< css::drawing::XShape > *pShape, bool bFloatingCtrl) override
Definition: ww8par3.cxx:2535
void MiserableRTLFrameFormatHack(SwTwips &rLeft, SwTwips &rRight, const ww8::Frame &rFrameFormat)
Nasty swap for bidi if necessary.
Definition: wrtw8esh.cxx:583
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
void WriteData(EscherEx &rEx) const override
Definition: wrtw8esh.cxx:1425
void DoComboBox(css::uno::Reference< css::beans::XPropertySet > const &xPropSet)
sal_uInt32 GetOrdNum() const
tools::Long mnEmuMul
Definition: escher.hxx:99
mso_txflBtoT
SwDoc & m_rDoc
Definition: wrtww8.hxx:574
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
constexpr tools::Long Top() const
mso_lineThinThick
SfxItemSet * GetItemSet() const
virtual void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner=ww8::WW8TableNodeInfoInner::Pointer_t()) override
Definition: wrtww8.cxx:1860
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:388
void setType(sal_uInt8 nType)
Definition: WW8FFData.hxx:70
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:31
#define DFF_Prop_pWrapPolygonVertices
sal_uInt16 GetSize() const
ESCHER_FillPicture
Marks a node in the document model.
Definition: ndindex.hxx:31
sal_uInt32 GetFlyShapeId(const SwFrameFormat &rFormat, unsigned int nHdFtIndex, DrawObjPointerVector &rPVec)
Definition: wrtw8esh.cxx:2975
SwWW8Writer & GetWriter() const
Definition: wrtww8.hxx:1180
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
sal_Int32 WriteFlyFrame(const DrawObj &rObj, sal_uInt32 &rShapeId, DrawObjPointerVector &rPVec)
Definition: wrtw8esh.cxx:2740
bool WriteText(WW8Export &rWrt)
Definition: wrtw8esh.cxx:911
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:717
WW8_CP m_ccpTxbx
Definition: ww8scan.hxx:1215
void Write(SvStream *pDataStrm)
Definition: WW8FFData.cxx:77
#define ESCHER_Prop_dyWrapDistTop
GPOS_AREA
SvStream & WriteStream(SvStream &rStream)
void EndSdrObjectPage()
sal_uInt16 TransformWhichBetweenPools(const SfxItemPool &rDestPool, const SfxItemPool &rSrcPool, sal_uInt16 nWhich)
Map an ID valid in one SfxItemPool to its equivalent in another.
#define ESCHER_Prop_cropFromRight
std::unique_ptr< MainTextPlcDrawObj > m_pSdrObjs
Definition: wrtww8.hxx:540
ESCHER_BlipFlagDefault
sal_Int32 nLineWidth
tools::Long SwTwips
Definition: swtypes.hxx:52
sal_Int32 m_lcbPlcfspaHdr
Definition: ww8scan.hxx:1393
tools::Long mnEmuDiv
Definition: escher.hxx:99
#define ESCHER_Prop_pibName
#define Y
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
#define ESCHER_Prop_fillBlip
virtual SdrInventor GetObjInventor() const
#define ESCHER_Prop_shadowColor
sal_uInt32 GetGroupLevel() const
sal_Int32 WW8_CP
Definition: ww8struc.hxx:153
void setStatus(const OUString &rStatus)
Definition: WW8FFData.cxx:57
constexpr Point TopLeft() const
virtual SdrLayerID GetHellId() const =0
#define ESCHER_Prop_fillBackColor
#define ESCHER_Prop_hspNext
virtual SdrLayerID GetLayer() const
void setHelp(const OUString &rHelp)
Definition: WW8FFData.cxx:51
sal_uInt32 mnYAlign
Definition: escher.hxx:72
eFORMTEXT
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
virtual ~SwEscherEx() override
Definition: wrtw8esh.cxx:2331
constexpr tools::Long Bottom() const
std::size_t ReadBytes(void *pData, std::size_t nSize)
#define ESCHER_Prop_dxTextLeft
constexpr sal_uInt16 RES_UNKNOWNATR_BEGIN(RES_BOXATR_END)
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
Definition: breakit.hxx:62
sal_Int32 GetBottom() const
#define ESCHER_Prop_fillColor
const SwMirrorGrf & GetMirrorGrf(bool=true) const
Definition: grfatr.hxx:282
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
WW8_CP m_ccpEdn
Definition: ww8scan.hxx:1214
WW8_FC m_fcPlcfspaHdr
Definition: ww8scan.hxx:1390
#define ESCHER_DggContainer
virtual const std::vector< sal_uInt32 > * GetShapeIdArr() const override
Definition: wrtw8esh.cxx:946
sal_Int32 GetTop() const
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
bool IsFlyFrameFormatInHeader(const SwFrameFormat &rFormat)
Definition: atrfrm.cxx:3612
#define ESCHER_SpContainer
#define ESCHER_Prop_fBackground
unsigned int mnHdFtIndex
Definition: wrtww8.hxx:349
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
Definition: fldbas.cxx:465
bool IsPosToggle() const
Definition: fmtornt.hxx:95
static void WriteGrfAttr(const SwNoTextNode &rNd, const SwFrameFormat &rFormat, EscherPropertyContainer &rPropOpt)
Definition: wrtw8esh.cxx:1661
SotStorage & GetStorage() const
Definition: shellio.hxx:499
void Append(const SdrObject &rObj, sal_uInt32 nShapeId)
Definition: wrtw8esh.cxx:930
FrPair GetMapFactor(MapUnit eS, MapUnit eD)
mso_sptTextBox
constexpr sal_uInt16 RES_TXTATR_END(RES_TXTATR_NOEND_END)
virtual void CloseContainer()
SfxItemState
#define ESCHER_ShpInst_PictureFrame
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
void MakeZOrderArrAndFollowIds(std::vector< DrawObj > &rSrcArr, DrawObjPointerVector &rDstArr)
Definition: wrtw8esh.cxx:2949
sal_Int32 GetDenominator() const
SvStream & Strm() const
Definition: wrtww8.hxx:1181
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
void AddAtom(sal_uInt32 nAtomSitze, sal_uInt16 nRecType, int nRecVersion=0, int nRecInstance=0)
sal_uInt8 mnTyp
Definition: wrtww8.hxx:1465
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
#define ESCHER_ShpInst_Rectangle
unsigned char sal_uInt8
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Make exporting a Writer Frame easy.
virtual void WriteFrameExtraData(const SwFrameFormat &)
Definition: wrtw8esh.cxx:1524
#define ESCHER_Prop_lineColor
bool IsRemote() const
void setWidth(tools::Long n)
SwTwips GetPos() const
Definition: fmtornt.hxx:59
#define ESCHER_Prop_fNoFillHitTest
virtual sal_Int32 GetParagraphCount() const =0
const OUString & GetTargetFrameName() const
Definition: fmturl.hxx:65
sal_uInt16 nScript
Definition: wrtww8.hxx:1464
bool IsTextAttr(sal_Int32 nSwPos)
Definition: wrtw8esh.cxx:1198
virtual void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance=0)
std::vector< EECharAttrib > aTextAtrArr
Definition: wrtww8.hxx:1457
virtual void WritePictures()
Definition: wrtw8esh.cxx:2181
void SetEndian(SvStreamEndian SvStreamEndian)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
MSO_TextFlow
bool HasMark() const
INetProtocol GetProtocol() const
MSWord_SdrAttrIter(const MSWord_SdrAttrIter &)=delete
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
constexpr TypedWhichId< SwDrawModeGrf > RES_GRFATR_DRAWMODE(144)
#define ESCHER_Prop_fillType
SvxBoxItemLine
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
virtual sal_uInt32 EnterGroup(const OUString &rShapeName, const tools::Rectangle *pBoundRect)
MSO_LineStyle
static bool RTLDrawingsHack(SwTwips &rLeft, sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft, SwTwips nPageRight, SwTwips nPageSize)
Definition: wrtw8esh.cxx:558
mso_txflTtoBA
sal_uInt8 m_nTextTyp
Definition: wrtww8.hxx:547
void WriteSdrTextObj(const SdrTextObj &rObj, sal_uInt8 nTyp)
Definition: wrtw8esh.cxx:1317
#define DFF_Prop_fshadowObscured
virtual bool EndURL(bool isAtEndOfParagraph)=0
Output URL end.
sal_uInt64 Tell() const
void * p
void AddOpt(sal_uInt16 nPropID, bool bBlib, sal_uInt32 nSizeReduction, SvMemoryStream &rStream)
FIB - the File Information Block.
Definition: ww8scan.hxx:1104
void WriteEmptyFlyFrame(const SwFrameFormat &rFormat, sal_uInt32 nShapeId)
Definition: wrtw8esh.cxx:1530
sal_Int32 GetNumerator() const
const SfxPoolItem & GetFormatAttr(sal_uInt16 nWhich, bool bInParents=true) const
If bInParents is FALSE, search only in this format for attribute.
Definition: format.cxx:369
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
WW8_CP m_ccpText
Definition: ww8scan.hxx:1209
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
sal_uInt16 Count() const
Definition: wrtww8.hxx:1301
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
WW8_CP m_ccpFootnote
Definition: ww8scan.hxx:1210
std::unique_ptr< WW8_WrPlcTextBoxes > m_pTextBxs
Definition: wrtww8.hxx:504
WW8_CP m_ccpAtn
Definition: ww8scan.hxx:1213
SvStream & WriteChar(char nChar)
virtual void GetCharAttribs(sal_Int32 nPara, std::vector< EECharAttrib > &rLst) const =0
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
static void InsUInt16(ww::bytes &rO, sal_uInt16 n)
Definition: wrtww8.cxx:1706
virtual ~SwEscherExGlobal() override
Definition: wrtw8esh.cxx:1502
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
void PreWriteHyperlinkWithinFly(const SwFrameFormat &rFormat, EscherPropertyContainer &rPropOpt)
Definition: wrtw8esh.cxx:277
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:715
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:326
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:93
virtual bool StartURL(const OUString &rUrl, const OUString &rTarget)=0
Output URL start.
sal_Int32 GetRight() const
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
std::optional< OutlinerParaObject > CreateEditOutlinerParaObject() const
virtual SvStream * ImplQueryPictureStream() override
Override to create a new memory stream for picture data.
Definition: wrtw8esh.cxx:1506
#define ESCHER_SplitMenuColors
const OUString & GetToolTip() const
Definition: expfld.cxx:1419
std::vector< const EECharAttrib * > aChrTextAtrArr
Definition: wrtww8.hxx:1458
bool m_bFontSizeWritten
Is font size written already as part of the current character properties?
Definition: wrtww8.hxx:571
SwEscherEx(SvStream *pStrm, WW8Export &rWW8Wrt)
Definition: wrtw8esh.cxx:2194
sal_Int32 WriteGrfFlyFrame(const SwFrameFormat &rFormat, sal_uInt32 nShapeId)
Definition: wrtw8esh.cxx:1601
SdrLayerID GetHellLayerId() const
ESCHER_BlipFlagURL
MapUnit
void CreateEscher()
Definition: wrtw8esh.cxx:1453
Base class for WW8Export and DocxExport.
Definition: wrtww8.hxx:449
OUString GetMark(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
RndStdIds
WW8_FC m_fcPlcfspaMom
Definition: ww8scan.hxx:1385
virtual Degree100 GetRotateAngle() const
constexpr sal_uInt16 EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
virtual const tools::Rectangle & GetLogicRect() const
WinwordAnchoring aWinwordAnchoring
Definition: escher.hxx:145
bool IsInline() const
Is this frame inline (as character)
bool ReadOCXStream(tools::SvRef< SotStorage > const &rSrc1, css::uno::Reference< css::drawing::XShape > *pShapeRef, bool bFloatingCtrl=false)
Definition: wrtw8esh.cxx:3015
void WriteOutliner(const OutlinerParaObject &rOutliner, sal_uInt8 nTyp)
Definition: wrtw8esh.cxx:1341
WriterSource GetWriterType() const
Get the type of frame that this wraps.
virtual const SfxPoolItem & GetItem(sal_uInt16 nWhich) const override
Definition: wrtw8esh.cxx:1231
rtl_TextEncoding GetNextCharSet() const
Definition: wrtw8esh.cxx:1044
void SetItemsThatDifferFromStandard(bool bCharAttr, SfxItemSet &rSet)
Definition: wrtw8esh.cxx:1248
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:154
std::vector< DrawObj * > DrawObjPointerVector
Definition: wrtww8.hxx:360
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
sal_uInt16 GetSetWhichFromSwDocWhich(const SfxItemSet &rSet, const SwDoc &rDoc, sal_uInt16 nWhich)
Map a SwDoc WhichId to the equivalent Id for a given SfxItemSet.
#define ESCHER_Prop_fPrint
virtual ~SwBasicEscherEx() override
Definition: wrtw8esh.cxx:1520
virtual void DoFormText(const SwInputField *pField) override
Definition: wrtw8esh.cxx:475
static sal_uInt32 GetColor(const sal_uInt32 nColor)
bool GetOpt(sal_uInt16 nPropertyID, sal_uInt32 &rPropValue) const
void WriteOLEPicture(EscherPropertyContainer &rPropOpt, ShapeFlag nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj, sal_uInt32 nShapeId, const css::awt::Rectangle *pVisArea)
Definition: wrtw8esh.cxx:2897
void SetHellLayerId(SdrLayerID nId)
SwFlyFrameFormat * GetPrev() const
Definition: fmtcnct.hxx:53
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
mso_lineSimple
bool IsTextNode() const
Definition: node.hxx:637
#define ESCHER_Prop_pibFlags
The class MSWordAttrIter is a helper class to build the Fkp.chpx.
Definition: wrtww8.hxx:1435
static void WriteLong(SvStream &rStrm, sal_Int32 nVal)
Definition: wrtww8.hxx:964
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
ww8::Frame maContent
Definition: wrtww8.hxx:345
const SwPosition & GetPosition() const
Get the position this frame is anchored at.
virtual void WriteChar(sal_Unicode c)=0
aStr
WW8_CP m_ccpHdr
Definition: ww8scan.hxx:1211
void NextPara(sal_Int32 nPar)
Definition: wrtw8esh.cxx:1024
sal_uInt32 mnYRelTo
Definition: escher.hxx:74
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
virtual OUString GetPar2() const override
aPromptText
Definition: expfld.cxx:1399
std::unique_ptr< WW8_WrPlcPn > m_pChpPlc
Definition: wrtww8.hxx:499
sal_uInt16 Which() const
SvxFrameDirection TrueFrameDirection(const SwFrameFormat &rFlyFormat) const
Right to left?
Definition: wrtw8nds.cxx:1655
SdrObject * FindRealSdrObject()
Definition: atrfrm.cxx:2773
const Graphic & GetGrf(bool bWait=false) const
Definition: ndgrf.cxx:371
static void InsAsString16(ww::bytes &rO, const OUString &rStr)
Definition: wrtww8.cxx:1724
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(107)
sal_Int32 WriteTextFlyFrame(const DrawObj &rObj, sal_uInt32 nShapeId, sal_uInt32 nTextBox, DrawObjPointerVector &rPVec)
Definition: wrtw8esh.cxx:2843
const Size & GetSize() const
void setHeight(tools::Long n)
sal_uInt16 nPos
mso_lineDotGEL
void WriteEscher()
Definition: wrtw8esh.cxx:1466
const SfxPoolItem * GetCurItem() const
#define ESCHER_Prop_lTxid
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1319
sal_Int16 nValue
#define ESCHER_ClientData
constexpr OUStringLiteral aObjectPool
Definition: ww8scan.hxx:45
#define ESCHER_Prop_pihlShape
const SvxFieldData * GetField() const
virtual const tools::Rectangle & GetLogicRect() const override
sal_uInt16 GetWidth() const
const OUString & GetURL() const
Definition: fmturl.hxx:66
SvxShadowLocation
#define ESCHER_Prop_dxTextRight
EnumT GetValue() const