LibreOffice Module sw (master)  1
docxexport.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 "docxexport.hxx"
21 #include "docxexportfilter.hxx"
22 #include "docxattributeoutput.hxx"
23 #include "docxsdrexport.hxx"
24 #include "docxhelper.hxx"
25 
26 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
27 #include <com/sun/star/document/XDocumentProperties.hpp>
28 #include <com/sun/star/document/XStorageBasedDocument.hpp>
29 #include <com/sun/star/drawing/XShape.hpp>
30 #include <com/sun/star/i18n/ScriptType.hpp>
31 #include <com/sun/star/frame/XModel.hpp>
32 #include <com/sun/star/xml/dom/XDocument.hpp>
33 #include <com/sun/star/xml/sax/XSAXSerializable.hpp>
34 #include <com/sun/star/xml/sax/Writer.hpp>
35 #include <com/sun/star/awt/XControlModel.hpp>
36 #include <com/sun/star/sdb/CommandType.hpp>
37 
38 #include <oox/token/namespaces.hxx>
39 #include <oox/token/tokens.hxx>
40 #include <oox/export/drawingml.hxx>
41 #include <oox/export/vmlexport.hxx>
43 #include <oox/export/shapes.hxx>
47 #include <oox/ole/olestorage.hxx>
48 #include <oox/ole/olehelper.hxx>
49 
50 #include <map>
51 #include <algorithm>
52 
53 #include <IMark.hxx>
57 #include <docsh.hxx>
58 #include <ndtxt.hxx>
59 #include "wrtww8.hxx"
60 #include <fltini.hxx>
61 #include <fmtline.hxx>
62 #include <fmtpdsc.hxx>
63 #include <frmfmt.hxx>
64 #include <section.hxx>
65 #include <ftninfo.hxx>
66 #include <pagedesc.hxx>
67 #include <poolfmt.hxx>
68 #include <swdbdata.hxx>
69 
70 #include <editeng/unoprnms.hxx>
71 #include <editeng/editobj.hxx>
72 #include <editeng/outlobj.hxx>
73 #include <editeng/brushitem.hxx>
75 
76 #include <docary.hxx>
77 #include <numrule.hxx>
78 #include <charfmt.hxx>
79 #include <viewsh.hxx>
80 #include <viewopt.hxx>
81 
82 #include "ww8par.hxx"
83 #include "ww8scan.hxx"
84 #include <oox/token/properties.hxx>
86 #include <comphelper/sequence.hxx>
88 #include <rtl/ustrbuf.hxx>
89 #include <sal/log.hxx>
90 #include <vcl/font.hxx>
92 #include <tools/diagnose_ex.h>
93 
94 using namespace sax_fastparser;
95 using namespace ::comphelper;
96 using namespace ::com::sun::star;
97 using namespace ::oox;
98 
100 
101 using sw::mark::IMark;
102 
104 {
105  return *m_pAttrOutput;
106 }
107 
109 {
110  return *m_pAttrOutput;
111 }
112 
114 {
115  return *m_pSections;
116 }
117 
118 bool DocxExport::CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich )
119 {
120  // TODO FIXME is this actually true for docx? - this is ~copied from WW8
121  if ( nScript == i18n::ScriptType::ASIAN )
122  {
123  // for asian in ww8, there is only one fontsize
124  // and one fontstyle (posture/weight)
125  switch ( nWhich )
126  {
127  case RES_CHRATR_FONTSIZE:
128  case RES_CHRATR_POSTURE:
129  case RES_CHRATR_WEIGHT:
130  return false;
131  default:
132  break;
133  }
134  }
135  else if ( nScript != i18n::ScriptType::COMPLEX )
136  {
137  // for western in ww8, there is only one fontsize
138  // and one fontstyle (posture/weight)
139  switch ( nWhich )
140  {
144  return false;
145  default:
146  break;
147  }
148  }
149  return true;
150 }
151 
152 void DocxExport::AppendBookmarks( const SwTextNode& rNode, sal_Int32 nCurrentPos, sal_Int32 nLen )
153 {
154  std::vector< OUString > aStarts;
155  std::vector< OUString > aEnds;
156 
157  IMarkVector aMarks;
158  if ( GetBookmarks( rNode, nCurrentPos, nCurrentPos + nLen, aMarks ) )
159  {
160  for ( IMark* pMark : aMarks )
161  {
162  const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
163  const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
164 
165  if (dynamic_cast<sw::mark::IDateFieldmark*>(pMark))
166  continue;
167 
168  if ( nStart == nCurrentPos )
169  aStarts.push_back( pMark->GetName() );
170 
171  if ( nEnd == nCurrentPos )
172  aEnds.push_back( pMark->GetName() );
173  }
174  }
175 
176  const OUString& aStr( rNode.GetText() );
177  const sal_Int32 nEnd = aStr.getLength();
178 
179  if ( nCurrentPos == nEnd )
180  m_pAttrOutput->WriteFinalBookmarks_Impl( aStarts, aEnds );
181  else
182  m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds );
183 }
184 
185 void DocxExport::AppendBookmark( const OUString& rName )
186 {
187  std::vector< OUString > aStarts;
188  std::vector< OUString > aEnds;
189 
190  aStarts.push_back( rName );
191  aEnds.push_back( rName );
192 
193  m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds );
194 }
195 
196 void DocxExport::AppendAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen )
197 {
198  std::vector< OUString > aStarts;
199  std::vector< OUString > aEnds;
200 
201  IMarkVector aMarks;
202  if (GetAnnotationMarks(rAttrs, nCurrentPos, nCurrentPos + nLen, aMarks))
203  {
204  for ( IMark* pMark : aMarks )
205  {
206  const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
207  const sal_Int32 nEnd = pMark->GetMarkEnd().nContent.GetIndex();
208 
209  if ( nStart == nCurrentPos )
210  aStarts.push_back( pMark->GetName() );
211 
212  if ( nEnd == nCurrentPos )
213  aEnds.push_back( pMark->GetName() );
214  }
215  }
216 
217  m_pAttrOutput->WriteAnnotationMarks_Impl( aStarts, aEnds );
218 }
219 
221 {
222  // Just collect the bullets for now, numbering.xml is not yet started.
223  CollectGrfsOfBullets();
224 }
225 
226 OString DocxExport::AddRelation( const OUString& rType, const OUString& rTarget )
227 {
228  OUString sId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
229  rType, rTarget, true );
230 
231  return sId.toUtf8();
232 }
233 
235 {
236  bool bRet( false );
237 
238  if (SfxItemState::SET != rFormat.GetItemState(RES_PARATR_NUMRULE, false))
239  {
240  if (const SwFormat *pParent = rFormat.DerivedFrom())
241  {
242  if (static_cast<const SwTextFormatColl*>(pParent)->IsAssignedToListLevelOfOutlineStyle())
243  {
244  ::sax_fastparser::FSHelperPtr pSerializer = m_pAttrOutput->GetSerializer( );
245  // Level 9 disables the outline
246  pSerializer->singleElementNS(XML_w, XML_outlineLvl, FSNS(XML_w, XML_val), "9");
247 
248  bRet = true;
249  }
250  }
251  }
252 
253  return bRet;
254 }
255 
257  const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode )
258 {
259  m_nHeadersFootersInSection = 1;
260 
261  // document setting indicating the requirement of EVEN and ODD for both headers and footers
263  m_aSettings.evenAndOddHeaders = true;
264 
265  // Turn ON flag for 'Writing Headers \ Footers'
266  m_pAttrOutput->SetWritingHeaderFooter( true );
267 
268  // headers
269  if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN )
270  WriteHeaderFooter( &rLeftFormat, true, "even" );
271  else if ( m_aSettings.evenAndOddHeaders )
272  {
273  if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD )
274  WriteHeaderFooter( &rFormat, true, "even" );
275  else if ( m_bHasHdr && nBreakCode == 2 )
276  WriteHeaderFooter( nullptr, true, "even" );
277  }
278 
279  if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD )
280  WriteHeaderFooter( &rFormat, true, "default" );
281 
282  if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_FIRST )
283  WriteHeaderFooter( &rFirstPageFormat, true, "first" );
284 
285  if( (nHeadFootFlags & (nsHdFtFlags::WW8_HEADER_EVEN
286  | nsHdFtFlags::WW8_HEADER_ODD
287  | nsHdFtFlags::WW8_HEADER_FIRST)) == 0
288  && m_bHasHdr && nBreakCode == 2 ) // 2: nexPage
289  WriteHeaderFooter( nullptr, true, "default" );
290 
291 
292  // footers
293  if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN )
294  WriteHeaderFooter( &rLeftFormat, false, "even" );
295  else if ( m_aSettings.evenAndOddHeaders )
296  {
297  if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD )
298  WriteHeaderFooter( &rFormat, false, "even" );
299  else if ( m_bHasFtr && nBreakCode == 2 )
300  WriteHeaderFooter( nullptr, false, "even");
301  }
302 
303  if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD )
304  WriteHeaderFooter( &rFormat, false, "default" );
305 
306  if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_FIRST )
307  WriteHeaderFooter( &rFirstPageFormat, false, "first" );
308 
309  if( (nHeadFootFlags & (nsHdFtFlags::WW8_FOOTER_EVEN
310  | nsHdFtFlags::WW8_FOOTER_ODD
311  | nsHdFtFlags::WW8_FOOTER_FIRST)) == 0
312  && m_bHasFtr && nBreakCode == 2 ) // 2: nexPage
313  WriteHeaderFooter( nullptr, false, "default");
314 
315  // Turn OFF flag for 'Writing Headers \ Footers'
316  m_pAttrOutput->SetWritingHeaderFooter( false );
317 }
318 
319 void DocxExport::OutputField( const SwField* pField, ww::eField eFieldType, const OUString& rFieldCmd, FieldFlags nMode )
320 {
321  m_pAttrOutput->WriteField_Impl( pField, eFieldType, rFieldCmd, nMode );
322 }
323 
324 void DocxExport::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
325 {
326  m_pAttrOutput->WriteFormData_Impl( rFieldmark );
327 }
328 
329 void DocxExport::WriteHyperlinkData( const ::sw::mark::IFieldmark& /*rFieldmark*/ )
330 {
331 #if OSL_DEBUG_LEVEL > 1
332  fprintf( stderr, "TODO DocxExport::WriteHyperlinkData()\n" );
333 #endif
334 }
335 
336 void DocxExport::DoComboBox(const OUString& rName,
337  const OUString& rHelp,
338  const OUString& rToolTip,
339  const OUString& rSelected,
340  uno::Sequence<OUString>& rListItems)
341 {
342  m_pDocumentFS->startElementNS(XML_w, XML_ffData);
343 
344  m_pDocumentFS->singleElementNS(XML_w, XML_name, FSNS(XML_w, XML_val), rName.toUtf8());
345 
346  m_pDocumentFS->singleElementNS(XML_w, XML_enabled);
347 
348  if ( !rHelp.isEmpty() )
349  m_pDocumentFS->singleElementNS(XML_w, XML_helpText, FSNS(XML_w, XML_val), rHelp.toUtf8());
350 
351  if ( !rToolTip.isEmpty() )
352  m_pDocumentFS->singleElementNS( XML_w, XML_statusText,
353  FSNS( XML_w, XML_val ), rToolTip.toUtf8() );
354 
355  m_pDocumentFS->startElementNS(XML_w, XML_ddList);
356 
357  // Output the 0-based index of the selected value
358  sal_Int32 nId = comphelper::findValue(rListItems, rSelected);
359  if (nId == -1)
360  nId = 0;
361 
362  m_pDocumentFS->singleElementNS(XML_w, XML_result, FSNS(XML_w, XML_val), OString::number(nId));
363 
364  // Loop over the entries
365 
366  for (const auto& rItem : rListItems)
367  {
368  m_pDocumentFS->singleElementNS( XML_w, XML_listEntry,
369  FSNS( XML_w, XML_val ), rItem.toUtf8() );
370  }
371 
372  m_pDocumentFS->endElementNS( XML_w, XML_ddList );
373 
374  m_pDocumentFS->endElementNS( XML_w, XML_ffData );
375 }
376 
378 {
379  assert(pField);
380  const OUString sStr = FieldString(ww::eFILLIN) + "\"" + pField->GetPar2() + "\"";
381  OutputField(pField, ww::eFILLIN, sStr);
382 }
383 
384 OString DocxExport::OutputChart( uno::Reference< frame::XModel > const & xModel, sal_Int32 nCount, ::sax_fastparser::FSHelperPtr const & m_pSerializer )
385 {
386  OUString aFileName = "charts/chart" + OUString::number(nCount) + ".xml";
387  OUString sId = m_pFilter->addRelation( m_pSerializer->getOutputStream(),
388  oox::getRelationship(Relationship::CHART),
389  aFileName );
390  aFileName = "word/charts/chart" + OUString::number(nCount) + ".xml";
392  m_pFilter->openFragmentStreamWithSerializer( aFileName,
393  "application/vnd.openxmlformats-officedocument.drawingml.chart+xml" );
394 
395  oox::drawingml::ChartExport aChartExport(XML_w, pChartFS, xModel, m_pFilter, oox::drawingml::DOCUMENT_DOCX);
396  aChartExport.ExportContent();
397  return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
398 }
399 
400 OString DocxExport::WriteOLEObject(SwOLEObj& rObject, OUString & io_rProgID)
401 {
402  uno::Reference <embed::XEmbeddedObject> xObj( rObject.GetOleRef() );
403  uno::Reference<uno::XComponentContext> const xContext(
404  GetFilter().getComponentContext());
405 
406  OUString sMediaType;
407  OUString sRelationType;
408  OUString sSuffix;
409  const char * pProgID(nullptr);
410 
411  uno::Reference<io::XInputStream> const xInStream =
412  oox::GetOLEObjectStream(xContext, xObj, io_rProgID,
413  sMediaType, sRelationType, sSuffix, pProgID);
414 
415  if (!xInStream.is())
416  {
417  return OString();
418  }
419 
420  assert(!sMediaType.isEmpty());
421  assert(!sRelationType.isEmpty());
422  assert(!sSuffix.isEmpty());
423  OUString sFileName = "embeddings/oleObject" + OUString::number( ++m_nOLEObjects ) + "." + sSuffix;
424  uno::Reference<io::XOutputStream> const xOutStream =
425  GetFilter().openFragmentStream("word/" + sFileName, sMediaType);
426  assert(xOutStream.is()); // no reason why that could fail
427 
428  try
429  {
431  }
432  catch (uno::Exception const&)
433  {
434  TOOLS_WARN_EXCEPTION("sw.ww8", "DocxExport::WriteOLEObject");
435  return OString();
436  }
437 
438  OUString const sId = m_pFilter->addRelation( GetFS()->getOutputStream(),
439  sRelationType, sFileName );
440  if (pProgID)
441  {
442  io_rProgID = OUString::createFromAscii(pProgID);
443  }
444 
445  return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
446 }
447 
448 std::pair<OString, OString> DocxExport::WriteActiveXObject(const uno::Reference<drawing::XShape>& rxShape,
449  const uno::Reference<awt::XControlModel>& rxControlModel)
450 {
451  ++m_nActiveXControls;
452 
453  // Write out ActiveX binary
454  const OUString sBinaryFileName = "word/activeX/activeX" + OUString::number(m_nActiveXControls) + ".bin";
455 
456  OString sGUID;
457  OString sName;
458  uno::Reference<io::XStream> xOutStorage(m_pFilter->openFragmentStream(sBinaryFileName, "application/vnd.ms-office.activeX"), uno::UNO_QUERY);
459  if(xOutStorage.is())
460  {
461  oox::ole::OleStorage aOleStorage(m_pFilter->getComponentContext(), xOutStorage, false);
462  uno::Reference<io::XOutputStream> xOutputStream(aOleStorage.openOutputStream("contents"), uno::UNO_SET_THROW);
463  uno::Reference< css::frame::XModel > xModel( m_pDoc->GetDocShell() ? m_pDoc->GetDocShell()->GetModel() : nullptr );
465  if ( !exportHelper.isValid() )
466  return std::make_pair<OString, OString>(OString(), OString());
467  sGUID = OUStringToOString(exportHelper.getGUID(), RTL_TEXTENCODING_UTF8);
468  sName = OUStringToOString(exportHelper.getName(), RTL_TEXTENCODING_UTF8);
469  exportHelper.exportControl(xOutputStream, rxShape->getSize(), true);
470  aOleStorage.commit();
471  }
472 
473  // Write out ActiveX fragment
474  const OUString sXMLFileName = "word/activeX/activeX" + OUString::number( m_nActiveXControls ) + ".xml";
475  ::sax_fastparser::FSHelperPtr pActiveXFS = m_pFilter->openFragmentStreamWithSerializer(sXMLFileName, "application/vnd.ms-office.activeX+xml" );
476 
477  const OUString sBinaryId = m_pFilter->addRelation( pActiveXFS->getOutputStream(),
478  oox::getRelationship(Relationship::ACTIVEXCONTROLBINARY),
479  sBinaryFileName.copy(sBinaryFileName.lastIndexOf("/") + 1) );
480 
481  pActiveXFS->singleElementNS(XML_ax, XML_ocx,
482  FSNS(XML_xmlns, XML_ax), m_pFilter->getNamespaceURL(OOX_NS(ax)).toUtf8(),
483  FSNS(XML_xmlns, XML_r), m_pFilter->getNamespaceURL(OOX_NS(officeRel)).toUtf8(),
484  FSNS(XML_ax, XML_classid), "{" + sGUID + "}",
485  FSNS(XML_ax, XML_persistence), "persistStorage",
486  FSNS(XML_r, XML_id), sBinaryId.toUtf8());
487 
488  OString sXMLId = OUStringToOString(m_pFilter->addRelation(m_pDocumentFS->getOutputStream(),
489  oox::getRelationship(Relationship::CONTROL),
490  sXMLFileName.copy(sBinaryFileName.indexOf("/") + 1)),
491  RTL_TEXTENCODING_UTF8);
492 
493  return std::pair<OString, OString>(sXMLId, sName);
494 }
495 
496 void DocxExport::OutputDML(uno::Reference<drawing::XShape> const & xShape)
497 {
498  uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY_THROW);
499  sal_Int32 nNamespace = XML_wps;
500  if (xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
501  nNamespace = XML_wpg;
502  else if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
503  nNamespace = XML_pic;
504  oox::drawingml::ShapeExport aExport(nNamespace, m_pAttrOutput->GetSerializer(), nullptr, m_pFilter, oox::drawingml::DOCUMENT_DOCX, m_pAttrOutput.get());
505  aExport.WriteShape(xShape);
506 }
507 
509 {
510  // Set the 'Reviewing' flags in the settings structure
511  m_aSettings.revisionView = m_bOrigShowChanges;
512  m_aSettings.trackRevisions = bool( RedlineFlags::On & m_nOrigRedlineFlags );
513 
514  InitStyles();
515 
516  // init sections
517  m_pSections.reset(new MSWordSections( *this ));
518 
519  // Make sure images are counted from one, even when exporting multiple documents.
521 
522  WriteMainText();
523 
524  WriteFootnotesEndnotes();
525 
526  WritePostitFields();
527 
528  WriteNumbering();
529 
530  WriteFonts();
531 
532  WriteSettings();
533 
534  WriteTheme();
535 
536  WriteGlossary();
537 
538  WriteCustomXml();
539 
540  WriteEmbeddings();
541 
542  WriteVBA();
543 
544  m_aLinkedTextboxesHelper.clear(); //final cleanup
545  m_pStyles.reset();
546  m_pSections.reset();
547 
548  return ERRCODE_NONE;
549 }
550 
551 void DocxExport::AppendSection( const SwPageDesc *pPageDesc, const SwSectionFormat* pFormat, sal_uLong nLnNum )
552 {
553  AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() );
554  m_pSections->AppendSection( pPageDesc, pFormat, nLnNum, m_pAttrOutput->IsFirstParagraph() );
555 }
556 
557 void DocxExport::OutputEndNode( const SwEndNode& rEndNode )
558 {
560 
561  if ( TXT_MAINTEXT == m_nTextTyp && rEndNode.StartOfSectionNode()->IsSectionNode() )
562  {
563  // this originally comes from WW8Export::WriteText(), and looks like it
564  // could have some code common with SectionNode()...
565 
566  const SwSection& rSect = rEndNode.StartOfSectionNode()->GetSectionNode()->GetSection();
567  if ( m_bStartTOX && TOX_CONTENT_SECTION == rSect.GetType() )
568  m_bStartTOX = false;
569 
570  SwNodeIndex aIdx( rEndNode, 1 );
571  const SwNode& rNd = aIdx.GetNode();
572  if ( rNd.IsEndNode() && rNd.StartOfSectionNode()->IsSectionNode() )
573  return;
574 
575  bool isInTable = IsInTable();
576  if ( !rNd.IsSectionNode() && isInTable ) // No sections in table
577  {
578  const SwSectionFormat* pParentFormat = rSect.GetFormat()->GetParent();
579  if( !pParentFormat )
580  pParentFormat = reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1));
581 
582  sal_uLong nRstLnNum;
583  if( rNd.IsContentNode() )
584  nRstLnNum = rNd.GetContentNode()->GetSwAttrSet().GetLineNumber().GetStartValue();
585  else
586  nRstLnNum = 0;
587 
588  AppendSection( m_pCurrentPageDesc, pParentFormat, nRstLnNum );
589  }
590  else
591  {
592  AttrOutput().SectionBreaks( rEndNode );
593  }
594  }
595  else if (TXT_MAINTEXT == m_nTextTyp && rEndNode.StartOfSectionNode()->IsTableNode())
596  // End node of a table: see if a section break should be written after the table.
597  AttrOutput().SectionBreaks(rEndNode);
598 }
599 
601 {
602  SAL_INFO("sw.ww8", "TODO DocxExport::OutputGrfNode( const SwGrfNode& )" );
603 }
604 
606 {
607  SAL_INFO("sw.ww8", "TODO DocxExport::OutputOLENode( const SwOLENode& )" );
608 }
609 
610 void DocxExport::OutputLinkedOLE( const OUString& )
611 {
612  // Nothing to implement here: WW8 only
613 }
614 
616 {
617  // Completely unused for Docx export... only here for code sharing
618  // purpose with binary export
619  return 0;
620 }
621 
623  const SwNode& rNd, const SwFormatPageDesc* pNewPgDescFormat,
624  const SwPageDesc* pNewPgDesc )
625 {
626  // tell the attribute output that we are ready to write the section
627  // break [has to be output inside paragraph properties]
628  AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() );
629 
630  const SwSectionFormat* pFormat = GetSectionFormat( rNd );
631  const sal_uLong nLnNm = GetSectionLineNo( pSet, rNd );
632 
633  OSL_ENSURE( pNewPgDescFormat || pNewPgDesc, "Neither page desc format nor page desc provided." );
634 
635  if ( pNewPgDescFormat )
636  {
637  m_pSections->AppendSection( *pNewPgDescFormat, rNd, pFormat, nLnNm );
638  }
639  else if ( pNewPgDesc )
640  {
641  m_pSections->AppendSection( pNewPgDesc, rNd, pFormat, nLnNm );
642  }
643 
644 }
645 
647 {
648  m_pStyles.reset(new MSWordStyles( *this, /*bListStyles =*/ true ));
649 
650  // setup word/styles.xml and the relations + content type
651  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
652  oox::getRelationship(Relationship::STYLES),
653  "styles.xml" );
654 
656  m_pFilter->openFragmentStreamWithSerializer( "word/styles.xml",
657  "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" );
658 
659  // switch the serializer to redirect the output to word/styles.xml
660  m_pAttrOutput->SetSerializer( pStylesFS );
661 
662  // do the work
663  m_pStyles->OutputStylesTable();
664 
665  // switch the serializer back
666  m_pAttrOutput->SetSerializer( m_pDocumentFS );
667 }
668 
670 {
671  if ( m_pAttrOutput->HasFootnotes() )
672  {
673  // setup word/styles.xml and the relations + content type
674  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
675  oox::getRelationship(Relationship::FOOTNOTES),
676  "footnotes.xml" );
677 
678  ::sax_fastparser::FSHelperPtr pFootnotesFS =
679  m_pFilter->openFragmentStreamWithSerializer( "word/footnotes.xml",
680  "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" );
681 
682  // switch the serializer to redirect the output to word/footnotes.xml
683  m_pAttrOutput->SetSerializer( pFootnotesFS );
684  // tdf#99227
685  m_pSdrExport->setSerializer( pFootnotesFS );
686  // tdf#107969
687  m_pVMLExport->SetFS(pFootnotesFS);
688 
689  // do the work
690  m_pAttrOutput->FootnotesEndnotes( true );
691 
692  // switch the serializer back
693  m_pVMLExport->SetFS(m_pDocumentFS);
694  m_pSdrExport->setSerializer( m_pDocumentFS );
695  m_pAttrOutput->SetSerializer( m_pDocumentFS );
696  }
697 
698  if ( m_pAttrOutput->HasEndnotes() )
699  {
700  // setup word/styles.xml and the relations + content type
701  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
702  oox::getRelationship(Relationship::ENDNOTES),
703  "endnotes.xml" );
704 
705  ::sax_fastparser::FSHelperPtr pEndnotesFS =
706  m_pFilter->openFragmentStreamWithSerializer( "word/endnotes.xml",
707  "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" );
708 
709  // switch the serializer to redirect the output to word/endnotes.xml
710  m_pAttrOutput->SetSerializer( pEndnotesFS );
711  // tdf#99227
712  m_pSdrExport->setSerializer( pEndnotesFS );
713  // tdf#107969
714  m_pVMLExport->SetFS(pEndnotesFS);
715 
716  // do the work
717  m_pAttrOutput->FootnotesEndnotes( false );
718 
719  // switch the serializer back
720  m_pVMLExport->SetFS(m_pDocumentFS);
721  m_pSdrExport->setSerializer( m_pDocumentFS );
722  m_pAttrOutput->SetSerializer( m_pDocumentFS );
723  }
724 }
725 
727 {
728  if ( m_pAttrOutput->HasPostitFields() )
729  {
730  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
731  oox::getRelationship(Relationship::COMMENTS),
732  "comments.xml" );
733 
735  m_pFilter->openFragmentStreamWithSerializer( "word/comments.xml",
736  "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" );
737 
738  pPostitFS->startElementNS( XML_w, XML_comments, MainXmlNamespaces());
739  m_pAttrOutput->SetSerializer( pPostitFS );
740  m_pAttrOutput->WritePostitFields();
741  m_pAttrOutput->SetSerializer( m_pDocumentFS );
742  pPostitFS->endElementNS( XML_w, XML_comments );
743  }
744 }
745 
747 {
748  if ( !m_pUsedNumTable )
749  return; // no numbering is used
750 
751  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
752  oox::getRelationship(Relationship::NUMBERING),
753  "numbering.xml" );
754 
755  ::sax_fastparser::FSHelperPtr pNumberingFS = m_pFilter->openFragmentStreamWithSerializer( "word/numbering.xml",
756  "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" );
757 
758  // switch the serializer to redirect the output to word/numbering.xml
759  m_pAttrOutput->SetSerializer( pNumberingFS );
760  m_pDrawingML->SetFS( pNumberingFS );
761 
762  pNumberingFS->startElementNS( XML_w, XML_numbering,
763  FSNS( XML_xmlns, XML_w ), m_pFilter->getNamespaceURL(OOX_NS(doc)).toUtf8(),
764  FSNS( XML_xmlns, XML_o ), m_pFilter->getNamespaceURL(OOX_NS(vmlOffice)).toUtf8(),
765  FSNS( XML_xmlns, XML_r ), m_pFilter->getNamespaceURL(OOX_NS(officeRel)).toUtf8(),
766  FSNS( XML_xmlns, XML_v ), m_pFilter->getNamespaceURL(OOX_NS(vml)).toUtf8() );
767 
768  BulletDefinitions();
769 
770  AbstractNumberingDefinitions();
771 
772  NumberingDefinitions();
773 
774  pNumberingFS->endElementNS( XML_w, XML_numbering );
775 
776  // switch the serializer back
777  m_pDrawingML->SetFS( m_pDocumentFS );
778  m_pAttrOutput->SetSerializer( m_pDocumentFS );
779 }
780 
781 void DocxExport::WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType )
782 {
783  // setup the xml stream
784  OUString aRelId;
786  if ( bHeader )
787  {
788  OUString aName( "header" + OUString::number( ++m_nHeaders ) + ".xml" );
789 
790  aRelId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
791  oox::getRelationship(Relationship::HEADER),
792  aName );
793 
794  pFS = m_pFilter->openFragmentStreamWithSerializer( "word/" + aName,
795  "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" );
796 
797  pFS->startElementNS( XML_w, XML_hdr, MainXmlNamespaces());
798  }
799  else
800  {
801  OUString aName( "footer" + OUString::number( ++m_nFooters ) + ".xml" );
802 
803  aRelId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
804  oox::getRelationship(Relationship::FOOTER),
805  aName );
806 
807  pFS = m_pFilter->openFragmentStreamWithSerializer( "word/" + aName,
808  "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" );
809 
810  pFS->startElementNS( XML_w, XML_ftr, MainXmlNamespaces());
811  }
812 
813  // switch the serializer to redirect the output to word/styles.xml
814  m_pAttrOutput->SetSerializer( pFS );
815  m_pVMLExport->SetFS( pFS );
816  m_pSdrExport->setSerializer(pFS);
817  SetFS( pFS );
818  {
819  DocxTableExportContext aTableExportContext(*m_pAttrOutput);
820  //When the stream changes the cache which is maintained for the graphics in case of alternate content is not cleared.
821  //So clearing the alternate content graphic cache.
822  m_pAttrOutput->PushRelIdCache();
823  // do the work
824  if (pFormat == nullptr)
825  AttrOutput().EmptyParagraph();
826  else
827  WriteHeaderFooterText(*pFormat, bHeader);
828  m_pAttrOutput->PopRelIdCache();
829  m_pAttrOutput->EndParaSdtBlock();
830  }
831 
832  // switch the serializer back
833  m_pAttrOutput->SetSerializer( m_pDocumentFS );
834  m_pVMLExport->SetFS( m_pDocumentFS );
835  m_pSdrExport->setSerializer(m_pDocumentFS);
836  SetFS( m_pDocumentFS );
837 
838  // close the tag
839  sal_Int32 nReference;
840  if ( bHeader )
841  {
842  pFS->endElementNS( XML_w, XML_hdr );
843  nReference = XML_headerReference;
844  }
845  else
846  {
847  pFS->endElementNS( XML_w, XML_ftr );
848  nReference = XML_footerReference;
849  }
850 
851  // and write the reference
852  m_pDocumentFS->singleElementNS( XML_w, nReference,
853  FSNS( XML_w, XML_type ), pType,
854  FSNS( XML_r, XML_id ), aRelId.toUtf8() );
855 }
856 
858 {
859  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
860  oox::getRelationship(Relationship::FONTTABLE),
861  "fontTable.xml" );
862 
863  ::sax_fastparser::FSHelperPtr pFS = m_pFilter->openFragmentStreamWithSerializer(
864  "word/fontTable.xml",
865  "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" );
866 
867  pFS->startElementNS( XML_w, XML_fonts,
868  FSNS( XML_xmlns, XML_w ), m_pFilter->getNamespaceURL(OOX_NS(doc)).toUtf8(),
869  FSNS( XML_xmlns, XML_r ), m_pFilter->getNamespaceURL(OOX_NS(officeRel)).toUtf8() );
870 
871  // switch the serializer to redirect the output to word/styles.xml
872  m_pAttrOutput->SetSerializer( pFS );
873 
874  // do the work
875  m_aFontHelper.WriteFontTable( *m_pAttrOutput );
876 
877  // switch the serializer back
878  m_pAttrOutput->SetSerializer( m_pDocumentFS );
879 
880  pFS->endElementNS( XML_w, XML_fonts );
881 }
882 
884 {
885  // Write the core properties
886  SwDocShell* pDocShell( m_pDoc->GetDocShell( ) );
887  uno::Reference<document::XDocumentProperties> xDocProps;
888  bool bSecurityOptOpenReadOnly = false;
889  if ( pDocShell )
890  {
891  uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
892  pDocShell->GetModel( ), uno::UNO_QUERY );
893  xDocProps = xDPS->getDocumentProperties();
894  bSecurityOptOpenReadOnly = pDocShell->IsSecurityOptOpenReadOnly();
895  }
896 
897  m_pFilter->exportDocumentProperties( xDocProps, bSecurityOptOpenReadOnly );
898 }
899 
901 {
902  SwViewShell *pViewShell(m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell());
903  if( !pViewShell && !m_aSettings.hasData() && !m_pAttrOutput->HasFootnotes() && !m_pAttrOutput->HasEndnotes())
904  return;
905 
906  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
907  oox::getRelationship(Relationship::SETTINGS),
908  "settings.xml" );
909 
910  ::sax_fastparser::FSHelperPtr pFS = m_pFilter->openFragmentStreamWithSerializer(
911  "word/settings.xml",
912  "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml" );
913 
914  pFS->startElementNS( XML_w, XML_settings,
915  FSNS( XML_xmlns, XML_w ), m_pFilter->getNamespaceURL(OOX_NS(doc)).toUtf8() );
916 
917  // View
918  if (pViewShell && pViewShell->GetViewOptions()->getBrowseMode())
919  {
920  pFS->singleElementNS(XML_w, XML_view, FSNS(XML_w, XML_val), "web");
921  }
922 
923  // Zoom
924  if (pViewShell)
925  {
928 
929  switch (pViewShell->GetViewOptions()->GetZoomType())
930  {
931  case SvxZoomType::WHOLEPAGE:
932  pAttributeList->add(FSNS(XML_w, XML_val), "fullPage");
933  break;
934  case SvxZoomType::PAGEWIDTH:
935  pAttributeList->add(FSNS(XML_w, XML_val), "bestFit");
936  break;
937  case SvxZoomType::OPTIMAL:
938  pAttributeList->add(FSNS(XML_w, XML_val), "textFit");
939  break;
940  default:
941  break;
942  }
943 
944  OString aZoom(OString::number(pViewShell->GetViewOptions()->GetZoom()));
945  pAttributeList->add(FSNS(XML_w, XML_percent), aZoom);
946  sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList.get());
947  pFS->singleElementNS(XML_w, XML_zoom, xAttributeList);
948  }
949 
950  // Display Background Shape
951  if (std::shared_ptr<SvxBrushItem> oBrush = getBackground(); oBrush)
952  {
953  // Turn on the 'displayBackgroundShape'
954  pFS->singleElementNS(XML_w, XML_displayBackgroundShape);
955  }
956 
957  // Track Changes
958  if ( !m_aSettings.revisionView )
959  pFS->singleElementNS( XML_w, XML_revisionView,
960  FSNS( XML_w, XML_insDel ), "0",
961  FSNS( XML_w, XML_formatting ), "0" );
962 
963  if ( m_aSettings.trackRevisions )
964  pFS->singleElementNS(XML_w, XML_trackRevisions);
965 
966  // Mirror Margins
967  if(isMirroredMargin())
968  pFS->singleElementNS(XML_w, XML_mirrorMargins);
969 
970  // Embed Fonts
971  if( m_pDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ))
972  pFS->singleElementNS(XML_w, XML_embedTrueTypeFonts);
973 
974  // Embed System Fonts
975  if( m_pDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_SYSTEM_FONTS ))
976  pFS->singleElementNS(XML_w, XML_embedSystemFonts);
977 
978  // Default Tab Stop
979  if( m_aSettings.defaultTabStop != 0 )
980  pFS->singleElementNS( XML_w, XML_defaultTabStop, FSNS( XML_w, XML_val ),
981  OString::number(m_aSettings.defaultTabStop) );
982 
983  // Do not justify lines with manual break
984  if( m_pDoc->getIDocumentSettingAccess().get( DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK ))
985  {
986  pFS->startElementNS(XML_w, XML_compat);
987  pFS->singleElementNS(XML_w, XML_doNotExpandShiftReturn);
988  pFS->endElementNS( XML_w, XML_compat );
989  }
990 
991  // export current mail merge database and table names
992  SwDBData aData = m_pDoc->GetDBData();
993  if ( !aData.sDataSource.isEmpty() && aData.nCommandType == css::sdb::CommandType::TABLE && !aData.sCommand.isEmpty() )
994  {
995  OUStringBuffer aDataSource;
996  aDataSource.append("SELECT * FROM ");
997  aDataSource.append(aData.sDataSource); // current database
998  aDataSource.append(".dbo."); // default database owner
999  aDataSource.append(aData.sCommand); // sheet name
1000  aDataSource.append("$"); // sheet identifier
1001  const OUString sDataSource = aDataSource.makeStringAndClear();
1002  pFS->startElementNS( XML_w, XML_mailMerge );
1003  pFS->singleElementNS(XML_w, XML_mainDocumentType,
1004  FSNS( XML_w, XML_val ), "formLetters" );
1005  pFS->singleElementNS(XML_w, XML_dataType,
1006  FSNS( XML_w, XML_val ), "textFile" );
1007  pFS->singleElementNS( XML_w, XML_query,
1008  FSNS( XML_w, XML_val ), OUStringToOString( sDataSource, RTL_TEXTENCODING_UTF8 ).getStr() );
1009  pFS->endElementNS( XML_w, XML_mailMerge );
1010  }
1011 
1012  // Automatic hyphenation: it's a global setting in Word, it's a paragraph setting in Writer.
1013  // Use the setting from the default style.
1014  SwTextFormatColl* pColl = m_pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(RES_POOLCOLL_STANDARD, /*bRegardLanguage=*/false);
1015  const SfxPoolItem* pItem;
1016  if (pColl && SfxItemState::SET == pColl->GetItemState(RES_PARATR_HYPHENZONE, false, &pItem))
1017  {
1018  pFS->singleElementNS(XML_w, XML_autoHyphenation,
1019  FSNS(XML_w, XML_val), OString::boolean(static_cast<const SvxHyphenZoneItem*>(pItem)->IsHyphen()));
1020  }
1021 
1022  // Even and Odd Headers
1023  if( m_aSettings.evenAndOddHeaders )
1024  pFS->singleElementNS(XML_w, XML_evenAndOddHeaders);
1025 
1026  // Has Footnotes
1027  if( m_pAttrOutput->HasFootnotes())
1028  DocxAttributeOutput::WriteFootnoteEndnotePr( pFS, XML_footnotePr, m_pDoc->GetFootnoteInfo(), XML_footnote );
1029 
1030  // Has Endnotes
1031  if( m_pAttrOutput->HasEndnotes())
1032  DocxAttributeOutput::WriteFootnoteEndnotePr( pFS, XML_endnotePr, m_pDoc->GetEndNoteInfo(), XML_endnote );
1033 
1034  // Has themeFontLang information
1035  uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
1036 
1037  bool hasProtectionProperties = false;
1038  uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1039  const OUString aGrabBagName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
1040  if ( xPropSetInfo->hasPropertyByName( aGrabBagName ) )
1041  {
1042  uno::Sequence< beans::PropertyValue > propList;
1043  xPropSet->getPropertyValue( aGrabBagName ) >>= propList;
1044 
1045  for( const auto& rProp : propList )
1046  {
1047  if ( rProp.Name == "ThemeFontLangProps" )
1048  {
1049  uno::Sequence< beans::PropertyValue > themeFontLangProps;
1050  rProp.Value >>= themeFontLangProps;
1051  OUString aValues[3];
1052  for( const auto& rThemeFontLangProp : themeFontLangProps )
1053  {
1054  if( rThemeFontLangProp.Name == "val" )
1055  rThemeFontLangProp.Value >>= aValues[0];
1056  else if( rThemeFontLangProp.Name == "eastAsia" )
1057  rThemeFontLangProp.Value >>= aValues[1];
1058  else if( rThemeFontLangProp.Name == "bidi" )
1059  rThemeFontLangProp.Value >>= aValues[2];
1060  }
1061  pFS->singleElementNS( XML_w, XML_themeFontLang,
1062  FSNS( XML_w, XML_val ), aValues[0].toUtf8(),
1063  FSNS( XML_w, XML_eastAsia ), aValues[1].toUtf8(),
1064  FSNS( XML_w, XML_bidi ), aValues[2].toUtf8() );
1065  }
1066  else if ( rProp.Name == "CompatSettings" )
1067  {
1068  pFS->startElementNS(XML_w, XML_compat);
1069 
1070  uno::Sequence< beans::PropertyValue > aCompatSettingsSequence;
1071  rProp.Value >>= aCompatSettingsSequence;
1072 
1073  for(const auto& rCompatSetting : aCompatSettingsSequence)
1074  {
1075  uno::Sequence< beans::PropertyValue > aCompatSetting;
1076  rCompatSetting.Value >>= aCompatSetting;
1077  OUString aName;
1078  OUString aUri;
1079  OUString aValue;
1080 
1081  for(const auto& rPropVal : aCompatSetting)
1082  {
1083  if( rPropVal.Name == "name" )
1084  rPropVal.Value >>= aName;
1085  else if( rPropVal.Name == "uri" )
1086  rPropVal.Value >>= aUri;
1087  else if( rPropVal.Name == "val" )
1088  rPropVal.Value >>= aValue;
1089  }
1090  pFS->singleElementNS( XML_w, XML_compatSetting,
1091  FSNS( XML_w, XML_name ), aName.toUtf8(),
1092  FSNS( XML_w, XML_uri ), aUri.toUtf8(),
1093  FSNS( XML_w, XML_val ), aValue.toUtf8());
1094  }
1095 
1096  pFS->endElementNS( XML_w, XML_compat );
1097  }
1098  else if (rProp.Name == "DocumentProtection")
1099  {
1100 
1101  uno::Sequence< beans::PropertyValue > rAttributeList;
1102  rProp.Value >>= rAttributeList;
1103 
1104  if (rAttributeList.hasElements())
1105  {
1107  for (const auto& rAttribute : rAttributeList)
1108  {
1109  static DocxStringTokenMap const aTokens[] =
1110  {
1111  { "edit", XML_edit },
1112  { "enforcement", XML_enforcement },
1113  { "formatting", XML_formatting },
1114  { "cryptProviderType", XML_cryptProviderType },
1115  { "cryptAlgorithmClass", XML_cryptAlgorithmClass },
1116  { "cryptAlgorithmType", XML_cryptAlgorithmType },
1117  { "cryptAlgorithmSid", XML_cryptAlgorithmSid },
1118  { "cryptSpinCount", XML_cryptSpinCount },
1119  { "hash", XML_hash },
1120  { "salt", XML_salt },
1121  { nullptr, 0 }
1122  };
1123 
1124  if (sal_Int32 nToken = DocxStringGetToken(aTokens, rAttribute.Name))
1125  pAttributeList->add(FSNS(XML_w, nToken), rAttribute.Value.get<OUString>().toUtf8());
1126  }
1127 
1128  // we have document protection from input DOCX file
1129 
1130  sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
1131  pFS->singleElementNS(XML_w, XML_documentProtection, xAttributeList);
1132 
1133  hasProtectionProperties = true;
1134  }
1135  }
1136  }
1137  }
1138 
1139  // Protect form
1140  // Section-specific write protection
1141  if (! hasProtectionProperties)
1142  {
1143  if (m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_FORM) ||
1144  m_pSections->DocumentIsProtected())
1145  {
1146  // we have form protection from Writer or from input ODT file
1147 
1148  pFS->singleElementNS(XML_w, XML_documentProtection,
1149  FSNS(XML_w, XML_edit), "forms",
1150  FSNS(XML_w, XML_enforcement), "true");
1151  }
1152  }
1153 
1154  // finish settings.xml
1155  pFS->endElementNS( XML_w, XML_settings );
1156 }
1157 
1159 {
1160  uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
1161 
1162  uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1164  if ( !xPropSetInfo->hasPropertyByName( aName ) )
1165  return;
1166 
1167  uno::Reference<xml::dom::XDocument> themeDom;
1168  uno::Sequence< beans::PropertyValue > propList;
1169  xPropSet->getPropertyValue( aName ) >>= propList;
1170  auto pProp = std::find_if(propList.begin(), propList.end(),
1171  [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXTheme"; });
1172  if (pProp != propList.end())
1173  pProp->Value >>= themeDom;
1174 
1175  // no theme dom to write
1176  if ( !themeDom.is() )
1177  return;
1178 
1179  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
1180  oox::getRelationship(Relationship::THEME),
1181  "theme/theme1.xml" );
1182 
1183  uno::Reference< xml::sax::XSAXSerializable > serializer( themeDom, uno::UNO_QUERY );
1184  uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
1185  writer->setOutputStream( GetFilter().openFragmentStream( "word/theme/theme1.xml",
1186  "application/vnd.openxmlformats-officedocument.theme+xml" ) );
1187  serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
1188  uno::Sequence< beans::StringPair >() );
1189 }
1190 
1192 {
1193  uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
1194 
1195  uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1197  if ( !xPropSetInfo->hasPropertyByName( aName ) )
1198  return;
1199 
1200  uno::Reference<xml::dom::XDocument> glossaryDocDom;
1201  uno::Sequence< uno::Sequence< uno::Any> > glossaryDomList;
1202  uno::Sequence< beans::PropertyValue > propList;
1203  xPropSet->getPropertyValue( aName ) >>= propList;
1204  sal_Int32 collectedProperties = 0;
1205  for ( const auto& rProp : propList )
1206  {
1207  OUString propName = rProp.Name;
1208  if ( propName == "OOXGlossary" )
1209  {
1210  rProp.Value >>= glossaryDocDom;
1211  collectedProperties++;
1212  }
1213  if (propName == "OOXGlossaryDom")
1214  {
1215  rProp.Value >>= glossaryDomList;
1216  collectedProperties++;
1217  }
1218  if (collectedProperties == 2)
1219  break;
1220  }
1221 
1222  // no glossary dom to write
1223  if ( !glossaryDocDom.is() )
1224  return;
1225 
1226  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
1227  oox::getRelationship(Relationship::GLOSSARYDOCUMENT),
1228  "glossary/document.xml" );
1229 
1230  uno::Reference< io::XOutputStream > xOutputStream = GetFilter().openFragmentStream( "word/glossary/document.xml",
1231  "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml" );
1232 
1233  uno::Reference< xml::sax::XSAXSerializable > serializer( glossaryDocDom, uno::UNO_QUERY );
1234  uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
1235  writer->setOutputStream( xOutputStream );
1236  serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
1237  uno::Sequence< beans::StringPair >() );
1238 
1239  for ( const uno::Sequence< uno::Any>& glossaryElement : glossaryDomList)
1240  {
1241  OUString gTarget, gType, gId, contentType;
1242  uno::Reference<xml::dom::XDocument> xDom;
1243  glossaryElement[0] >>= xDom;
1244  glossaryElement[1] >>= gId;
1245  glossaryElement[2] >>= gType;
1246  glossaryElement[3] >>= gTarget;
1247  glossaryElement[4] >>= contentType;
1248  gId = gId.copy(3); //"rId" only save the numeric value
1249 
1250  PropertySet aProps(xOutputStream);
1251  aProps.setAnyProperty( PROP_RelId, uno::makeAny( gId.toInt32() ));
1252  m_pFilter->addRelation( xOutputStream, gType, gTarget);
1253  uno::Reference< xml::sax::XSAXSerializable > gserializer( xDom, uno::UNO_QUERY );
1254  writer->setOutputStream(GetFilter().openFragmentStream( "word/glossary/" + gTarget, contentType ) );
1255  gserializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
1256  uno::Sequence< beans::StringPair >() );
1257  }
1258 }
1259 
1261 {
1262  uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
1263 
1264  uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1265  static const OUString aName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
1266  if ( !xPropSetInfo->hasPropertyByName( aName ) )
1267  return;
1268 
1269  uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomlist;
1270  uno::Sequence<uno::Reference<xml::dom::XDocument> > customXmlDomPropslist;
1271  uno::Sequence< beans::PropertyValue > propList;
1272  xPropSet->getPropertyValue( aName ) >>= propList;
1273  auto pProp = std::find_if(propList.begin(), propList.end(),
1274  [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXCustomXml"; });
1275  if (pProp != propList.end())
1276  pProp->Value >>= customXmlDomlist;
1277 
1278  pProp = std::find_if(propList.begin(), propList.end(),
1279  [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXCustomXmlProps"; });
1280  if (pProp != propList.end())
1281  pProp->Value >>= customXmlDomPropslist;
1282 
1283  for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++)
1284  {
1285  uno::Reference<xml::dom::XDocument> customXmlDom = customXmlDomlist[j];
1286  uno::Reference<xml::dom::XDocument> customXmlDomProps = customXmlDomPropslist[j];
1287  if (customXmlDom.is())
1288  {
1289  m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
1290  oox::getRelationship(Relationship::CUSTOMXML),
1291  "../customXml/item"+OUString::number((j+1))+".xml" );
1292 
1293  uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDom, uno::UNO_QUERY );
1294  uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
1295  writer->setOutputStream( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml",
1296  "application/xml" ) );
1297  serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
1298  uno::Sequence< beans::StringPair >() );
1299  }
1300 
1301  if (customXmlDomProps.is())
1302  {
1303  uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDomProps, uno::UNO_QUERY );
1304  uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
1305  writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number((j+1))+".xml",
1306  "application/vnd.openxmlformats-officedocument.customXmlProperties+xml" ) );
1307  serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
1308  uno::Sequence< beans::StringPair >() );
1309 
1310  // Adding itemprops's relationship entry to item.xml.rels file
1311  m_pFilter->addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number((j+1))+".xml",
1312  "application/xml" ) ,
1313  oox::getRelationship(Relationship::CUSTOMXMLPROPS),
1314  "itemProps"+OUString::number((j+1))+".xml" );
1315  }
1316  }
1317 }
1318 
1320 {
1321  uno::Reference<document::XStorageBasedDocument> xStorageBasedDocument(m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
1322  if (!xStorageBasedDocument.is())
1323  return;
1324 
1325  uno::Reference<embed::XStorage> xDocumentStorage = xStorageBasedDocument->getDocumentStorage();
1326  OUString aMacrosName("_MS_VBA_Macros");
1327  if (!xDocumentStorage.is() || !xDocumentStorage->hasByName(aMacrosName))
1328  return;
1329 
1330  const sal_Int32 nOpenMode = embed::ElementModes::READ;
1331  uno::Reference<io::XStream> xMacrosStream = xDocumentStorage->openStreamElement(aMacrosName, nOpenMode);
1332  uno::Reference<io::XOutputStream> xProjectStream;
1333  if (xMacrosStream.is())
1334  {
1335  // First handle the project stream, this sets xProjectStream.
1336  std::unique_ptr<SvStream> pIn(utl::UcbStreamHelper::CreateStream(xMacrosStream));
1337 
1338  xProjectStream = GetFilter().openFragmentStream("word/vbaProject.bin", "application/vnd.ms-office.vbaProject");
1339  uno::Reference<io::XStream> xOutputStream(xProjectStream, uno::UNO_QUERY);
1340  if (!xOutputStream.is())
1341  return;
1342  std::unique_ptr<SvStream> pOut(utl::UcbStreamHelper::CreateStream(xOutputStream));
1343 
1344  // Write the stream.
1345  pOut->WriteStream(*pIn);
1346 
1347  // Write the relationship.
1348  m_pFilter->addRelation(m_pDocumentFS->getOutputStream(), oox::getRelationship(Relationship::VBAPROJECT), "vbaProject.bin");
1349  }
1350 
1351  OUString aDataName("_MS_VBA_Macros_XML");
1352  if (!xDocumentStorage.is() || !xDocumentStorage->hasByName(aDataName))
1353  return;
1354 
1355  uno::Reference<io::XStream> xDataStream = xDocumentStorage->openStreamElement(aDataName, nOpenMode);
1356  if (xDataStream.is())
1357  {
1358  // Then the data stream, which wants to work with an already set
1359  // xProjectStream.
1360  std::unique_ptr<SvStream> pIn(utl::UcbStreamHelper::CreateStream(xDataStream));
1361 
1362  uno::Reference<io::XStream> xOutputStream(GetFilter().openFragmentStream("word/vbaData.xml", "application/vnd.ms-word.vbaData+xml"), uno::UNO_QUERY);
1363  if (!xOutputStream.is())
1364  return;
1365  std::unique_ptr<SvStream> pOut(utl::UcbStreamHelper::CreateStream(xOutputStream));
1366 
1367  // Write the stream.
1368  pOut->WriteStream(*pIn);
1369 
1370  // Write the relationship.
1371  if (!xProjectStream.is())
1372  return;
1373 
1374  m_pFilter->addRelation(xProjectStream, oox::getRelationship(Relationship::WORDVBADATA), "vbaData.xml");
1375  }
1376 }
1377 
1379 {
1380  uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
1381 
1382  uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1384  if ( !xPropSetInfo->hasPropertyByName( aName ) )
1385  return;
1386 
1387  uno::Sequence< beans::PropertyValue > embeddingsList;
1388  uno::Sequence< beans::PropertyValue > propList;
1389  xPropSet->getPropertyValue( aName ) >>= propList;
1390  auto pProp = std::find_if(propList.begin(), propList.end(),
1391  [](const beans::PropertyValue& rProp) { return rProp.Name == "OOXEmbeddings"; });
1392  if (pProp != propList.end())
1393  pProp->Value >>= embeddingsList;
1394  for (const auto& rEmbedding : embeddingsList)
1395  {
1396  OUString embeddingPath = rEmbedding.Name;
1397  uno::Reference<io::XInputStream> embeddingsStream;
1398  rEmbedding.Value >>= embeddingsStream;
1399 
1400  OUString contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
1401  // FIXME: this .xlsm hack is silly - if anything the mime-type for an existing embedded object should be read from [Content_Types].xml
1402  if (embeddingPath.endsWith(".xlsm"))
1403  contentType = "application/vnd.ms-excel.sheet.macroEnabled.12";
1404  else if (embeddingPath.endsWith(".bin"))
1405  contentType = "application/vnd.openxmlformats-officedocument.oleObject";
1406 
1407  if ( embeddingsStream.is() )
1408  {
1409  uno::Reference< io::XOutputStream > xOutStream = GetFilter().openFragmentStream(embeddingPath,
1410  contentType);
1411  try
1412  {
1413  sal_Int32 nBufferSize = 512;
1414  uno::Sequence< sal_Int8 > aDataBuffer(nBufferSize);
1415  sal_Int32 nRead;
1416  do
1417  {
1418  nRead = embeddingsStream->readBytes( aDataBuffer, nBufferSize );
1419  if( nRead )
1420  {
1421  if( nRead < nBufferSize )
1422  {
1423  nBufferSize = nRead;
1424  aDataBuffer.realloc(nRead);
1425  }
1426  xOutStream->writeBytes( aDataBuffer );
1427  }
1428  }
1429  while( nRead );
1430  xOutStream->flush();
1431  }
1432  catch(const uno::Exception&)
1433  {
1434  css::uno::Any ex( cppu::getCaughtException() );
1435  SAL_WARN("sw.ww8", "WriteEmbeddings() ::Failed to copy Inputstream to outputstream exception caught! " << exceptionToString(ex));
1436  }
1437  xOutStream->closeOutput();
1438  }
1439  }
1440 }
1441 
1443 {
1444  bool bMirroredMargins = false;
1445  if ( UseOnPage::Mirror == (UseOnPage::Mirror & m_pDoc->GetPageDesc(0).ReadUseOn()) )
1446  {
1447  bMirroredMargins = true;
1448  }
1449  return bMirroredMargins;
1450 }
1451 
1453 {
1454  // setup the namespaces
1455  m_pDocumentFS->startElementNS( XML_w, XML_document, MainXmlNamespaces());
1456 
1457  if ( getenv("SW_DEBUG_DOM") )
1458  {
1459  m_pDoc->dumpAsXml();
1460  }
1461 
1462  // reset the incrementing linked-textboxes chain ID before re-saving.
1463  m_nLinkedTextboxesChainId=0;
1464  m_aLinkedTextboxesHelper.clear();
1465 
1466  // Write background page color
1467  if (std::shared_ptr<SvxBrushItem> oBrush = getBackground(); oBrush)
1468  {
1469  Color backgroundColor = oBrush->GetColor();
1470  OString aBackgroundColorStr = msfilter::util::ConvertColor(backgroundColor);
1471 
1472  m_pDocumentFS->singleElementNS(XML_w, XML_background, FSNS(XML_w, XML_color),
1473  aBackgroundColorStr);
1474  }
1475 
1476  // body
1477  m_pDocumentFS->startElementNS(XML_w, XML_body);
1478 
1479  m_pCurPam->GetPoint()->nNode = m_pDoc->GetNodes().GetEndOfContent().StartOfSectionNode()->GetIndex();
1480 
1481  // the text
1482  WriteText();
1483 
1484  // clear linked textboxes since old ones can't be linked to frames in a different section (correct?)
1485  m_aLinkedTextboxesHelper.clear();
1486 
1487  // the last section info
1488  m_pAttrOutput->EndParaSdtBlock();
1489  const WW8_SepInfo *pSectionInfo = m_pSections? m_pSections->CurrentSectionInfo(): nullptr;
1490  if ( pSectionInfo )
1491  SectionProperties( *pSectionInfo );
1492 
1493  // finish body and document
1494  m_pDocumentFS->endElementNS( XML_w, XML_body );
1495  m_pDocumentFS->endElementNS( XML_w, XML_document );
1496 }
1497 
1499 {
1501  pAttr->add( FSNS( XML_xmlns, XML_o ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(vmlOffice)), RTL_TEXTENCODING_UTF8).getStr() );
1502  pAttr->add( FSNS( XML_xmlns, XML_r ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(officeRel)), RTL_TEXTENCODING_UTF8).getStr() );
1503  pAttr->add( FSNS( XML_xmlns, XML_v ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(vml)), RTL_TEXTENCODING_UTF8).getStr() );
1504  pAttr->add( FSNS( XML_xmlns, XML_w ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(doc)), RTL_TEXTENCODING_UTF8).getStr() );
1505  pAttr->add( FSNS( XML_xmlns, XML_w10 ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(vmlWord)), RTL_TEXTENCODING_UTF8).getStr() );
1506  pAttr->add( FSNS( XML_xmlns, XML_wp ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(dmlWordDr)), RTL_TEXTENCODING_UTF8).getStr() );
1507  pAttr->add( FSNS( XML_xmlns, XML_wps ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(wps)), RTL_TEXTENCODING_UTF8).getStr() );
1508  pAttr->add( FSNS( XML_xmlns, XML_wpg ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(wpg)), RTL_TEXTENCODING_UTF8).getStr() );
1509  pAttr->add( FSNS( XML_xmlns, XML_mc ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(mce)), RTL_TEXTENCODING_UTF8).getStr() );
1510  pAttr->add( FSNS( XML_xmlns, XML_wp14 ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(wp14)), RTL_TEXTENCODING_UTF8).getStr() );
1511  pAttr->add( FSNS( XML_xmlns, XML_w14 ), OUStringToOString(m_pFilter->getNamespaceURL(OOX_NS(w14)), RTL_TEXTENCODING_UTF8).getStr() );
1512  pAttr->add( FSNS( XML_mc, XML_Ignorable ), "w14 wp14" );
1513  return XFastAttributeListRef( pAttr );
1514 }
1515 
1516 bool DocxExport::ignoreAttributeForStyleDefaults( sal_uInt16 nWhich ) const
1517 {
1518  if( nWhich == RES_TEXTGRID )
1519  return true; // w:docGrid is written only to document.xml, not to styles.xml
1520  if (nWhich == RES_PARATR_HYPHENZONE)
1521  return true; // w:suppressAutoHyphens is only a formatting exception, not a default
1523 }
1524 
1526 {
1527  const EditTextObject& rEditObj = rParaObj.GetTextObject();
1528  MSWord_SdrAttrIter aAttrIter( *this, rEditObj, nTyp );
1529 
1530  sal_Int32 nPara = rEditObj.GetParagraphCount();
1531  for( sal_Int32 n = 0; n < nPara; ++n )
1532  {
1533  if( n )
1534  aAttrIter.NextPara( n );
1535 
1536  AttrOutput().StartParagraph( ww8::WW8TableNodeInfo::Pointer_t());
1537  rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
1538  OUString aStr( rEditObj.GetText( n ));
1539  sal_Int32 nCurrentPos = 0;
1540  const sal_Int32 nEnd = aStr.getLength();
1541  do {
1542  AttrOutput().StartRun( nullptr, 0 );
1543  const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd);
1544  rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
1545 
1546  bool bTextAtr = aAttrIter.IsTextAttr( nCurrentPos );
1547  if( !bTextAtr )
1548  {
1549  if( nCurrentPos == 0 && nNextAttr - nCurrentPos == aStr.getLength())
1550  AttrOutput().RunText( aStr, eChrSet );
1551  else
1552  {
1553  OUString tmp( aStr.copy( nCurrentPos, nNextAttr - nCurrentPos ));
1554  AttrOutput().RunText( tmp, eChrSet );
1555  }
1556  }
1557  AttrOutput().StartRunProperties();
1558  aAttrIter.OutAttr( nCurrentPos );
1559  AttrOutput().EndRunProperties( nullptr );
1560 
1561  nCurrentPos = nNextAttr;
1562  eChrSet = eNextChrSet;
1563  aAttrIter.NextPos();
1564 
1565  AttrOutput().EndRun( nullptr, 0 );
1566 
1567  } while( nCurrentPos < nEnd );
1568 // aAttrIter.OutParaAttr(false);
1569  AttrOutput().EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t());
1570  }
1571 }
1572 
1574 {
1575  mpFS = pFS;
1576 }
1577 
1578 DocxExport::DocxExport(DocxExportFilter* pFilter, SwDoc* pDocument, SwPaM* pCurrentPam,
1579  SwPaM* pOriginalPam, bool bDocm, bool bTemplate)
1580  : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ),
1581  m_pFilter( pFilter ),
1582  m_nHeaders( 0 ),
1583  m_nFooters( 0 ),
1584  m_nOLEObjects( 0 ),
1585  m_nActiveXControls( 0 ),
1586  m_nHeadersFootersInSection(0),
1587  m_bDocm(bDocm),
1588  m_bTemplate(bTemplate)
1589 {
1590  // Write the document properties
1591  WriteProperties( );
1592 
1593  // relations for the document
1594  m_pFilter->addRelation( oox::getRelationship(Relationship::OFFICEDOCUMENT),
1595  "word/document.xml" );
1596 
1597  // Set media type depending of document type
1598  OUString aMediaType;
1599  if (m_bDocm)
1600  {
1601  if (m_bTemplate)
1602  {
1603  aMediaType = "application/vnd.ms-word.template.macroEnabledTemplate.main+xml";
1604  }
1605  else
1606  {
1607  aMediaType = "application/vnd.ms-word.document.macroEnabled.main+xml";
1608  }
1609  }
1610  else
1611  {
1612  if (m_bTemplate)
1613  {
1614  aMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml";
1615  }
1616  else
1617  {
1618  aMediaType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
1619  }
1620  }
1621 
1622 
1623  // the actual document
1624  m_pDocumentFS = m_pFilter->openFragmentStreamWithSerializer( "word/document.xml", aMediaType );
1625 
1627 
1628  // the DrawingML access
1630 
1631  // the attribute output for the document
1632  m_pAttrOutput.reset(new DocxAttributeOutput( *this, m_pDocumentFS, m_pDrawingML.get() ));
1633 
1634  // the related VMLExport
1635  m_pVMLExport.reset(new VMLExport( m_pDocumentFS, m_pAttrOutput.get() ));
1636 
1637  // the related drawing export
1638  m_pSdrExport.reset(new DocxSdrExport( *this, m_pDocumentFS, m_pDrawingML.get() ));
1639 }
1640 
1642 {
1643 }
1644 
1646 : evenAndOddHeaders( false )
1647 , defaultTabStop( 0 )
1648 , revisionView( true )
1649 , trackRevisions( false )
1650 {
1651 }
1652 
1654 {
1655  if( evenAndOddHeaders )
1656  return true;
1657  if( defaultTabStop != 0 )
1658  return true;
1659  if ( !revisionView )
1660  return true;
1661  if ( trackRevisions )
1662  return true;
1663 
1664  return false;
1665 }
1666 
1667 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void WriteFootnotesEndnotes()
Write footnotes.xml and endnotes.xml.
Definition: docxexport.cxx:669
bool IsHyphen(sal_Unicode cChar)
#define RES_CHRATR_WEIGHT
Definition: hintids.hxx:83
void OutAttr(sal_Int32 nSwPos)
Definition: wrtw8esh.cxx:1128
void InitStyles()
Setup pStyles and write styles.xml.
Definition: docxexport.cxx:646
virtual void DoFormText(const SwInputField *pField) override
Definition: docxexport.cxx:377
sal_Int32 WhereNext() const
Definition: wrtww8.hxx:1463
virtual void OutputLinkedOLE(const OUString &) override
Definition: docxexport.cxx:610
const char * sGUID
std::unique_ptr< oox::vml::VMLExport > m_pVMLExport
Exporter of the VML shapes.
Definition: docxexport.hxx:101
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
bool hasData() const
const HdFtFlags WW8_FOOTER_FIRST
Definition: ww8scan.hxx:1594
Class to collect and output the sections/headers/footers.
Definition: wrtww8.hxx:198
DocxAttributeOutput & DocxAttrOutput() const
Access to the derived attribute output class.
Definition: docxexport.cxx:108
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
The class that has handlers for various resource types when exporting as DOCX.
Handles DOCX export of drawings.
bool IsSectionNode() const
Definition: node.hxx:644
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
virtual bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) override
Return value indicates if an inherited outline numbering is suppressed.
Definition: docxexport.cxx:234
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:76
rtl_TextEncoding GetNodeCharSet() const
Definition: wrtww8.hxx:1465
static FastAttributeList * createAttrList()
const OUString & GetText() const
Definition: ndtxt.hxx:211
static void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::io::XOutputStream > &xOutput)
virtual void OutputEndNode(const SwEndNode &)
Output SwEndNode.
Definition: wrtww8.cxx:4189
virtual void AppendBookmarks(const SwTextNode &rNode, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: docxexport.cxx:152
css::uno::Reference< css::xml::sax::XFastAttributeList > XFastAttributeListRef
std::pair< OString, OString > WriteActiveXObject(const uno::Reference< css::drawing::XShape > &rxShape, const uno::Reference< awt::XControlModel > &rxControlModel)
Definition: docxexport.cxx:448
#define RES_CHRATR_CJK_POSTURE
Definition: hintids.hxx:93
sal_Int32 findValue(const css::uno::Sequence< OUString > &_rList, const OUString &_rValue)
#define FSNS(namespc, element)
bool IsSecurityOptOpenReadOnly() const
sal_uIntPtr sal_uLong
OUString sDataSource
Definition: swdbdata.hxx:30
virtual void WriteHyperlinkData(const ::sw::mark::IFieldmark &rFieldmark) override
Definition: docxexport.cxx:329
Base class of all fields.
Definition: fldbas.hxx:279
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:900
bool const m_bDocm
If the result will be a .docm file or not.
Definition: docxexport.hxx:107
Definition: doc.hxx:185
sal_Int16 nId
#define RES_CHRATR_CJK_WEIGHT
Definition: hintids.hxx:94
All the information that should be stashed away when we're in the middle of of a table export and sti...
SwNode & GetNode() const
Definition: ndindex.hxx:118
void WriteSettings()
Write word/settings.xml.
Definition: docxexport.cxx:900
void WriteGlossary()
SwSectionFormat * GetFormat()
Definition: section.hxx:337
for(size_t a(0);a< count;a++)
void WriteFonts()
Write word/fontTable.xml.
Definition: docxexport.cxx:857
virtual void WriteHeadersFooters(sal_uInt8 nHeadFootFlags, const SwFrameFormat &rFormat, const SwFrameFormat &rLeftFormat, const SwFrameFormat &rFirstPageFormat, sal_uInt8 nBreakCode) override
Output the actual headers and footers.
Definition: docxexport.cxx:256
#define RES_CHRATR_CJK_FONTSIZE
Definition: hintids.hxx:91
virtual void OutputGrfNode(const SwGrfNode &) override
Output SwGrfNode.
Definition: docxexport.cxx:600
void WriteCustomXml()
Write customXml/item[n].xml and customXml/itemProps[n].xml.
bool isMirroredMargin()
return true if Page Layout is set as Mirrored
Used to export formatted text associated to drawings.
Definition: wrtww8.hxx:1427
sax_fastparser::XFastAttributeListRef MainXmlNamespaces()
All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...)
OUString FieldString(ww::eField eIndex)
Definition: ww8atr.cxx:2580
const SwSection & GetSection() const
Definition: node.hxx:541
static void WriteFootnoteEndnotePr(::sax_fastparser::FSHelperPtr const &fs, int tag, const SwEndNoteInfo &info, int listtag)
writes the footnotePr/endnotePr (depending on tag) section
FieldFlags
Definition: wrtww8.hxx:146
std::unique_ptr< DocxAttributeOutput > m_pAttrOutput
Attribute output for document.
Definition: docxexport.hxx:80
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
bool const m_bTemplate
Export is done into template (.dotx)
Definition: docxexport.hxx:110
Class to collect and output the styles table.
Definition: wrtww8.hxx:1543
Any SAL_CALL getCaughtException()
virtual bool ignoreAttributeForStyleDefaults(sal_uInt16 nWhich) const override
Used to filter out attributes that can be e.g. written to .doc but not to .docx.
virtual AttributeOutputBase & AttrOutput() const override
Access to the attribute output class.
Definition: docxexport.cxx:103
ShapeExport & WriteShape(const css::uno::Reference< css::drawing::XShape > &xShape)
OString OutputChart(css::uno::Reference< css::frame::XModel > const &xModel, sal_Int32 nCount,::sax_fastparser::FSHelperPtr const &m_pSerializer)
Returns the relationd id.
Definition: docxexport.cxx:384
eField
Definition: fields.hxx:26
void WritePostitFields()
Write comments.xml.
Definition: docxexport.cxx:726
const HdFtFlags WW8_FOOTER_EVEN
Definition: ww8scan.hxx:1591
sal_uLong GetStartValue() const
Definition: fmtline.hxx:57
#define RES_PARATR_NUMRULE
Definition: hintids.hxx:170
OString WriteOLEObject(SwOLEObj &rObject, OUString &io_rProgID)
Definition: docxexport.cxx:400
void WriteOutliner(const OutlinerParaObject &rOutliner, sal_uInt8 nTyp)
RedlineFlags on.
virtual void AppendSection(const SwPageDesc *pPageDesc, const SwSectionFormat *pFormat, sal_uLong nLnNum) override
Definition: docxexport.cxx:551
void WriteHeaderFooter(const SwFormat *pFormat, bool bHeader, const char *pType)
Write reference to a header/footer + the actual xml containing the text.
Definition: docxexport.cxx:781
OString AddRelation(const OUString &rType, const OUString &rTarget)
Returns the relationd id.
Definition: docxexport.cxx:226
OUString getRelationship(Relationship eRelationship)
virtual MSWordSections & Sections() const override
Access to the sections/headers/footres.
Definition: docxexport.cxx:113
#define UNO_NAME_MISC_OBJ_INTEROPGRABBAG
virtual void AppendAnnotationMarks(const SwWW8AttrIter &rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen) override
Definition: docxexport.cxx:196
if(nullptr==pCandidateA||nullptr==pCandidateB)
OUString GetText(sal_Int32 nPara) const
bool getOutputStream(ProgramOptions const &options, OString const &extension, std::ostream **ppOutputStream, OString &targetSourceFileName, OString &tmpSourceFileName)
const HdFtFlags WW8_HEADER_ODD
Definition: ww8scan.hxx:1590
Base class for various Writer styles.
Definition: format.hxx:43
void WriteEmbeddings()
Write word/embeddings/Worksheet[n].xlsx.
bool IsContentNode() const
Definition: node.hxx:628
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const EditTextObject & GetTextObject() const
::sax_fastparser::FSHelperPtr openFragmentStreamWithSerializer(const OUString &rStreamName, const OUString &rMediaType)
void WriteProperties()
Write docProps/core.xml.
Definition: docxexport.cxx:883
Style of a layout element.
Definition: frmfmt.hxx:57
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) override
Guess the script (asian/western).
Definition: docxexport.cxx:118
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
OUString sName
void OutputDML(css::uno::Reference< css::drawing::XShape > const &xShape)
Writes the shape using drawingML syntax.
Definition: docxexport.cxx:496
SwContentNode * GetContentNode()
Definition: node.hxx:615
#define RES_PARATR_HYPHENZONE
Definition: hintids.hxx:167
sal_Int32 DocxStringGetToken(DocxStringTokenMap const *pMap, const OUString &rName)
std::unique_ptr< oox::drawingml::DrawingML > m_pDrawingML
Access to the DrawingML writer.
Definition: docxexport.hxx:77
OString ConvertColor(const Color &rColor)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:398
Marks a node in the document model.
Definition: ndindex.hxx:31
bool IsEndNode() const
Definition: node.hxx:632
GUIDCNamePair const aData
virtual void OutputOLENode(const SwOLENode &) override
Output SwOLENode.
Definition: docxexport.cxx:605
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
void SetFS(::sax_fastparser::FSHelperPtr const &mpFS)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
virtual void OutputEndNode(const SwEndNode &) override
Output SwEndNode.
Definition: docxexport.cxx:557
virtual void DoComboBox(const OUString &rName, const OUString &rHelp, const OUString &ToolTip, const OUString &rSelected, css::uno::Sequence< OUString > &rListItems) override
Definition: docxexport.cxx:336
OString exceptionToString(const css::uno::Any &caught)
SwSectionFormat * GetParent() const
Definition: section.hxx:356
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
std::unique_ptr< DocxSdrExport > m_pSdrExport
Exporter of drawings.
Definition: docxexport.hxx:104
sal_Int32 GetParagraphCount() const
virtual void WriteNumbering() override
Write the numbering table.
Definition: docxexport.cxx:746
SwFormat * DerivedFrom() const
Definition: format.hxx:108
OUString addRelation(const OUString &rType, const OUString &rTarget)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual sal_uLong ReplaceCr(sal_uInt8 nChar) override
Definition: docxexport.cxx:615
virtual void PrepareNewPageDesc(const SfxItemSet *pSet, const SwNode &rNd, const SwFormatPageDesc *pNewPgDescFormat, const SwPageDesc *pNewPgDesc) override
Get ready for a new section.
Definition: docxexport.cxx:622
::sax_fastparser::FSHelperPtr m_pDocumentFS
Fast serializer for the document output.
Definition: docxexport.hxx:71
#define RES_TEXTGRID
Definition: hintids.hxx:220
void WriteVBA()
Writes word/vbaProject.bin.
DocxExportFilter * m_pFilter
Pointer to the filter that owns us.
Definition: docxexport.hxx:68
#define ERRCODE_NONE
unsigned char sal_uInt8
#define RES_CHRATR_POSTURE
Definition: hintids.hxx:79
bool IsTextAttr(sal_Int32 nSwPos)
Definition: wrtw8esh.cxx:1208
#define SAL_INFO(area, stream)
virtual ErrCode ExportDocument_Impl() override
Format-dependent part of the actual export.
Definition: docxexport.cxx:508
const HdFtFlags WW8_HEADER_FIRST
Definition: ww8scan.hxx:1593
void WriteTheme()
Write word/theme/theme1.xml.
virtual void WriteFormData(const ::sw::mark::IFieldmark &rFieldmark) override
Write the data of the form field.
Definition: docxexport.cxx:324
const sal_uInt8 PageBreak
void add(sal_Int32 nToken, const sal_Char *pValue)
The physical access to the DOCX document (for writing).
Reference< XComponentContext > getProcessComponentContext()
std::shared_ptr< WW8TableNodeInfoInner > Pointer_t
virtual void OutputField(const SwField *pField, ww::eField eFieldType, const OUString &rFieldCmd, FieldFlags nMode=FieldFlags::All) override
Write the field.
Definition: docxexport.cxx:319
static void ResetCounters()
bool evenAndOddHeaders
returns true if there are any non-default settings (i.e. something to write)
Definition: docxexport.hxx:58
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:723
OString const aName
uno::Reference< io::XInputStream > GetOLEObjectStream(uno::Reference< uno::XComponentContext > const &xContext, uno::Reference< embed::XEmbeddedObject > const &xObj, OUString const &i_rProgID, OUString &o_rMediaType, OUString &o_rRelationType, OUString &o_rSuffix, const char *&o_rpProgID)
virtual bool ignoreAttributeForStyleDefaults(sal_uInt16) const
Used to filter out attributes that can be e.g. written to .doc but not to .docx.
Definition: wrtww8.hxx:667
virtual void AppendBookmark(const OUString &rName) override
Definition: docxexport.cxx:185
#define SAL_WARN(area, stream)
Base class for WW8Export and DocxExport.
Definition: wrtww8.hxx:452
Reference< XModel > xModel
bool IsTableNode() const
Definition: node.hxx:640
virtual ~DocxExport() override
Destructor.
SwSectionNode * GetSectionNode()
Definition: node.hxx:607
Ends a section of nodes in the document model.
Definition: node.hxx:333
rtl_TextEncoding GetNextCharSet() const
Definition: wrtw8esh.cxx:1054
SectionType GetType() const
Definition: section.hxx:171
std::vector< ::sw::mark::IMark * > IMarkVector
Used to split the runs according to the bookmarks start and ends.
Definition: wrtww8.hxx:575
std::shared_ptr< WW8TableNodeInfo > Pointer_t
DefTokenId const nToken
OUString sCommand
Definition: swdbdata.hxx:31
aStr
DocxExport(DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, bool bDocm, bool bTemplate)
Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
void NextPara(sal_Int32 nPar)
Definition: wrtw8esh.cxx:1034
virtual OUString GetPar2() const override
aPromptText
Definition: expfld.cxx:1406
const HdFtFlags WW8_FOOTER_ODD
Definition: ww8scan.hxx:1592
virtual void ExportGrfBullet(const SwTextNode &) override
Definition: docxexport.cxx:220
const HdFtFlags WW8_HEADER_EVEN
Definition: ww8scan.hxx:1589
const SwFormatLineNumber & GetLineNumber(bool=true) const
Definition: fmtline.hxx:64
Base class of the Writer document model elements.
Definition: node.hxx:79
void WriteMainText()
FIXME this is temporary, remotely reminding the method of the same name in WW8Export.
OUString sId