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