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