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  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-Attribut true
1011 
1012  // A special character is required in the text for DrawObjects,
1013  // therefore a fSpec-Attribut
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 a 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  const MapMode aMap100mm( MapUnit::Map100thMM );
1588  Size aSize( rGrf.GetPrefSize() );
1589  if ( MapUnit::MapPixel == rGrf.GetPrefMapMode().GetMapUnit() )
1590  {
1591  aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMap100mm );
1592  }
1593  else
1594  {
1595  aSize = OutputDevice::LogicToLogic( aSize,rGrf.GetPrefMapMode(), aMap100mm );
1596  }
1597  sal_uInt32 nBlibId = mxGlobal->GetBlibID( *(mxGlobal->QueryPictureStream()), aGraphicObject );
1598  if (nBlibId)
1599  aPropOpt.AddOpt(ESCHER_Prop_pib, nBlibId, true);
1600  }
1606  aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
1607  aPropOpt.AddOpt( ESCHER_Prop_dyTextTop, 0 );
1608  aPropOpt.AddOpt( ESCHER_Prop_dyTextBottom, 0 );
1609  aPropOpt.AddOpt( ESCHER_Prop_dxTextLeft, 0 );
1610  aPropOpt.AddOpt( ESCHER_Prop_dxTextRight, 0 );
1611  const Color aTmpColor( COL_WHITE );
1612  std::shared_ptr<SvxBrushItem> aBrush(std::make_shared<SvxBrushItem>(aTmpColor, RES_BACKGROUND));
1613  const SvxBrushItem* pRet = rWrt.GetCurrentPageBgBrush();
1614  if (pRet && (pRet->GetGraphic() ||( pRet->GetColor() != COL_TRANSPARENT)))
1615  aBrush.reset(static_cast<SvxBrushItem*>(pRet->Clone()));
1616  WriteBrushAttr(*aBrush, aPropOpt);
1617 
1618  aPropOpt.AddOpt( ESCHER_Prop_pictureActive, 0 );
1619  aPropOpt.Commit( GetStream() );
1621  GetStream().WriteUInt32( 0x80000000 );
1622  CloseContainer();
1623 }
1624 
1625 sal_Int32 SwBasicEscherEx::WriteGrfFlyFrame(const SwFrameFormat& rFormat, sal_uInt32 nShapeId)
1626 {
1627  sal_Int32 nBorderThick=0;
1629  SwGrfNode *pGrfNd = pNd ? pNd->GetGrfNode() : nullptr;
1630  OSL_ENSURE(pGrfNd, "No SwGrfNode ?, suspicious");
1631  if (!pGrfNd)
1632  return nBorderThick;
1633 
1635 
1636  const SwMirrorGrf &rMirror = pGrfNd->GetSwAttrSet().GetMirrorGrf();
1638  AddMirrorFlags(ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, rMirror),
1639  nShapeId);
1640 
1641  EscherPropertyContainer aPropOpt;
1642 
1643  sal_uInt32 nFlags = ESCHER_BlipFlagDefault;
1644 
1645  if (pGrfNd->IsLinkedFile())
1646  {
1647  OUString sURL;
1648  pGrfNd->GetFileFilterNms( &sURL, nullptr );
1649 
1650  ww::bytes aBuf;
1651  SwWW8Writer::InsAsString16( aBuf, sURL );
1652  SwWW8Writer::InsUInt16( aBuf, 0 );
1653 
1654  aPropOpt.AddOpt(ESCHER_Prop_pibName, true, aBuf.size(), aBuf);
1657  }
1658  else
1659  {
1660  const Graphic& aGraphic(pGrfNd->GetGrf());
1661  GraphicObject aGraphicObject( aGraphic );
1662  OString aUniqueId = aGraphicObject.GetUniqueID();
1663 
1664  if (!aUniqueId.isEmpty())
1665  {
1666  const MapMode aMap100mm( MapUnit::Map100thMM );
1667  Size aSize( aGraphic.GetPrefSize() );
1668 
1669  if ( MapUnit::MapPixel == aGraphic.GetPrefMapMode().GetMapUnit() )
1670  {
1672  aSize, aMap100mm );
1673  }
1674  else
1675  {
1676  aSize = OutputDevice::LogicToLogic( aSize,
1677  aGraphic.GetPrefMapMode(), aMap100mm );
1678  }
1679 
1680  sal_uInt32 nBlibId = mxGlobal->GetBlibID( *QueryPictureStream(), aGraphicObject);
1681  if (nBlibId)
1682  aPropOpt.AddOpt(ESCHER_Prop_pib, nBlibId, true);
1683  }
1684  }
1685 
1686  aPropOpt.AddOpt( ESCHER_Prop_pibFlags, nFlags );
1687  nBorderThick = WriteFlyFrameAttr(rFormat,mso_sptPictureFrame,aPropOpt);
1688  WriteGrfAttr(*pGrfNd, rFormat, aPropOpt);
1689 
1690  aPropOpt.Commit( GetStream() );
1691 
1692  // store anchor attribute
1693  WriteFrameExtraData( rFormat );
1694 
1695  CloseContainer(); // ESCHER_SpContainer
1696  return nBorderThick;
1697 }
1698 
1700  EscherPropertyContainer& rPropOpt)
1701 {
1702  const SfxPoolItem* pItem;
1703  GraphicDrawMode nMode = GraphicDrawMode::Standard;
1704  sal_Int32 nContrast = 0;
1705  sal_Int16 nBrightness = 0;
1706 
1707  if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_CONTRAST,
1708  true, &pItem))
1709  {
1710  nContrast = static_cast<const SfxInt16Item*>(pItem)->GetValue();
1711  }
1712 
1713  if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_LUMINANCE,
1714  true, &pItem))
1715  {
1716  nBrightness = static_cast<const SfxInt16Item*>(pItem)->GetValue();
1717  }
1718 
1719  if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_DRAWMODE,
1720  true, &pItem))
1721  {
1722  nMode = static_cast<GraphicDrawMode>(static_cast<const SfxEnumItemInterface*>(pItem)->GetEnumValue());
1723  if (nMode == GraphicDrawMode::Watermark)
1724  {
1725  /*
1726  There is no real watermark mode in word, we must use standard
1727  mode and modify our ones by 70% extra brightness and 70% less
1728  contrast. This means that unmodified default OOo watermark
1729  will turn back into watermark, and modified OOo watermark will
1730  change into a close visual representation in standardmode
1731  */
1732  nBrightness += 70;
1733  if (nBrightness > 100)
1734  nBrightness = 100;
1735  nContrast -= 70;
1736  if (nContrast < -100)
1737  nContrast = -100;
1738  nMode = GraphicDrawMode::Standard;
1739  }
1740  }
1741 
1742  sal_uInt32 nPictureMode;
1743  if (nMode == GraphicDrawMode::Greys)
1744  nPictureMode = 0x40004;
1745  else if (nMode == GraphicDrawMode::Mono)
1746  nPictureMode = 0x60006;
1747  else
1748  nPictureMode = 0;
1749  rPropOpt.AddOpt( ESCHER_Prop_pictureActive, nPictureMode );
1750 
1751  if (nContrast != 0)
1752  {
1753  nContrast+=100;
1754  if (nContrast == 100)
1755  nContrast = 0x10000;
1756  else if (nContrast < 100)
1757  {
1758  nContrast *= 0x10000;
1759  nContrast /= 100;
1760  }
1761  else if (nContrast < 200)
1762  nContrast = (100 * 0x10000) / (200-nContrast);
1763  else
1764  nContrast = 0x7fffffff;
1765  rPropOpt.AddOpt( ESCHER_Prop_pictureContrast, nContrast);
1766  }
1767 
1768  if (nBrightness != 0)
1769  rPropOpt.AddOpt( ESCHER_Prop_pictureBrightness, nBrightness * 327 );
1770 
1771  sal_Int32 nCropL = 0;
1772  sal_Int32 nCropR = 0;
1773  sal_Int32 nCropT = 0;
1774  sal_Int32 nCropB = 0;
1775  if (SfxItemState::SET == rNd.GetSwAttrSet().GetItemState(RES_GRFATR_CROPGRF,
1776  true, &pItem))
1777  {
1778  const SwCropGrf& rCrop = *static_cast<const SwCropGrf*>(pItem);
1779  nCropL += rCrop.GetLeft();
1780  nCropR += rCrop.GetRight();
1781  nCropT += rCrop.GetTop();
1782  nCropB += rCrop.GetBottom();
1783  }
1784 
1785  // simulate border padding as a negative crop.
1786  if (SfxItemState::SET == rFormat.GetItemState(RES_BOX, false, &pItem))
1787  {
1788  const SvxBoxItem& rBox = *static_cast<const SvxBoxItem*>(pItem);
1789  nCropL -= rBox.GetDistance( SvxBoxItemLine::LEFT );
1790  nCropR -= rBox.GetDistance( SvxBoxItemLine::RIGHT );
1791  nCropT -= rBox.GetDistance( SvxBoxItemLine::TOP );
1792  nCropB -= rBox.GetDistance( SvxBoxItemLine::BOTTOM );
1793  }
1794 
1795  const Size aSz( rNd.GetTwipSize() );
1796  if( 0 != nCropL )
1797  rPropOpt.AddOpt( ESCHER_Prop_cropFromLeft, ToFract16( nCropL, aSz.Width()) );
1798  if( 0 != nCropR )
1799  rPropOpt.AddOpt( ESCHER_Prop_cropFromRight, ToFract16( nCropR, aSz.Width()));
1800  if( 0 != nCropT )
1801  rPropOpt.AddOpt( ESCHER_Prop_cropFromTop, ToFract16( nCropT, aSz.Height()));
1802  if( 0 != nCropB )
1803  rPropOpt.AddOpt( ESCHER_Prop_cropFromBottom, ToFract16( nCropB, aSz.Height()));
1804 }
1805 
1806 void SwBasicEscherEx::SetPicId(const SdrObject &, sal_uInt32,
1808 {
1809 }
1810 
1811 void SwEscherEx::SetPicId(const SdrObject &rSdrObj, sal_uInt32 nShapeId,
1812  EscherPropertyContainer &rPropOpt)
1813 {
1814  pTextBxs->Append(rSdrObj, nShapeId);
1815  sal_uInt32 nPicId = pTextBxs->Count();
1816  nPicId *= 0x10000;
1817  rPropOpt.AddOpt( ESCHER_Prop_pictureId, nPicId );
1818 }
1819 
1820 sal_Int32 SwBasicEscherEx::WriteOLEFlyFrame(const SwFrameFormat& rFormat, sal_uInt32 nShapeId)
1821 {
1822  sal_Int32 nBorderThick = 0;
1823  if (const SdrObject* pSdrObj = rFormat.FindRealSdrObject())
1824  {
1825  SwNodeIndex aIdx(*rFormat.GetContent().GetContentIdx(), 1);
1826  SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
1827  sal_Int64 nAspect = rOLENd.GetAspect();
1828 
1829  uno::Reference < embed::XEmbeddedObject > xObj(rOLENd.GetOLEObj().GetOleRef());
1830 
1831  // the rectangle is used to transport the size of the object
1832  // the left, top corner is set to ( 0, 0 ) by default constructor,
1833  // if the width and height are set correctly bRectIsSet should be set to true
1834  awt::Rectangle aRect;
1835  bool bRectIsSet = false;
1836 
1837  // TODO/LATER: should the icon size be stored in case of iconified object?
1838  if ( xObj.is() && nAspect != embed::Aspects::MSOLE_ICON )
1839  {
1840  try
1841  {
1842  awt::Size aSize = xObj->getVisualAreaSize( nAspect );
1843  aRect.Width = aSize.Width;
1844  aRect.Height = aSize.Height;
1845  bRectIsSet = true;
1846  }
1847  catch( const uno::Exception& )
1848  {}
1849  }
1850 
1851  /*
1852  #i5970#
1853  Export floating ole2 .doc ver 8+ wmf ole2 previews as emf previews
1854  instead ==> allows unicode text to be preserved
1855  */
1856 #ifdef OLE_PREVIEW_AS_EMF
1857  const Graphic* pGraphic = rOLENd.GetGraphic();
1858 #endif
1860 
1861  EscherPropertyContainer aPropOpt;
1862  const SwMirrorGrf &rMirror = rOLENd.GetSwAttrSet().GetMirrorGrf();
1863  WriteOLEPicture(aPropOpt,
1864  AddMirrorFlags(ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::OLEShape, rMirror),
1865  pGraphic ? *pGraphic : Graphic(), *pSdrObj, nShapeId, bRectIsSet ? &aRect : nullptr );
1866 
1867  nBorderThick = WriteFlyFrameAttr(rFormat, mso_sptPictureFrame, aPropOpt);
1868  WriteGrfAttr(rOLENd, rFormat, aPropOpt);
1869  aPropOpt.Commit(GetStream());
1870 
1871  // store anchor attribute
1872  WriteFrameExtraData( rFormat );
1873 
1874  CloseContainer(); // ESCHER_SpContainer
1875  }
1876  return nBorderThick;
1877 }
1878 
1880  EscherPropertyContainer& rPropOpt)
1881 {
1882  bool bSetOpacity = false;
1883  sal_uInt32 nOpaque = 0;
1884  if (const GraphicObject *pGraphicObject = rBrush.GetGraphicObject())
1885  {
1886  OString aUniqueId = pGraphicObject->GetUniqueID();
1887  if (!aUniqueId.isEmpty())
1888  {
1889  const Graphic &rGraphic = pGraphicObject->GetGraphic();
1890  Size aSize(rGraphic.GetPrefSize());
1891  const MapMode aMap100mm(MapUnit::Map100thMM);
1892  if (MapUnit::MapPixel == rGraphic.GetPrefMapMode().GetMapUnit())
1893  {
1895  aSize, aMap100mm);
1896  }
1897  else
1898  {
1899  aSize = OutputDevice::LogicToLogic(aSize,
1900  rGraphic.GetPrefMapMode(), aMap100mm);
1901  }
1902 
1903  sal_uInt32 nBlibId = mxGlobal->GetBlibID(*QueryPictureStream(), *pGraphicObject);
1904  if (nBlibId)
1905  rPropOpt.AddOpt(ESCHER_Prop_fillBlip,nBlibId,true);
1906  }
1907 
1908  if (0 != (nOpaque = pGraphicObject->GetAttr().GetTransparency()))
1909  bSetOpacity = true;
1910 
1912  rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x140014 );
1913  rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0 );
1914  }
1915  else
1916  {
1917  sal_uInt32 nFillColor = GetColor(rBrush.GetColor());
1918  rPropOpt.AddOpt( ESCHER_Prop_fillColor, nFillColor );
1919  rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, nFillColor ^ 0xffffff );
1920  rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 );
1921 
1922  if (0 != (nOpaque = rBrush.GetColor().GetTransparency()))
1923  bSetOpacity = true;
1924  }
1925 
1926  if (bSetOpacity)
1927  {
1928  nOpaque = (nOpaque * 100) / 0xFE;
1929  nOpaque = ((100 - nOpaque) << 16) / 100;
1930  rPropOpt.AddOpt(ESCHER_Prop_fillOpacity, nOpaque);
1931  }
1932 }
1933 
1935  MSO_SPT eShapeType, EscherPropertyContainer& rPropOpt)
1936 {
1937  sal_Int32 nLineWidth=0;
1938  const SfxPoolItem* pItem;
1939  bool bFirstLine = true;
1940  if (SfxItemState::SET == rFormat.GetItemState(RES_BOX, true, &pItem))
1941  {
1942  static const o3tl::enumarray<SvxBoxItemLine, sal_uInt16> aExhperProp =
1943  {
1946  };
1947  const SvxBorderLine* pLine;
1948 
1950  if( nullptr != ( pLine = static_cast<const SvxBoxItem*>(pItem)->GetLine( n )) )
1951  {
1952  if( bFirstLine )
1953  {
1954  sal_uInt32 nLineColor = GetColor(pLine->GetColor());
1955  rPropOpt.AddOpt( ESCHER_Prop_lineColor, nLineColor );
1957  nLineColor ^ 0xffffff );
1958 
1959  MSO_LineStyle eStyle;
1960  if( pLine->isDouble() )
1961  {
1962  // double line
1963  nLineWidth = pLine->GetWidth();
1964  if( pLine->GetInWidth() == pLine->GetOutWidth() )
1965  eStyle = mso_lineDouble;
1966  else if( pLine->GetInWidth() < pLine->GetOutWidth() )
1967  eStyle = mso_lineThickThin;
1968  else
1969  eStyle = mso_lineThinThick;
1970  }
1971  else
1972  {
1973  // simple line
1974  eStyle = mso_lineSimple;
1975  nLineWidth = pLine->GetWidth();
1976  }
1977 
1978  rPropOpt.AddOpt( ESCHER_Prop_lineStyle, eStyle );
1979  rPropOpt.AddOpt( ESCHER_Prop_lineWidth,
1980  DrawModelToEmu( nLineWidth ));
1981 
1982  MSO_LineDashing eDashing = mso_lineSolid;
1983  switch (pLine->GetBorderLineStyle())
1984  {
1985  case SvxBorderLineStyle::DASHED:
1986  eDashing = mso_lineDashGEL;
1987  break;
1988  case SvxBorderLineStyle::DOTTED:
1989  eDashing = mso_lineDotGEL;
1990  break;
1991  case SvxBorderLineStyle::SOLID:
1992  default:
1993  break;
1994  }
1995  rPropOpt.AddOpt( ESCHER_Prop_lineDashing, eDashing );
1996  rPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x8000E );
1997 
1998  //Use import logic to determine how much of border will go
1999  //outside graphic
2001  eStyle,eShapeType,nLineWidth);
2002  bFirstLine = false;
2003  }
2004  rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(
2005  static_cast<const SvxBoxItem*>(pItem)->GetDistance( n ) ));
2006  }
2007  else
2008  rPropOpt.AddOpt( aExhperProp[ n ], DrawModelToEmu(static_cast<const SvxBoxItem*>(pItem)->GetDistance( n )) );
2009  }
2010  else
2011  {
2012  rPropOpt.AddOpt( ESCHER_Prop_dyTextTop, 0 );
2013  rPropOpt.AddOpt( ESCHER_Prop_dyTextBottom, 0 );
2014  rPropOpt.AddOpt( ESCHER_Prop_dxTextLeft, 0 );
2015  rPropOpt.AddOpt( ESCHER_Prop_dxTextRight, 0 );
2016  }
2017 
2018  if( bFirstLine ) // no valid line found
2019  {
2020  rPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x80000 );
2021  }
2022  const SwAttrSet& rAttrSet = rFormat.GetAttrSet();
2023  if (SfxItemState::SET == rAttrSet.GetItemState(RES_BOX, false, &pItem))
2024  {
2025  const SvxBoxItem* pBox = static_cast<const SvxBoxItem*>(pItem);
2026  if( pBox )
2027  {
2028  const SfxPoolItem* pShadItem;
2029  if (SfxItemState::SET
2030  == rAttrSet.GetItemState(RES_SHADOW, true, &pShadItem))
2031  {
2032  const SvxShadowItem* pSI = static_cast<const SvxShadowItem*>(pShadItem);
2033 
2034  const sal_uInt16 nCstScale = 635; // unit scale between AOO and MS Word
2035  const sal_uInt32 nShadowType = 131074; // shadow type of ms word. need to set the default value.
2036 
2037  Color nColor = pSI->GetColor();
2038  sal_Int32 nOffX = pSI->GetWidth() * nCstScale;
2039  sal_Int32 nOffY = pSI->GetWidth() * nCstScale;
2040 
2041  SvxShadowLocation eLocation = pSI->GetLocation();
2042  if( (eLocation!=SvxShadowLocation::NONE) && (pSI->GetWidth()!=0) )
2043  {
2044  switch( eLocation )
2045  {
2046  case SvxShadowLocation::TopLeft:
2047  {
2048  nOffX = -nOffX;
2049  nOffY = -nOffY;
2050  }
2051  break;
2052  case SvxShadowLocation::TopRight:
2053  {
2054  nOffY = -nOffY;
2055  }
2056  break;
2057  case SvxShadowLocation::BottomLeft:
2058  {
2059  nOffX = -nOffX;
2060  }
2061  break;
2062  case SvxShadowLocation::BottomRight:
2063  break;
2064  default:
2065  break;
2066  }
2067 
2068  rPropOpt.AddOpt( DFF_Prop_shadowColor, wwUtility::RGBToBGR(nColor));
2069  rPropOpt.AddOpt( DFF_Prop_shadowOffsetX, nOffX );
2070  rPropOpt.AddOpt( DFF_Prop_shadowOffsetY, nOffY );
2071  rPropOpt.AddOpt( DFF_Prop_fshadowObscured, nShadowType );
2072  }
2073  }
2074  }
2075  }
2076 
2077  // SwWW8ImplReader::Read_GrafLayer() imports these as opaque
2078  // unconditionally, so if both are true, don't export the property.
2079  bool bIsInHeader = sw::IsFlyFrameFormatInHeader(rFormat);
2080  bool bIsThrought = rFormat.GetSurround().GetValue() == css::text::WrapTextMode_THROUGH;
2081 
2082  if (bIsInHeader)
2083  {
2084  std::shared_ptr<SvxBrushItem> aBrush(rFormat.makeBackgroundBrushItem());
2085 
2086  if(aBrush)
2087  {
2088  WriteBrushAttr(*aBrush, rPropOpt);
2089  }
2090  }
2091  else
2092  {
2093  std::shared_ptr<SvxBrushItem> aBrush(rWrt.TrueFrameBgBrush(rFormat));
2094 
2095  if(aBrush)
2096  {
2097  WriteBrushAttr(*aBrush, rPropOpt);
2098  }
2099  }
2100 
2101  const SdrObject* pObj = rFormat.FindRealSdrObject();
2102 
2103  if( pObj && (pObj->GetLayer() == GetHellLayerId() ||
2104  pObj->GetLayer() == GetInvisibleHellId() ) && !(bIsInHeader && bIsThrought))
2105  {
2106  rPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x200020 );
2107  }
2108 
2109  PreWriteHyperlinkWithinFly(rFormat,rPropOpt);
2110 
2111  return nLineWidth;
2112 }
2113 
2114 sal_Int32 SwEscherEx::WriteFlyFrameAttr(const SwFrameFormat& rFormat, MSO_SPT eShapeType,
2115  EscherPropertyContainer& rPropOpt)
2116 {
2117  sal_Int32 nLineWidth = SwBasicEscherEx::WriteFlyFrameAttr(rFormat, eShapeType,
2118  rPropOpt);
2119 
2120  /*
2121  These are not in SwBasicEscherEx::WriteFlyFrameAttr because inline objs
2122  can't do it in word and it hacks it in by stretching the graphic that
2123  way, perhaps we should actually draw in this space into the graphic we
2124  are exporting!
2125  */
2126  const SfxPoolItem* pItem;
2127  if (SfxItemState::SET == rFormat.GetItemState(RES_LR_SPACE, true, &pItem))
2128  {
2130  DrawModelToEmu( static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft() ) );
2132  DrawModelToEmu( static_cast<const SvxLRSpaceItem*>(pItem)->GetRight() ) );
2133  }
2134  else
2135  {
2136  rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistLeft, 0 );
2137  rPropOpt.AddOpt( ESCHER_Prop_dxWrapDistRight, 0 );
2138  }
2139 
2140  if (SfxItemState::SET == rFormat.GetItemState(RES_UL_SPACE, true, &pItem))
2141  {
2143  DrawModelToEmu( static_cast<const SvxULSpaceItem*>(pItem)->GetUpper() ) );
2145  DrawModelToEmu( static_cast<const SvxULSpaceItem*>(pItem)->GetLower() ) );
2146  }
2147 
2148  if (rFormat.GetSurround().IsContour())
2149  {
2150  if (const SwNoTextNode *pNd = GetNoTextNodeFromSwFrameFormat(rFormat))
2151  {
2152  const tools::PolyPolygon *pPolyPoly = pNd->HasContour();
2153  if (pPolyPoly && pPolyPoly->Count())
2154  {
2155  tools::Polygon aPoly = CorrectWordWrapPolygonForExport(*pPolyPoly, pNd);
2156  SvMemoryStream aPolyDump;
2157  aPolyDump.SetEndian(SvStreamEndian::LITTLE);
2158 
2159  sal_uInt16 nLen = aPoly.GetSize();
2160  aPolyDump.WriteUInt16( nLen );
2161  aPolyDump.WriteUInt16( nLen );
2162  aPolyDump.WriteUInt16( 8 );
2163  for (sal_uInt16 nI = 0; nI < nLen; ++nI)
2164  {
2165  aPolyDump.WriteUInt32( aPoly[nI].X() );
2166  aPolyDump.WriteUInt32( aPoly[nI].Y() );
2167  }
2168 
2169  rPropOpt.AddOpt(DFF_Prop_pWrapPolygonVertices, false, 0, aPolyDump);
2170  }
2171  }
2172  }
2173 
2174  PreWriteHyperlinkWithinFly(rFormat,rPropOpt);
2175 
2176  return nLineWidth;
2177 }
2178 
2180 {
2181  MapUnit eMap = MapUnit::MapTwip;
2183  {
2184  // PPT works only with units of 576DPI
2185  // WW however is using twips, i.e 1440DPI.
2186  eMap = pModel->GetScaleUnit();
2187  }
2188 
2189  // MS-DFF-Properties mostly are in EMU (English Metric Units)
2190  // 1mm=36000emu, 1twip=635emu
2191  Fraction aFact(360, 1);
2192  aFact /= GetMapFactor(MapUnit::Map100thMM, eMap).X();
2193  // create little values
2194  aFact = Fraction(aFact.GetNumerator(), aFact.GetDenominator());
2195  mnEmuMul = aFact.GetNumerator();
2196  mnEmuDiv = aFact.GetDenominator();
2197 
2199 }
2200 
2201 sal_Int32 SwBasicEscherEx::ToFract16(sal_Int32 nVal, sal_uInt32 nMax)
2202 {
2203  if (nMax)
2204  {
2205  if (nVal >= 0)
2206  {
2207  sal_Int32 nMSVal = (nVal / 65536) * nMax;
2208  nMSVal += (nVal * 65536) / nMax;
2209  return nMSVal;
2210  } else {
2211  // negative fraction does not have "-0", fractional part is always
2212  // positive: -0.4 represented as -1 + 0.6
2213  sal_Int32 const nDiv = (nVal / sal_Int32(nMax)) - 1;
2214  sal_uInt32 nMSVal = (sal_uInt32(nDiv) << 16) & 0xffff0000;
2215  nMSVal += (nVal * 65536) / sal_Int32(nMax) + (-nDiv * 65536);
2216  return nMSVal;
2217  }
2218  }
2219  return 0;
2220 }
2221 
2223 {
2225 }
2226 
2228 {
2229  if( SvStream* pPicStrm = static_cast< SwEscherExGlobal& >( *mxGlobal ).GetPictureStream() )
2230  {
2231  // set the blip - entries to the correct stream pos
2232  sal_Int32 nEndPos = pPicStrm->Tell();
2233  mxGlobal->WriteBlibStoreEntry(*pEscherStrm, 1, nEndPos);
2234 
2235  pPicStrm->Seek(0);
2236  pEscherStrm->WriteStream( *pPicStrm );
2237  }
2238 }
2239 
2241  : SwBasicEscherEx(pStrm, rWW8Wrt),
2242  pTextBxs(nullptr)
2243 {
2246 
2247  sal_uInt16 nColorCount = 4;
2248  pStrm ->WriteUInt16( nColorCount << 4 ) // instance
2249  .WriteUInt16( ESCHER_SplitMenuColors ) // record type
2250  .WriteUInt32( nColorCount * 4 ) // size
2251  .WriteUInt32( 0x08000004 )
2252  .WriteUInt32( 0x08000001 )
2253  .WriteUInt32( 0x08000002 )
2254  .WriteUInt32( 0x100000f7 );
2255 
2256  CloseContainer(); // ESCHER_DggContainer
2257 
2258  sal_uInt8 i = 2; // for header/footer and the other
2259  PlcDrawObj *pSdrObjs = rWrt.m_pHFSdrObjs;
2260  pTextBxs = rWrt.m_pHFTextBxs;
2261 
2262  // if no header/footer -> skip over
2263  if (!pSdrObjs->size())
2264  {
2265  --i;
2266  pSdrObjs = rWrt.m_pSdrObjs;
2267  pTextBxs = rWrt.m_pTextBxs;
2268  }
2269 
2270  for( ; i--; pSdrObjs = rWrt.m_pSdrObjs, pTextBxs = rWrt.m_pTextBxs )
2271  {
2272  // "dummy char" (or any Count ?) - why? Only Microsoft knows it.
2273  GetStream().WriteChar( i );
2274 
2276 
2277  EnterGroup();
2278 
2279  sal_uLong nSecondShapeId = pSdrObjs == rWrt.m_pSdrObjs ? GenerateShapeId() : 0;
2280 
2281  // write now all Writer-/DrawObjects
2282  DrawObjPointerVector aSorted;
2283  MakeZOrderArrAndFollowIds(pSdrObjs->GetObjArr(), aSorted);
2284 
2285  sal_uInt32 nShapeId=0;
2286  for (auto& pObj : aSorted)
2287  {
2288  sal_Int32 nBorderThick=0;
2289  OSL_ENSURE(pObj, "impossible");
2290  if (!pObj)
2291  continue;
2292  const ww8::Frame &rFrame = pObj->maContent;
2293  const SwFrameFormat& rFormat = rFrame.GetFrameFormat();
2294 
2295  switch (rFrame.GetWriterType())
2296  {
2297  case ww8::Frame::eTextBox:
2298  case ww8::Frame::eOle:
2299  case ww8::Frame::eGraphic:
2300  nBorderThick = WriteFlyFrame(*pObj, nShapeId, aSorted);
2301  break;
2303  WriteOCXControl(rFormat, nShapeId = GenerateShapeId());
2304  break;
2305  case ww8::Frame::eDrawing:
2306  {
2308  const SdrObject* pSdrObj = rFormat.FindRealSdrObject();
2309  if (pSdrObj)
2310  {
2311  nShapeId = AddSdrObject(*pSdrObj);
2312  }
2313 #if OSL_DEBUG_LEVEL > 0
2314  else
2315  OSL_ENSURE( false, "Where is the SDR-Object?" );
2316 #endif
2317  }
2318  break;
2319  default:
2320  break;
2321  }
2322 
2323  if( !nShapeId )
2324  {
2325  nShapeId = AddDummyShape();
2326  }
2327 
2328  pObj->SetShapeDetails(nShapeId, nBorderThick);
2329  }
2330 
2331  EndSdrObjectPage(); // ???? Bugfix for 74724
2332 
2333  if( nSecondShapeId )
2334  {
2336 
2338  ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::Background,
2339  nSecondShapeId );
2340 
2341  EscherPropertyContainer aPropOpt;
2342  const SwFrameFormat &rFormat = rWrt.m_pDoc->GetPageDesc(0).GetMaster();
2343  const SfxPoolItem* pItem = nullptr;
2344  SfxItemState eState = rFormat.GetItemState(RES_BACKGROUND, true,
2345  &pItem);
2346  if (SfxItemState::SET == eState && pItem)
2347  {
2348  const SvxBrushItem* pBrush = static_cast<const SvxBrushItem*>(pItem);
2349  WriteBrushAttr(*pBrush, aPropOpt);
2350 
2352  if( ePos != GPOS_NONE && ePos != GPOS_AREA )
2353  {
2354  /* #i56806# 0x033F parameter specifies a 32-bit field of shape boolean properties.
2355  0x10001 means fBackground and fUsefBackground flag are true thus background
2356  picture will be shown as "tiled" fill.*/
2357  aPropOpt.AddOpt( ESCHER_Prop_fBackground, 0x10001 );
2358  }
2359  }
2360  aPropOpt.AddOpt( ESCHER_Prop_lineColor, 0x8000001 );
2361  aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080008 );
2362  aPropOpt.AddOpt( ESCHER_Prop_shadowColor, 0x8000002 );
2363  aPropOpt.AddOpt( ESCHER_Prop_lineWidth, 0 );
2364 
2365  aPropOpt.Commit( *pStrm );
2366 
2367  AddAtom( 4, ESCHER_ClientData );
2368  GetStream().WriteInt32( 1 );
2369 
2370  CloseContainer(); // ESCHER_SpContainer
2371  }
2372  CloseContainer(); // ESCHER_DgContainer
2373  }
2374 }
2375 
2377 {
2378 }
2379 
2381 {
2382  pEscherStrm->Seek(0);
2384  delete pEscherStrm;
2385  pEscherStrm = nullptr;
2386 }
2387 
2388 
2389 namespace
2390 {
2391  template<typename OrientType>
2392  void lcl_SetRelationOrient(OrientType& rOrient, const sw::WW8AnchorConv eConv, const std::function<void()>& fDefault)
2393  {
2394  switch(eConv)
2395  {
2397  // #i33818#
2398  rOrient.SetRelationOrient(text::RelOrientation::PAGE_PRINT_AREA);
2399  break;
2401  rOrient.SetRelationOrient(text::RelOrientation::PAGE_FRAME);
2402  break;
2404  rOrient.SetRelationOrient(text::RelOrientation::FRAME);
2405  break;
2407  rOrient.SetRelationOrient(text::RelOrientation::CHAR);
2408  break;
2410  rOrient.SetRelationOrient(text::RelOrientation::TEXT_LINE);
2411  break;
2412  default:
2413  fDefault();
2414  }
2415  }
2416 }
2443  SwFormatVertOrient& _iorVertOri,
2444  const SwFrameFormat& _rFrameFormat )
2445 {
2446  const RndStdIds eAnchor = _rFrameFormat.GetAnchor().GetAnchorId();
2447 
2448  if ( (RndStdIds::FLY_AS_CHAR == eAnchor) || (RndStdIds::FLY_AT_FLY == eAnchor) )
2449  {
2450  // no conversion for as-character or at frame anchored objects
2451  return false;
2452  }
2453 
2454  // determine value of attribute 'Follow text flow', because positions aligned
2455  // at page areas have to be converted, if it's set.
2456  const bool bFollowTextFlow = _rFrameFormat.GetFollowTextFlow().GetValue();
2457 
2458  // check, if horizontal and vertical position have to be converted due to
2459  // the fact, that the object is anchored at a paragraph, which has a "column
2460  // break before" attribute
2461  bool bConvDueToAnchoredAtColBreakPara( false );
2462  if ( ( (eAnchor == RndStdIds::FLY_AT_PARA) || (eAnchor == RndStdIds::FLY_AT_CHAR) ) &&
2463  _rFrameFormat.GetAnchor().GetContentAnchor() &&
2464  _rFrameFormat.GetAnchor().GetContentAnchor()->nNode.GetNode().IsTextNode() )
2465  {
2466  SwTextNode& rAnchorTextNode =
2467  dynamic_cast<SwTextNode&>(_rFrameFormat.GetAnchor().GetContentAnchor()->nNode.GetNode());
2468  const SvxFormatBreakItem& rBreak = ItemGet<SvxFormatBreakItem>(rAnchorTextNode, RES_BREAK);
2469  if (rBreak.GetBreak() == SvxBreak::ColumnBefore)
2470  {
2471  bConvDueToAnchoredAtColBreakPara = true;
2472  }
2473  }
2474 
2477  // convert horizontal position, if needed
2478  {
2479 
2480  // determine, if conversion has to be performed due to the position orientation
2481  bool bConvDueToOrientation( false );
2482  {
2483  const sal_Int16 eHOri = _iorHoriOri.GetHoriOrient();
2484  bConvDueToOrientation = eHOri == text::HoriOrientation::LEFT || eHOri == text::HoriOrientation::RIGHT ||
2485  eHOri == text::HoriOrientation::INSIDE || eHOri == text::HoriOrientation::OUTSIDE ||
2486  ( eHOri != text::HoriOrientation::CENTER && _iorHoriOri.IsPosToggle() );
2487  }
2488 
2489  // determine conversion type due to the position relation
2490  if ( bConvDueToAnchoredAtColBreakPara )
2491  {
2492  eHoriConv = sw::WW8AnchorConv::CONV2PG;
2493  }
2494  else if ( _iorHoriOri.IsPosToggle()
2495  && _iorHoriOri.GetHoriOrient() == text::HoriOrientation::RIGHT )
2496  {
2497  eHoriConv = sw::WW8AnchorConv::NO_CONV;
2498  _iorHoriOri.SetHoriOrient( text::HoriOrientation::OUTSIDE );
2499  }
2500  else
2501  {
2502  switch ( _iorHoriOri.GetRelationOrient() )
2503  {
2504  case text::RelOrientation::PAGE_FRAME:
2505  case text::RelOrientation::PAGE_PRINT_AREA:
2506  {
2507  if ( bConvDueToOrientation || bFollowTextFlow )
2508  eHoriConv = sw::WW8AnchorConv::CONV2PG;
2509  }
2510  break;
2511  case text::RelOrientation::PAGE_LEFT:
2512  case text::RelOrientation::PAGE_RIGHT:
2513  {
2514  // relation not supported by WW8. Thus, conversion always needed.
2515  eHoriConv = sw::WW8AnchorConv::CONV2PG;
2516  }
2517  break;
2518  case text::RelOrientation::FRAME:
2519  {
2520  if ( bConvDueToOrientation )
2522  }
2523  break;
2524  case text::RelOrientation::PRINT_AREA:
2525  case text::RelOrientation::FRAME_LEFT:
2526  case text::RelOrientation::FRAME_RIGHT:
2527  {
2528  // relation not supported by WW8. Thus, conversion always needed.
2530  }
2531  break;
2532  case text::RelOrientation::CHAR:
2533  {
2534  if ( bConvDueToOrientation )
2535  eHoriConv = sw::WW8AnchorConv::CONV2CHAR;
2536  }
2537  break;
2538  default:
2539  OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown horizontal relation" );
2540  }
2541  }
2542  }
2543 
2544  // convert vertical position, if needed
2545  {
2546 
2547  // determine, if conversion has to be performed due to the position orientation
2548  bool bConvDueToOrientation( false );
2549  {
2550  const sal_Int16 eVOri = _iorVertOri.GetVertOrient();
2551  bConvDueToOrientation = ( eVOri == text::VertOrientation::TOP ||
2552  eVOri == text::VertOrientation::BOTTOM ||
2553  eVOri == text::VertOrientation::CHAR_TOP ||
2554  eVOri == text::VertOrientation::CHAR_BOTTOM ||
2555  eVOri == text::VertOrientation::CHAR_CENTER ||
2556  eVOri == text::VertOrientation::LINE_TOP ||
2557  eVOri == text::VertOrientation::LINE_BOTTOM ||
2558  eVOri == text::VertOrientation::LINE_CENTER );
2559  }
2560 
2561  // determine conversion type due to the position relation
2562  if ( bConvDueToAnchoredAtColBreakPara )
2563  {
2564  eVertConv = sw::WW8AnchorConv::CONV2PG;
2565  }
2566  else
2567  {
2568  switch ( _iorVertOri.GetRelationOrient() )
2569  {
2570  case text::RelOrientation::PAGE_FRAME:
2571  case text::RelOrientation::PAGE_PRINT_AREA:
2572  {
2573  if ( bConvDueToOrientation || bFollowTextFlow )
2574  eVertConv = sw::WW8AnchorConv::CONV2PG;
2575  }
2576  break;
2577  case text::RelOrientation::FRAME:
2578  {
2579  if ( bConvDueToOrientation ||
2580  _iorVertOri.GetVertOrient() == text::VertOrientation::CENTER )
2581  {
2583  }
2584  }
2585  break;
2586  case text::RelOrientation::PRINT_AREA:
2587  {
2588  // relation not supported by WW8. Thus, conversion always needed.
2590  }
2591  break;
2592  case text::RelOrientation::CHAR:
2593  {
2594  // relation not supported by WW8. Thus, conversion always needed.
2596  }
2597  break;
2598  case text::RelOrientation::TEXT_LINE:
2599  {
2600  if ( bConvDueToOrientation ||
2601  _iorVertOri.GetVertOrient() == text::VertOrientation::NONE )
2602  {
2603  eVertConv = sw::WW8AnchorConv::CONV2LINE;
2604  }
2605  }
2606  break;
2607  case text::RelOrientation::PAGE_LEFT:
2608  case text::RelOrientation::PAGE_RIGHT:
2609  case text::RelOrientation::FRAME_LEFT:
2610  case text::RelOrientation::FRAME_RIGHT:
2611  default:
2612  OSL_FAIL( "<WinwordAnchoring::ConvertPosition(..)> - unknown vertical relation" );
2613  }
2614  }
2615 
2616  }
2617  if (eVertConv != sw::WW8AnchorConv::NO_CONV || eHoriConv != sw::WW8AnchorConv::NO_CONV)
2618  {
2619  sw::WW8AnchorConvResult aResult(eHoriConv, eVertConv);
2620  _rFrameFormat.CallSwClientNotify(sw::WW8AnchorConvHint(aResult));
2621  if(!aResult.m_bConverted)
2622  return false;
2623  if (eHoriConv != sw::WW8AnchorConv::NO_CONV)
2624  {
2625  lcl_SetRelationOrient(_iorHoriOri, eHoriConv, [&_iorHoriOri]() {_iorHoriOri.SetHoriOrient(text::HoriOrientation::NONE);} );
2626  _iorHoriOri.SetPos(aResult.m_aPos.X());
2627  }
2628  if (eVertConv != sw::WW8AnchorConv::NO_CONV)
2629  {
2630  lcl_SetRelationOrient(_iorVertOri, eVertConv, [&_iorVertOri]() {_iorVertOri.SetVertOrient(text::VertOrientation::NONE);} );
2631  _iorVertOri.SetPos(aResult.m_aPos.Y());
2632  }
2633  return true;
2634  }
2635  return false;
2636 }
2637 
2639 {
2640  const RndStdIds eAnchor = rFormat.GetAnchor().GetAnchorId();
2641  mbInline = (eAnchor == RndStdIds::FLY_AS_CHAR);
2642 
2643  SwFormatHoriOrient rHoriOri = rFormat.GetHoriOrient();
2644  SwFormatVertOrient rVertOri = rFormat.GetVertOrient();
2645 
2646  // #i30669# - convert the positioning attributes.
2647  // Most positions are converted, if layout information exists.
2648  const bool bPosConverted = ConvertPosition( rHoriOri, rVertOri, rFormat );
2649 
2650  const sal_Int16 eHOri = rHoriOri.GetHoriOrient();
2651  const sal_Int16 eVOri = rVertOri.GetVertOrient(); // #i22673#
2652 
2653  const sal_Int16 eHRel = rHoriOri.GetRelationOrient();
2654  const sal_Int16 eVRel = rVertOri.GetRelationOrient();
2655 
2656  // horizontal Adjustment
2657  switch (eHOri)
2658  {
2659  default:
2661  mnXAlign = 0;
2662  break;
2664  mnXAlign = 1;
2665  break;
2666  case text::HoriOrientation::CENTER:
2667  mnXAlign = 2;
2668  break;
2670  mnXAlign = 3;
2671  break;
2672  case text::HoriOrientation::INSIDE:
2673  mnXAlign = 4;
2674  break;
2675  case text::HoriOrientation::OUTSIDE:
2676  mnXAlign = 5;
2677  break;
2678  }
2679 
2680  // vertical Adjustment
2681  // #i22673#
2682  // When adjustment is vertically relative to line or to char
2683  // bottom becomes top and vice versa
2684  const bool bVertSwap = !bPosConverted &&
2685  ( (eVRel == text::RelOrientation::CHAR) ||
2686  (eVRel == text::RelOrientation::TEXT_LINE) );
2687  switch (eVOri)
2688  {
2689  default:
2691  mnYAlign = 0;
2692  break;
2694  case text::VertOrientation::LINE_TOP:
2695  case text::VertOrientation::CHAR_TOP:
2696  mnYAlign = bVertSwap ? 3 : 1;
2697  break;
2698  case text::VertOrientation::CENTER:
2699  case text::VertOrientation::LINE_CENTER:
2700  mnYAlign = 2;
2701  break;
2703  case text::VertOrientation::LINE_BOTTOM:
2704  case text::VertOrientation::CHAR_BOTTOM:
2705  mnYAlign = bVertSwap ? 1 : 3;
2706  break;
2707  }
2708 
2709  // Adjustment is horizontally relative to...
2710  switch (eHRel)
2711  {
2712  case text::RelOrientation::PAGE_PRINT_AREA:
2713  mnXRelTo = 0;
2714  break;
2715  case text::RelOrientation::PAGE_FRAME:
2716  case text::RelOrientation::PAGE_LEFT: //:-(
2717  case text::RelOrientation::PAGE_RIGHT: //:-(
2718  mnXRelTo = 1;
2719  break;
2720  case text::RelOrientation::FRAME:
2721  case text::RelOrientation::FRAME_LEFT: //:-(
2722  case text::RelOrientation::FRAME_RIGHT: //:-(
2723  if (eAnchor == RndStdIds::FLY_AT_PAGE)
2724  mnXRelTo = 1;
2725  else
2726  mnXRelTo = 2;
2727  break;
2728  case text::RelOrientation::PRINT_AREA:
2729  if (eAnchor == RndStdIds::FLY_AT_PAGE)
2730  mnXRelTo = 0;
2731  else
2732  mnXRelTo = 2;
2733  break;
2734  case text::RelOrientation::CHAR:
2735  mnXRelTo = 3;
2736  break;
2737  case text::RelOrientation::TEXT_LINE:
2738  break;
2739  }
2740 
2741  // Adjustment is vertically relative to...
2742  switch (eVRel)
2743  {
2744  case text::RelOrientation::PAGE_PRINT_AREA:
2745  mnYRelTo = 0;
2746  break;
2747  case text::RelOrientation::PAGE_FRAME:
2748  mnYRelTo = 1;
2749  break;
2750  case text::RelOrientation::PRINT_AREA:
2751  if (eAnchor == RndStdIds::FLY_AT_PAGE)
2752  mnYRelTo = 0;
2753  else
2754  mnYRelTo = 2;
2755  break;
2756  case text::RelOrientation::FRAME:
2757  if (eAnchor == RndStdIds::FLY_AT_PAGE)
2758  mnYRelTo = 1;
2759  else
2760  mnYRelTo = 2;
2761  break;
2762  case text::RelOrientation::CHAR:
2763  case text::RelOrientation::TEXT_LINE: // #i22673# - vertical alignment at top of line
2764  case text::RelOrientation::PAGE_LEFT: //nonsense
2765  case text::RelOrientation::PAGE_RIGHT: //nonsense
2766  case text::RelOrientation::FRAME_LEFT: //nonsense
2767  case text::RelOrientation::FRAME_RIGHT: //nonsense
2768  mnYRelTo = 3;
2769  break;
2770  }
2771 }
2772 
2774 {
2777 
2779  GetStream().WriteInt32( 0 );
2780 
2782  GetStream().WriteInt32( 1 );
2783 }
2784 
2785 sal_Int32 SwEscherEx::WriteFlyFrame(const DrawObj &rObj, sal_uInt32 &rShapeId,
2786  DrawObjPointerVector &rPVec)
2787 {
2788  const SwFrameFormat &rFormat = rObj.maContent.GetFrameFormat();
2789 
2790  // check for textflyframe and if it is the first in a Chain
2791  sal_Int32 nBorderThick = 0;
2792  const SwNodeIndex* pNdIdx = rFormat.GetContent().GetContentIdx();
2793  if( pNdIdx )
2794  {
2795  SwNodeIndex aIdx( *pNdIdx, 1 );
2796  switch( aIdx.GetNode().GetNodeType() )
2797  {
2798  case SwNodeType::Grf:
2799  nBorderThick = WriteGrfFlyFrame( rFormat, rShapeId = GenerateShapeId() );
2800  break;
2801  case SwNodeType::Ole:
2802  nBorderThick = WriteOLEFlyFrame( rFormat, rShapeId = GenerateShapeId() );
2803  break;
2804  default:
2805  if (const SdrObject* pObj = rFormat.FindRealSdrObject())
2806  {
2807  // check for the first in a Chain
2808  sal_uInt32 nTextId;
2809  sal_uInt16 nOff = 0;
2810  const SwFrameFormat* pFormat = &rFormat, *pPrev;
2811  while( nullptr != ( pPrev = pFormat->GetChain().GetPrev() ))
2812  {
2813  ++nOff;
2814  pFormat = pPrev;
2815  }
2816 
2817  rShapeId = GetFlyShapeId(rFormat, rObj.mnHdFtIndex, rPVec);
2818  if( !nOff )
2819  {
2820  nTextId = pTextBxs->GetPos( pObj );
2821  if( USHRT_MAX == nTextId )
2822  {
2823  pTextBxs->Append( *pObj, rShapeId );
2824  nTextId = pTextBxs->Count();
2825  }
2826  else
2827  ++nTextId;
2828  }
2829  else
2830  {
2831  const SdrObject* pPrevObj = pFormat->FindRealSdrObject();
2832  nTextId = pTextBxs->GetPos( pPrevObj );
2833  if( USHRT_MAX == nTextId )
2834  {
2835  sal_uInt32 nPrevShapeId =
2836  GetFlyShapeId(*pFormat, rObj.mnHdFtIndex, rPVec);
2837  pTextBxs->Append( *pPrevObj, nPrevShapeId );
2838  nTextId = pTextBxs->Count();
2839  }
2840  else
2841  ++nTextId;
2842  }
2843  nTextId *= 0x10000;
2844  nTextId += nOff;
2845 
2846  nBorderThick = WriteTextFlyFrame(rObj, rShapeId, nTextId, rPVec);
2847  }
2848 
2849  //In browse mode the sdr object doesn't always exist. For example, the
2850  //object is in the hidden header/footer. We save the fmt directly
2851  //in such cases; we copy most of the logic from the block above
2852  const bool bBrowseMode = rFormat.getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE);
2853  if( bBrowseMode && rFormat.GetDoc())
2854  {
2855  if( !rFormat.GetChain().GetPrev() )//obj in header/footer?
2856  {
2857  rShapeId = GetFlyShapeId(rFormat, rObj.mnHdFtIndex, rPVec);
2858  pTextBxs->Append( &rFormat, rShapeId );
2859  sal_uInt32 nTextId = pTextBxs->Count();
2860 
2861  nTextId *= 0x10000;
2862  nBorderThick = WriteTextFlyFrame(rObj, rShapeId, nTextId, rPVec);
2863  }
2864  }
2865 
2866  }
2867  }
2868  return nBorderThick;
2869 }
2870 
2871 static sal_uInt16 FindPos(const SwFrameFormat &rFormat, unsigned int nHdFtIndex,
2872  DrawObjPointerVector &rPVec)
2873 {
2874  auto aIter = std::find_if(rPVec.begin(), rPVec.end(),
2875  [&rFormat, nHdFtIndex](const DrawObj* pObj) {
2876  OSL_ENSURE(pObj, "Impossible");
2877  return pObj &&
2878  nHdFtIndex == pObj->mnHdFtIndex &&
2879  &rFormat == (&pObj->maContent.GetFrameFormat());
2880  });
2881  if (aIter != rPVec.end())
2882  return static_cast< sal_uInt16 >(aIter - rPVec.begin());
2883  return USHRT_MAX;
2884 }
2885 
2886 sal_Int32 SwEscherEx::WriteTextFlyFrame(const DrawObj &rObj, sal_uInt32 nShapeId,
2887  sal_uInt32 nTextBox, DrawObjPointerVector &rPVec)
2888 {
2889  const SwFrameFormat &rFormat = rObj.maContent.GetFrameFormat();
2890  SvxFrameDirection nDirection = rObj.mnDirection;
2891 
2892  sal_Int32 nBorderThick=0;
2894 
2895  AddShape( ESCHER_ShpInst_TextBox, ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty, nShapeId );
2896  EscherPropertyContainer aPropOpt;
2897  aPropOpt.AddOpt(ESCHER_Prop_lTxid, nTextBox);
2898  if (const SwFrameFormat *pNext = rFormat.GetChain().GetNext())
2899  {
2900  sal_uInt16 nPos = FindPos(*pNext, rObj.mnHdFtIndex, rPVec);
2901  if (USHRT_MAX != nPos && aFollowShpIds[nPos])
2902  aPropOpt.AddOpt(ESCHER_Prop_hspNext, aFollowShpIds[nPos]);
2903  }
2904  nBorderThick = WriteFlyFrameAttr( rFormat, mso_sptTextBox, aPropOpt );
2905 
2906  MSO_TextFlow nFlow;
2907 
2908  switch (nDirection)
2909  {
2910  default:
2911  OSL_ENSURE(false, "unknown direction type");
2912  [[fallthrough]];
2913  case SvxFrameDirection::Horizontal_LR_TB:
2914  nFlow=mso_txflHorzN;
2915  break;
2916  case SvxFrameDirection::Horizontal_RL_TB:
2917  nFlow=mso_txflHorzN;
2918  break;
2919  case SvxFrameDirection::Vertical_LR_TB: //not really possible in word
2920  case SvxFrameDirection::Vertical_RL_TB:
2921  nFlow=mso_txflTtoBA;
2922  break;
2923  }
2924  aPropOpt.AddOpt( ESCHER_Prop_txflTextFlow, nFlow );
2925 
2926  aPropOpt.Commit( GetStream() );
2927 
2928  // store anchor attribute
2929  WriteFrameExtraData( rFormat );
2930 
2931  AddAtom( 4, ESCHER_ClientTextbox ); GetStream().WriteUInt32( nTextBox );
2932 
2933  CloseContainer(); // ESCHER_SpContainer
2934  return nBorderThick;
2935 }
2936 
2938  ShapeFlag nShapeFlags, const Graphic &rGraphic, const SdrObject &rObj,
2939  sal_uInt32 nShapeId, const awt::Rectangle* pVisArea )
2940 {
2941  //nShapeFlags == 0xA00 + flips and ole active
2942  AddShape(ESCHER_ShpInst_PictureFrame, nShapeFlags, nShapeId);
2943 
2944  GraphicObject aGraphicObject(rGraphic);
2945  OString aId = aGraphicObject.GetUniqueID();
2946  if (!aId.isEmpty())
2947  {
2948  // SJ: the fourth parameter (VisArea) should be set..
2949  sal_uInt32 nBlibId = mxGlobal->GetBlibID( *QueryPictureStream(), aGraphicObject, pVisArea);
2950  if (nBlibId)
2951  rPropOpt.AddOpt(ESCHER_Prop_pib, nBlibId, true);
2952  }
2953 
2954  SetPicId(rObj, nShapeId, rPropOpt);
2955  rPropOpt.AddOpt( ESCHER_Prop_pictureActive, 0x10000 );
2956 }
2957 
2958 void SwEscherEx::WriteOCXControl( const SwFrameFormat& rFormat, sal_uInt32 nShapeId )
2959 {
2960  const SdrObject* pSdrObj = rFormat.FindRealSdrObject();
2961  if (!pSdrObj)
2962  return;
2963 
2965 
2968  OSL_ENSURE(pModel && pDevice, "no model or device");
2969 
2970  // #i71538# use complete SdrViews
2971  // SdrExchangeView aExchange(pModel, pDevice);
2972  SdrView aExchange(*pModel, pDevice);
2973  const Graphic aGraphic(SdrExchangeView::GetObjGraphic(*pSdrObj));
2974  EscherPropertyContainer aPropOpt;
2975  WriteOLEPicture(aPropOpt,
2976  ShapeFlag::HaveAnchor | ShapeFlag::HaveShapeProperty | ShapeFlag::OLEShape, aGraphic,
2977  *pSdrObj, nShapeId, nullptr );
2978 
2979  WriteFlyFrameAttr( rFormat, mso_sptPictureFrame , aPropOpt );
2980  aPropOpt.Commit( GetStream() );
2981 
2982  // store anchor attribute
2983  WriteFrameExtraData( rFormat );
2984 
2985  CloseContainer(); // ESCHER_SpContainer
2986 
2987 }
2988 
2990  std::vector<DrawObj>& rSrcArr, DrawObjPointerVector&rDstArr)
2991 {
2992  ::lcl_makeZOrderArray(rWrt, rSrcArr, rDstArr);
2993 
2994  //Now set up the follow IDs
2995  aFollowShpIds.clear();
2996 
2997  for (DrawObj* p : rDstArr)
2998  {
2999  const SwFrameFormat &rFormat = p->maContent.GetFrameFormat();
3000  bool bNeedsShapeId = false;
3001 
3002  if (RES_FLYFRMFMT == rFormat.Which())
3003  {
3004  const SwFormatChain &rChain = rFormat.GetChain();
3005  if (rChain.GetPrev() || rChain.GetNext())
3006  bNeedsShapeId = true;
3007  }
3008 
3009  sal_uLong nShapeId = bNeedsShapeId ? GenerateShapeId() : 0;
3010 
3011  aFollowShpIds.push_back(nShapeId);
3012  }
3013 }
3014 
3015 sal_uInt32 SwEscherEx::GetFlyShapeId(const SwFrameFormat& rFormat,
3016  unsigned int nHdFtIndex, DrawObjPointerVector &rpVec)
3017 {
3018  sal_uInt16 nPos = FindPos(rFormat, nHdFtIndex, rpVec);
3019  sal_uInt32 nShapeId;
3020  if (USHRT_MAX != nPos)
3021  {
3022  if (0 == (nShapeId = aFollowShpIds[nPos]))
3023  {
3024  nShapeId = GenerateShapeId();
3025  aFollowShpIds[ nPos ] = nShapeId;
3026  }
3027  }
3028  else
3029  nShapeId = GenerateShapeId();
3030  return nShapeId;
3031 }
3032 
3034  const uno::Reference< drawing::XShape>& xXShapeRef, sal_uInt32 nShapeId )
3035 {
3036  sal_uInt32 nId = 0;
3037  if (SdrObject* pObj = GetSdrObjectFromXShape(xXShapeRef))
3038  {
3039  pTextBxs->Append( *pObj, nShapeId );
3040  nId = pTextBxs->Count();
3041  nId *= 0x10000;
3042  }
3043  return nId;
3044 }
3045 
3047 ::ole::MSConvertOCXControls( pDSh ? pDSh->GetModel() : nullptr ), pPaM( pP ), mnObjectId(0)
3048 {
3049 }
3050 
3051 
3052 // in transitioning away old filter for ole/ocx controls, ReadOCXStream has been made pure virtual in
3053 // filter/source/msocximex.cxx, so.. we need an implementation here
3055  css::uno::Reference< css::drawing::XShape > *pShapeRef,
3056  bool bFloatingCtrl )
3057 {
3058  uno::Reference< form::XFormComponent > xFComp;
3059  bool bRes = oox::ole::MSConvertOCXControls::ReadOCXStorage( rSrc1, xFComp );
3060  if ( bRes && xFComp.is() )
3061  {
3062  css::awt::Size aSz; // not used in import
3063  bRes = InsertControl( xFComp, aSz,pShapeRef,bFloatingCtrl);
3064  }
3065  return bRes;
3066 }
3067 
3069 {
3070  const uno::Reference< awt::XControlModel >& xControlModel =
3071  rFormObj.GetUnoControlModel();
3072 
3073  //Why oh lord do we use so many different units ?
3074  //I think I painted myself into a little bit of a
3075  //corner by trying to use the uno interface for
3076  //controls export
3077  tools::Rectangle aRect = rFormObj.GetLogicRect();
3078  aRect.SetPos(Point(0,0));
3079  awt::Size aSize;
3080  aSize.Width = TWIPS_TO_MM(aRect.Right());
3081  aSize.Height = TWIPS_TO_MM(aRect.Bottom());
3082 
3083  //Open the ObjectPool
3085 
3086  //Create a destination storage for the microsoft control
3087  OUStringBuffer sStorageName;
3088  sal_uInt32 nObjId = ++mnObjectId;
3089  sStorageName.append('_').append( static_cast<sal_Int64>( nObjId ));
3090  tools::SvRef<SotStorage> xOleStg = xObjPool->OpenSotStorage(sStorageName.makeStringAndClear());
3091 
3092  if (!xOleStg.is())
3093  return;
3094 
3095  OUString sUName;
3096  if (!WriteOCXStream( mxModel, xOleStg,xControlModel,aSize,sUName))
3097  return;
3098 
3099  sal_uInt8 aSpecOLE[] =
3100  {
3101  0x03, 0x6a, 0xFF, 0xFF, 0xFF, 0xFF, // sprmCPicLocation
3102  0x0a, 0x08, 1, // sprmCFOLE2
3103  0x55, 0x08, 1, // sprmCFSpec
3104  0x56, 0x08, 1 // sprmCFObj
3105  };
3106  //Set the obj id into the sprmCPicLocation
3107  sal_uInt8 *pData = aSpecOLE+2;
3108  Set_UInt32(pData,nObjId );
3109 
3110  OUString sField = FieldString(ww::eCONTROL) + "Forms." + sUName + ".1 \\s ";
3111 
3112  rWW8Wrt.OutputField(nullptr, ww::eCONTROL, sField,
3114 
3115  rWW8Wrt.m_pChpPlc->AppendFkpEntry(rWW8Wrt.Strm().Tell(),sizeof(aSpecOLE),
3116  aSpecOLE);
3117  rWW8Wrt.WriteChar( 0x1 );
3118  rWW8Wrt.OutputField(nullptr, ww::eCONTROL, OUString(), FieldFlags::End | FieldFlags::Close);
3119 }
3120 
3121 /* 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:1436
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:963
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:1463
SwNoTextNode * GetNoTextNodeFromSwFrameFormat(const SwFrameFormat &rFormat)
Get the SwNoTextNode associated with a SwFrameFormat if here is one.
sal_Int64 GetAspect() const
Definition: ndole.hxx:132
#define RES_URL
Definition: hintids.hxx:216
WW8AnchorConv
Definition: frmfmt.hxx:294
static ShapeFlag AddMirrorFlags(ShapeFlag nFlags, const SwMirrorGrf &rMirror)
Definition: wrtw8esh.cxx:1557
void setHeight(long n)
std::unique_ptr< ww::bytes > pO
Buffer.
Definition: wrtww8.hxx:966
SvStream * pTableStrm
Definition: wrtww8.hxx:968
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
unsigned int GetHdFtIndex() const
Definition: wrtww8.hxx:1111
bool IsSaveRelFSys() const
void OutSwString(const OUString &, sal_Int32 nStt, sal_Int32 nLen)
Definition: wrtww8.cxx:1861
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:523
std::unique_ptr< WW8Fib > pFib
File Information Block.
Definition: wrtww8.hxx:970
virtual AttributeOutputBase & AttrOutput() const override
memory leak #i120098#, to hold the reference to unnamed SotStorage obj
Definition: wrtww8.cxx:3681
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:157
void WriteStringAsPara(const OUString &rText)
Definition: wrtww8.cxx:1804
#define ESCHER_Prop_pictureId
rtl_TextEncoding GetNodeCharSet() const
Definition: wrtww8.hxx:1465
#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
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const SfxItemPool * pEditPool
Definition: wrtww8.hxx:1431
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:2958
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:2871
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:1435
const GraphicObject * GetGraphicObject(OUString const &referer=OUString()) const
const EditTextObject * pEditObj
Definition: wrtww8.hxx:1430
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:2114
#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:1820
void addListboxEntry(const OUString &rEntry)
Definition: WW8FFData.cxx:64
void SetAnchoring(const SwFrameFormat &rFormat)
Definition: wrtw8esh.cxx:2638
tools::Polygon CorrectWordWrapPolygonForExport(const tools::PolyPolygon &rPolyPoly, const SwNoTextNode *pNd)
Undo all scaling / move tricks of the wrap polygon done during import.
WW8_CP Fc2Cp(sal_uLong nFc) const
Definition: wrtww8.hxx:1080
virtual void AddShape(sal_uInt32 nShpInstance, ShapeFlag nFlagIds, sal_uInt32 nShapeID=0)
#define RES_CHRATR_CJK_FONTSIZE
Definition: hintids.hxx:91
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
std::unique_ptr< WW8_WrPlcField > m_pFieldTextBxs
Definition: wrtww8.hxx:522
void Set_UInt32(sal_uInt8 *&p, sal_uInt32 n)
Definition: ww8struc.hxx: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:1427
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:2773
#define RES_TXTATR_END
Definition: hintids.hxx:158
std::shared_ptr< EscherExGlobal > mxGlobal
const SfxItemSet * GetCurItemSet() const
Getter for pISet.
Definition: wrtww8.hxx:709
#define ESCHER_ClientTextbox
css::chart::ChartAxisLabelPosition ePos
OUString FieldString(ww::eField eIndex)
Definition: ww8atr.cxx:2580
long NormAngle36000(long a)
std::shared_ptr< SvxBrushItem > TrueFrameBgBrush(const SwFrameFormat &rFlyFormat) const
Definition: wrtw8nds.cxx:1646
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:1811
virtual void SetPicId(const SdrObject &, sal_uInt32, EscherPropertyContainer &)
Definition: wrtw8esh.cxx:1806
#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:2442
mso_lineThickThin
mso_sptPictureFrame
#define ESCHER_Prop_dxWrapDistLeft
SvStream & GetStream() const
SwEscherEx * m_pEscher
Definition: wrtww8.hxx:536
constexpr::Color COL_TRANSPARENT(0xFF, 0xFF, 0xFF, 0xFF)
virtual sal_uInt32 QueryTextID(const css::uno::Reference< css::drawing::XShape > &, sal_uInt32) override
Definition: wrtw8esh.cxx:3033
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:1934
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:1735
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:89
SwNodeType GetNodeType() const
Definition: node.hxx:144
MSWordExportBase & m_rExport
Definition: wrtww8.hxx:1417
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:3046
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:34
#define DFF_msofbtUDefProp
#define RES_GRFATR_LUMINANCE
Definition: hintids.hxx:243
const SvxBrushItem * GetCurrentPageBgBrush() const
Definition: wrtw8nds.cxx:1627
sal_Int32 SearchNext(sal_Int32 nStartPos)
Definition: wrtw8esh.cxx:1062
bool m_bInWriteEscher
Definition: wrtww8.hxx:551
void SetClientData(EscherExClientRecord_Base *p)
GraphicDrawMode
#define RES_UL_SPACE
Definition: hintids.hxx:197
bool Append(WW8Export const &, WW8_CP nCp, const ww8::Frame &rFormat, const Point &rNdTopLeft)
Definition: wrtw8esh.cxx: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:533
void WriteChar(sal_Unicode c) override
Definition: wrtww8.cxx:1898
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:1879
WW8_WrPlcTextBoxes * m_pTextBxs
Definition: wrtww8.hxx:497
SdrLayerID GetInvisibleHellId() const
Definition: wrtw8esh.cxx:2222
static sal_Int32 ToFract16(sal_Int32 nVal, sal_uInt32 nMax)
Definition: wrtw8esh.cxx:2201
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:5131
#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:3068
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:1437
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:491
const SwFormatFollowTextFlow & GetFollowTextFlow(bool=true) const
const EditTextObject & GetTextObject() const
OBJ_LINE
Style of a layout element.
Definition: frmfmt.hxx:57
void setName(const OUString &rName)
Definition: WW8FFData.hxx:75
#define ESCHER_Prop_pictureContrast
#define SAL_MAX_INT32
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetCurItemSet(const SfxItemSet *pS)
Setter for pISet.
Definition: wrtww8.hxx:712
EscherExHostAppData aHostData
Definition: escher.hxx:144
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
sal_uInt8 const mnTyp
Definition: wrtww8.hxx:1440
#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:875
#define STREAM_SEEK_TO_BEGIN
#define ESCHER_Prop_dxWrapDistRight
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void WritePictures() override
Definition: wrtw8esh.cxx:1496
sal_uInt32 mnXRelTo
Definition: escher.hxx:73
const SwModify * m_pOutFormatNode
Definition: wrtww8.hxx:530
ESCHER_BlipFlagLinkToFile
OUString sName
#define EE_FEATURE_FIELD
void SetSize(const Size &rSize)
int i
sal_uInt16 GetPos(const void *p) const
Definition: wrtww8.hxx:1277
std::vector< rtl_TextEncoding > aChrSetArr
Definition: wrtww8.hxx:1434
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:937
const SfxPoolItem * NextItem()
const Fraction & X() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
void FinishEscher()
Definition: wrtw8esh.cxx:2380
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
rtl_TextEncoding eNdChrSet
Definition: wrtww8.hxx:1438
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:784
virtual bool InsertControl(const css::uno::Reference< css::form::XFormComponent > &rFComp, const css::awt::Size &rSize, css::uno::Reference< css::drawing::XShape > *pShape, bool bFloatingCtrl) override
Definition: ww8par3.cxx:2517
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:68
long Bottom() const
void MiserableRTLFrameFormatHack(SwTwips &rLeft, SwTwips &rRight, const ww8::Frame &rFrameFormat)
Nasty swap for bidi if necessary.
Definition: wrtw8esh.cxx: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
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:1888
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:398
void setType(sal_uInt8 nType)
Definition: WW8FFData.hxx:71
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:31
#define DFF_Prop_pWrapPolygonVertices
sal_uInt16 GetSize() const
ESCHER_FillPicture
Marks a node in the document model.
Definition: ndindex.hxx:31
sal_uInt32 GetFlyShapeId(const SwFrameFormat &rFormat, unsigned int nHdFtIndex, DrawObjPointerVector &rPVec)
Definition: wrtw8esh.cxx:3015
SwWW8Writer & GetWriter() const
Definition: wrtww8.hxx:1155
#define RES_UNKNOWNATR_BEGIN
Definition: hintids.hxx:266
MapUnit GetMapUnit() const
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
sal_Int32 WriteFlyFrame(const DrawObj &rObj, sal_uInt32 &rShapeId, DrawObjPointerVector &rPVec)
Definition: wrtw8esh.cxx:2785
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:759
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:534
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:2376
std::size_t ReadBytes(void *pData, std::size_t nSize)
Point PixelToLogic(const Point &rDevicePt) const
Size GetPrefSize() const
#define ESCHER_Prop_dxTextLeft
WW8_WrPlcTextBoxes * m_pHFTextBxs
Definition: wrtww8.hxx:497
sal_Int32 GetBottom() const
#define ESCHER_Prop_fillColor
const SwMirrorGrf & GetMirrorGrf(bool=true) const
Definition: grfatr.hxx:280
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
SVX_DLLPUBLIC SdrObject * GetSdrObjectFromXShape(const css::uno::Reference< css::drawing::XShape > &xShape)
WW8_CP m_ccpEdn
Definition: ww8scan.hxx: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:1699
SotStorage & GetStorage() const
Definition: shellio.hxx:493
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:2989
sal_Int32 GetDenominator() const
SvStream & Strm() const
Definition: wrtww8.hxx:1156
sal_Int16 GetRelationOrient() const
Definition: fmtornt.hxx:88
void AddAtom(sal_uInt32 nAtomSitze, sal_uInt16 nRecType, int nRecVersion=0, int nRecInstance=0)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
MapMode GetPrefMapMode() const
#define ESCHER_ShpInst_Rectangle
unsigned char sal_uInt8
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Make exporting a Writer Frame easy.
virtual void WriteFrameExtraData(const SwFrameFormat &)
Definition: wrtw8esh.cxx: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:1439
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:1432
virtual void WritePictures()
Definition: wrtw8esh.cxx:2227
void SetEndian(SvStreamEndian SvStreamEndian)
MSO_TextFlow
bool HasMark() const
INetProtocol GetProtocol() const
MSWord_SdrAttrIter(const MSWord_SdrAttrIter &)=delete
#define ESCHER_Prop_fillType
SvxBoxItemLine
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
virtual sal_uInt32 EnterGroup(const OUString &rShapeName, const tools::Rectangle *pBoundRect)
MSO_LineStyle
mso_txflTtoBA
#define TWIPS_TO_MM(val)
sal_uInt8 m_nTextTyp
Definition: wrtww8.hxx:540
void WriteSdrTextObj(const SdrTextObj &rObj, sal_uInt8 nTyp)
Definition: wrtw8esh.cxx: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:379
WW8_CP m_ccpText
Definition: ww8scan.hxx:1204
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
sal_uInt16 Count() const
Definition: wrtww8.hxx:1276
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:1433
bool m_bFontSizeWritten
Is font size written already as part of the current character properties?
Definition: wrtww8.hxx:564
SwEscherEx(SvStream *pStrm, WW8Export &rWW8Wrt)
Definition: wrtw8esh.cxx:2240
sal_Int32 WriteGrfFlyFrame(const SwFrameFormat &rFormat, sal_uInt32 nShapeId)
Definition: wrtw8esh.cxx:1625
SdrLayerID GetHellLayerId() const
ESCHER_BlipFlagURL
MapUnit
void CreateEscher()
Definition: wrtw8esh.cxx:1467
Base class for WW8Export and DocxExport.
Definition: wrtww8.hxx:452
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:3054
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:2937
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:1410
static void WriteLong(SvStream &rStrm, sal_Int32 nVal)
Definition: wrtww8.hxx:940
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:492
sal_uInt16 Which() const
SvxFrameDirection TrueFrameDirection(const SwFrameFormat &rFlyFormat) const
Right to left?
Definition: wrtw8nds.cxx:1594
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:2886
SwDoc * m_pDoc
Definition: wrtww8.hxx:567
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:1307
#define ESCHER_ClientData
#define ESCHER_Prop_pihlShape
const SvxFieldData * GetField() const
virtual const tools::Rectangle & GetLogicRect() const override
sal_uInt16 GetWidth() const
const OUString & GetURL() const
Definition: fmturl.hxx:66
SvxShadowLocation
#define ESCHER_Prop_dxTextRight
EnumT GetValue() const