LibreOffice Module sw (master)  1
unotxdoc.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 <boost/property_tree/json_parser.hpp>
21 
22 #include <sal/config.h>
23 #include <officecfg/Office/Common.hxx>
24 #include <comphelper/string.hxx>
25 #include <AnnotationWin.hxx>
26 #include <o3tl/any.hxx>
27 #include <osl/mutex.hxx>
28 #include <vcl/virdev.hxx>
29 #include <vcl/sysdata.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/print.hxx>
32 #include <sfx2/bindings.hxx>
33 #include <sfx2/viewfrm.hxx>
34 #include <sfx2/lokhelper.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <sfx2/printer.hxx>
39 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
40 #include <sfx2/lokcharthelper.hxx>
41 #include <sfx2/ipclient.hxx>
42 #include <editeng/svxacorr.hxx>
43 #include <editeng/acorrcfg.hxx>
44 #include <cmdid.h>
45 #include <swtypes.hxx>
46 #include <wdocsh.hxx>
47 #include <wrtsh.hxx>
48 #include <pview.hxx>
49 #include <viewsh.hxx>
50 #include <pvprtdat.hxx>
51 #include <printdata.hxx>
52 #include <pagefrm.hxx>
53 #include <rootfrm.hxx>
54 #include <svl/stritem.hxx>
55 #include <unotxdoc.hxx>
56 #include <svl/numuno.hxx>
57 #include <fldbas.hxx>
58 #include <unomap.hxx>
59 #include <unotextbodyhf.hxx>
60 #include <unotextrange.hxx>
61 #include <unotextcursor.hxx>
62 #include <unosett.hxx>
63 #include <unocoll.hxx>
64 #include <unoredlines.hxx>
65 #include <unosrch.hxx>
66 #include <sfx2/request.hxx>
67 #include <sfx2/objsh.hxx>
68 #include <unoprnms.hxx>
69 #include <unostyle.hxx>
70 #include <unodraw.hxx>
71 #include <svl/eitem.hxx>
72 #include <unotools/datetime.hxx>
73 #include <unocrsr.hxx>
74 #include <unofieldcoll.hxx>
75 #include <unoidxcoll.hxx>
76 #include <unocrsrhelper.hxx>
77 #include <globdoc.hxx>
78 #include <viewopt.hxx>
79 #include <unochart.hxx>
80 #include <charatr.hxx>
81 #include <svx/xmleohlp.hxx>
82 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
83 #include <com/sun/star/lang/DisposedException.hpp>
84 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
85 #include <com/sun/star/lang/NoSupportException.hpp>
86 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
87 #include <com/sun/star/beans/PropertyAttribute.hpp>
88 #include <com/sun/star/beans/XFastPropertySet.hpp>
89 #include <com/sun/star/document/RedlineDisplayType.hpp>
90 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
91 #include <com/sun/star/frame/XController.hpp>
92 #include <com/sun/star/frame/XFrame.hpp>
93 #include <com/sun/star/script/XInvocation.hpp>
94 #include <com/sun/star/view/XSelectionSupplier.hpp>
95 #include <sfx2/linkmgr.hxx>
96 #include <svx/unofill.hxx>
97 #include <swmodule.hxx>
98 #include <docstat.hxx>
99 #include <modcfg.hxx>
100 #include <ndtxt.hxx>
101 #include <strings.hrc>
102 #include <bitmaps.hlst>
103 #include "unodefaults.hxx"
104 #include "SwXDocumentSettings.hxx"
105 #include <doc.hxx>
107 #include <IDocumentDeviceAccess.hxx>
112 #include <IDocumentFieldsAccess.hxx>
113 #include <IDocumentStatistics.hxx>
115 #include <IDocumentState.hxx>
116 #include <svl/zforlist.hxx>
117 #include <drawdoc.hxx>
118 #include <SwStyleNameMapper.hxx>
119 #include <osl/file.hxx>
120 #include <comphelper/lok.hxx>
123 #include <unotools/saveopt.hxx>
124 #include <swruler.hxx>
125 #include <docufld.hxx>
126 
127 
129 #include <numrule.hxx>
130 
131 #include <editeng/langitem.hxx>
132 #include <docary.hxx>
134 #include <i18nutil/searchopt.hxx>
135 
136 #include <charfmt.hxx>
137 #include <fmtcol.hxx>
138 #include <istyleaccess.hxx>
139 
140 #include <swatrset.hxx>
141 #include <view.hxx>
142 #include <viscrs.hxx>
143 #include <srcview.hxx>
144 #include <edtwin.hxx>
145 #include <swdtflvr.hxx>
146 #include <PostItMgr.hxx>
147 
148 #include <svtools/langtab.hxx>
149 #include <map>
150 #include <set>
151 #include <vector>
152 
153 #include <editeng/eeitem.hxx>
154 #include <editeng/editeng.hxx>
155 #include <editeng/editview.hxx>
156 #include <svx/svdoutl.hxx>
157 #include <svx/svdview.hxx>
159 #include <memory>
160 #include <redline.hxx>
162 #include <xmloff/odffields.hxx>
163 #include <tools/json_writer.hxx>
164 
165 #define TWIPS_PER_PIXEL 15
166 
167 using namespace ::com::sun::star;
168 using namespace ::com::sun::star::text;
169 using namespace ::com::sun::star::i18n;
170 using namespace ::com::sun::star::uno;
171 using namespace ::com::sun::star::beans;
172 using namespace ::com::sun::star::lang;
173 using namespace ::com::sun::star::container;
174 using namespace ::com::sun::star::document;
175 using ::osl::FileBase;
176 
177 static std::unique_ptr<SwPrintUIOptions> lcl_GetPrintUIOptions(
178  SwDocShell * pDocShell,
179  const SfxViewShell * pView )
180 {
181  if (!pDocShell)
182  return nullptr;
183 
184  const bool bWebDoc = nullptr != dynamic_cast< const SwWebDocShell * >(pDocShell);
185  const bool bSwSrcView = nullptr != dynamic_cast< const SwSrcView * >(pView);
186  const SwView * pSwView = dynamic_cast< const SwView * >(pView);
187  const bool bHasSelection = pSwView && pSwView->HasSelection( false ); // check for any selection, not just text selection
188  const bool bHasPostIts = sw_GetPostIts(pDocShell->GetDoc()->getIDocumentFieldsAccess(), nullptr);
189 
190  // get default values to use in dialog from documents SwPrintData
191  const SwPrintData &rPrintData = pDocShell->GetDoc()->getIDocumentDeviceAccess().getPrintData();
192 
193  // Get current page number
194  sal_uInt16 nCurrentPage = 1;
195  const SwWrtShell* pSh = pDocShell->GetWrtShell();
196  const SwRootFrame *pFrame = nullptr;
197  if (pSh)
198  {
199  SwPaM* pShellCursor = pSh->GetCursor();
200  nCurrentPage = pShellCursor->GetPageNum();
201  pFrame = pSh->GetLayout();
202  }
203  else if (!bSwSrcView)
204  {
205  const SwPagePreview* pPreview = dynamic_cast< const SwPagePreview* >(pView);
206  OSL_ENSURE(pPreview, "Unexpected type of the view shell");
207  if (pPreview)
208  {
209  nCurrentPage = pPreview->GetSelectedPage();
210  pFrame = pPreview->GetViewShell()->GetLayout();
211  }
212  }
213 
214  // If blanks are skipped, account for them in initial page range value
215  if (pFrame && !rPrintData.IsPrintEmptyPages())
216  {
217  sal_uInt16 nMax = nCurrentPage;
218  const SwPageFrame *pPage = dynamic_cast<const SwPageFrame*>(pFrame->Lower());
219  while (pPage && nMax-- > 0)
220  {
221  if (pPage->getFrameArea().Height() == 0)
222  nCurrentPage--;
223  pPage = static_cast<const SwPageFrame*>(pPage->GetNext());
224  }
225  }
226  return std::make_unique<SwPrintUIOptions>( nCurrentPage, bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData );
227 }
228 
229 static SwTextFormatColl *lcl_GetParaStyle(const OUString& rCollName, SwDoc& rDoc)
230 {
231  SwTextFormatColl* pColl = rDoc.FindTextFormatCollByName( rCollName );
232  if( !pColl )
233  {
234  const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
235  rCollName, SwGetPoolIdFromName::TxtColl );
236  if( USHRT_MAX != nId )
237  pColl = rDoc.getIDocumentStylePoolAccess().GetTextCollFromPool( nId );
238  }
239  return pColl;
240 }
241 
242 static void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell const * pDocShell )
243 {
244  // check if the view frame still exists
245  SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell, false );
246  while(pFound)
247  {
248  if( pFound == pToClose)
249  {
250  pToClose->DoClose();
251  break;
252  }
253  pFound = SfxViewFrame::GetNext( *pFound, pDocShell, false );
254  }
255 }
256 
258 {
259 private:
260  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
261 
262 public:
264 
265  Impl() : m_RefreshListeners(m_Mutex) { }
266 
267 };
268 
269 namespace
270 {
271  class theSwXTextDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextDocumentUnoTunnelId > {};
272 }
273 
274 const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId()
275 {
276  return theSwXTextDocumentUnoTunnelId::get().getSeq();
277 }
278 
279 sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId )
280 {
281  if( isUnoTunnelId<SwXTextDocument>(rId) )
282  {
283  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
284  }
285  if( isUnoTunnelId<SfxObjectShell>(rId) )
286  {
287  return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(m_pDocShell ));
288  }
289 
290  sal_Int64 nRet = SfxBaseModel::getSomething( rId );
291  if (nRet)
292  return nRet;
293 
295  if (!m_xNumFormatAgg.is()) // may happen if not valid or no SwDoc
296  return 0;
297  Any aNumTunnel = m_xNumFormatAgg->queryAggregation(cppu::UnoType<XUnoTunnel>::get());
298  Reference<XUnoTunnel> xNumTunnel;
299  aNumTunnel >>= xNumTunnel;
300  return (xNumTunnel.is()) ? xNumTunnel->getSomething(rId) : 0;
301 }
302 
304 {
305  Any aRet = SwXTextDocumentBaseClass::queryInterface(rType);
306  if ( !aRet.hasValue() )
307  aRet = SfxBaseModel::queryInterface(rType);
308  if ( !aRet.hasValue() &&
310  {
311  Reference<lang::XMultiServiceFactory> xTmp = this;
312  aRet <<= xTmp;
313  }
314  if ( !aRet.hasValue() &&
316  {
317  Reference<tiledrendering::XTiledRenderable> xTmp = this;
318  aRet <<= xTmp;
319  }
320 
321  if ( !aRet.hasValue()
328  {
330  if(m_xNumFormatAgg.is())
331  aRet = m_xNumFormatAgg->queryAggregation(rType);
332  }
333  return aRet;
334 }
335 
336 void SAL_CALL SwXTextDocument::acquire()throw()
337 {
339 }
340 
341 void SAL_CALL SwXTextDocument::release()throw()
342 {
344 }
345 
347 {
348  return SfxBaseModel::queryAdapter();
349 }
350 
351 Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes()
352 {
353  Sequence< uno::Type > aNumTypes;
355  if(m_xNumFormatAgg.is())
356  {
357  const uno::Type& rProvType = cppu::UnoType<XTypeProvider>::get();
358  Any aNumProv = m_xNumFormatAgg->queryAggregation(rProvType);
359  Reference<XTypeProvider> xNumProv;
360  if(aNumProv >>= xNumProv)
361  {
362  aNumTypes = xNumProv->getTypes();
363  }
364  }
367  SwXTextDocumentBaseClass::getTypes(),
368  aNumTypes,
369  Sequence {
372 }
373 
375  : SfxBaseModel(pShell)
376  , m_pImpl(new Impl)
377  ,
378  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)),
379 
380  m_pDocShell(pShell),
381 
382  m_bObjectValid(pShell != nullptr),
383 
384  m_pDrawPage(nullptr),
385  mxXDrawPage(),
386  m_pBodyText(nullptr),
387  mxXNumberingRules(),
388  mxXFootnotes(),
389  mxXFootnoteSettings(),
390  mxXEndnotes(),
391  mxXEndnoteSettings(),
392  mxXReferenceMarks(),
393  mxXTextFieldTypes(),
394  mxXTextFieldMasters(),
395  mxXTextSections(),
396  mxXBookmarks(),
397  mxXTextTables(),
398  mxXTextFrames(),
399  mxXGraphicObjects(),
400  mxXEmbeddedObjects(),
401  mxXStyleFamilies(),
402  mxXAutoStyles(),
403  mxXChapterNumbering(),
404  mxXDocumentIndexes(),
405 
406  mxXLineNumberingProperties(),
407  mxLinkTargetSupplier(),
408  mxXRedlines(),
409  m_pHiddenViewFrame(nullptr),
410  // #i117783#
411  m_bApplyPagePrintSettingsFromXPagePrintable( false )
412 {
413 }
414 
416 {
417  OSL_ENSURE(m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetOrCreateDrawModel(), "No SdrModel in SwDoc, should not happen");
419 }
420 
422 {
423  InitNewDoc();
424  if(m_xNumFormatAgg.is())
425  {
427  m_xNumFormatAgg->setDelegator(x0);
428  m_xNumFormatAgg = nullptr;
429  }
430  m_pPrintUIOptions.reset();
431  if (m_pRenderData && m_pRenderData->IsViewOptionAdjust())
432  { // rhbz#827695: this can happen if the last page is not printed
433  // the SwViewShell has been deleted already by SwView::~SwView
434  // FIXME: replace this awful implementation of XRenderable with
435  // something less insane that has its own view
436  m_pRenderData->ViewOptionAdjustCrashPreventionKludge();
437  }
438  m_pRenderData.reset();
439 }
440 
442 {
443  if(!mxPropertyHelper.is())
444  {
446  }
447  return mxPropertyHelper.get();
448 }
449 
451 {
452  if(!IsValid())
453  return;
454 
455  if(!m_xNumFormatAgg.is())
456  {
457  if ( m_pDocShell->GetDoc() )
458  {
461  Reference< util::XNumberFormatsSupplier > xTmp = pNumFormat;
462  m_xNumFormatAgg.set(xTmp, UNO_QUERY);
463  }
464  if(m_xNumFormatAgg.is())
465  m_xNumFormatAgg->setDelegator(static_cast<cppu::OWeakObject*>(static_cast<SwXTextDocumentBaseClass*>(this)));
466  }
467  else
468  {
469  const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
470  Any aNumTunnel = m_xNumFormatAgg->queryAggregation(rTunnelType);
471  SvNumberFormatsSupplierObj* pNumFormat = nullptr;
472  Reference< XUnoTunnel > xNumTunnel;
473  if(aNumTunnel >>= xNumTunnel)
474  {
475  pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
476  xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
477 
478  }
479  OSL_ENSURE(pNumFormat, "No number formatter available");
480  if (pNumFormat && !pNumFormat->GetNumberFormatter())
482  }
483 }
484 
485 Reference< XText > SwXTextDocument::getText()
486 {
487  SolarMutexGuard aGuard;
488  if(!IsValid())
489  throw DisposedException("", static_cast< XTextDocument* >(this));
490  if(!m_xBodyText.is())
491  {
494  }
495  return m_xBodyText;
496 }
497 
499 {
500  SolarMutexGuard aGuard;
501  if(!IsValid())
502  throw DisposedException("", static_cast< XTextDocument* >(this));
503 }
504 
506 {
507  SolarMutexGuard aGuard;
508  if(!IsValid())
509  throw DisposedException("", static_cast< XTextDocument* >(this));
510 
511  maActionArr.emplace_front(new UnoActionContext(m_pDocShell->GetDoc()));
512 }
513 
515 {
516  SolarMutexGuard aGuard;
517  if(maActionArr.empty())
518  throw RuntimeException("Nothing to unlock");
519 
520  maActionArr.pop_front();
521 }
522 
524 {
525  SolarMutexGuard aGuard;
526  return !maActionArr.empty();
527 }
528 
529 Reference< frame::XController > SwXTextDocument::getCurrentController()
530 {
532 }
533 
534 void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController)
535 {
537 }
538 
540 {
541  SolarMutexGuard aGuard;
543  if(IsValid())
544  {
545  SwView* pView = static_cast<SwView*>(SfxViewShell::GetFirst(true, checkSfxViewShell<SwView>));
546  while(pView && pView->GetObjectShell() != m_pDocShell)
547  {
548  pView = static_cast<SwView*>(SfxViewShell::GetNext(*pView, true, checkSfxViewShell<SwView>));
549  }
550  if(pView)
551  {
552  Any aRef = pView->GetUNOObject()->getSelection();
553  aRef >>= xRef;
554  }
555  }
556  return xRef;
557 }
558 
560 {
561  return SfxBaseModel::attachResource(aURL, aArgs);
562 }
563 
565 {
566  return SfxBaseModel::getURL();
567 }
568 
570 {
571  return SfxBaseModel::getArgs();
572 }
573 
574 void SwXTextDocument::connectController(const Reference< frame::XController > & xController)
575 {
576  SfxBaseModel::connectController(xController);
577 }
578 
579 void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController)
580 {
582 }
583 
585 {
586  // Delete UnoActionContexts before deleting the SwDoc, as the first has unowned pointers to the
587  // second.
588  maActionArr.clear();
589 
591 }
592 
593 void SwXTextDocument::close( sal_Bool bDeliverOwnership )
594 {
595  if(m_pDocShell)
596  {
597  uno::Sequence< uno::Any > aArgs;
599  }
600  SolarMutexGuard aGuard;
601  if(IsValid() && m_pHiddenViewFrame)
603  SfxBaseModel::close(bDeliverOwnership);
604 }
605 
606 void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener)
607 {
609 }
610 
611 void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener)
612 {
614 }
615 
617 {
618  SolarMutexGuard aGuard;
619  if(!IsValid())
620  throw DisposedException("", static_cast< XTextDocument* >(this));
621 
623  {
625  }
627 }
628 
629 Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules()
630 {
631  SolarMutexGuard aGuard;
632  if(!IsValid())
633  throw DisposedException("", static_cast< XTextDocument* >(this));
634  if(!mxXChapterNumbering.is())
635  {
637  }
638  return mxXChapterNumbering;
639 }
640 
641 Reference< XIndexAccess > SwXTextDocument::getNumberingRules()
642 {
643  SolarMutexGuard aGuard;
644  if(!IsValid())
645  throw DisposedException("", static_cast< XTextDocument* >(this));
646  if(!mxXNumberingRules.is() )
647  {
649  }
650  return mxXNumberingRules;
651 }
652 
653 Reference< XIndexAccess > SwXTextDocument::getFootnotes()
654 {
655  SolarMutexGuard aGuard;
656  if(!IsValid())
657  throw DisposedException("", static_cast< XTextDocument* >(this));
658  if(!mxXFootnotes.is())
659  {
660  mxXFootnotes = new SwXFootnotes(false, m_pDocShell->GetDoc());
661  }
662  return mxXFootnotes;
663 }
664 
667 {
668  SolarMutexGuard aGuard;
669  if(!IsValid())
670  throw DisposedException("", static_cast< XTextDocument* >(this));
671  if(!mxXFootnoteSettings.is())
672  {
674  }
675  return mxXFootnoteSettings;
676 }
677 
678 Reference< XIndexAccess > SwXTextDocument::getEndnotes()
679 {
680  SolarMutexGuard aGuard;
681  if(!IsValid())
682  throw DisposedException("", static_cast< XTextDocument* >(this));
683  if(!mxXEndnotes.is())
684  {
685  mxXEndnotes = new SwXFootnotes(true, m_pDocShell->GetDoc());
686  }
687  return mxXEndnotes;
688 }
689 
691 {
692  SolarMutexGuard aGuard;
693  if(!IsValid())
694  throw DisposedException("", static_cast< XTextDocument* >(this));
695  if(!mxXEndnoteSettings.is())
696  {
698  }
699  return mxXEndnoteSettings;
700 }
701 
702 Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor()
703 {
704  SolarMutexGuard aGuard;
705  Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch;
706  return xRet;
707 }
708 
709 SwUnoCursor* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCursor)
710 {
711  getText();
712  XText *const pText = m_xBodyText.get();
713  SwXBodyText* pBText = static_cast<SwXBodyText*>(pText);
714  SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true);
715  xCursor.set( static_cast<text::XWordCursor*>(pXTextCursor) );
716 
717  auto& rUnoCursor(pXTextCursor->GetCursor());
718  rUnoCursor.SetRemainInSection(false);
719  return &rUnoCursor;
720 }
721 
722 sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc)
723 {
724  SolarMutexGuard aGuard;
725  Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY_THROW);
726  if(!IsValid() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
727  throw DisposedException("", static_cast< XTextDocument* >(this));
728 
729  Reference< XTextCursor > xCursor;
730  auto pUnoCursor(CreateCursorForSearch(xCursor));
731 
732  const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
733  xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
734 
736 
737  i18nutil::SearchOptions2 aSearchOpt;
738  pSearch->FillSearchOptions( aSearchOpt );
739 
742 
743  // Search should take place anywhere
744  pUnoCursor->SetRemainInSection(false);
745  sal_uInt32 nResult;
746  UnoActionContext aContext(m_pDocShell->GetDoc());
747  //try attribute search first
748  if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes())
749  {
754  SfxItemSet aReplace(m_pDocShell->GetDoc()->GetAttrPool(),
755  svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1,
756  RES_PARATR_BEGIN, RES_PARATR_END-1,
758  pSearch->FillSearchItemSet(aSearch);
759  pSearch->FillReplaceItemSet(aReplace);
760  bool bCancel;
761  nResult = static_cast<sal_Int32>(pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
762  eStart, eEnd, bCancel,
763  static_cast<FindRanges>(eRanges),
764  !pSearch->m_sSearchText.isEmpty() ? &aSearchOpt : nullptr,
765  &aReplace ));
766  }
767  else if(pSearch->m_bStyles)
768  {
769  SwTextFormatColl *pSearchColl = lcl_GetParaStyle(pSearch->m_sSearchText, pUnoCursor->GetDoc());
770  SwTextFormatColl *pReplaceColl = lcl_GetParaStyle(pSearch->m_sReplaceText, pUnoCursor->GetDoc());
771 
772  bool bCancel;
773  nResult = pUnoCursor->FindFormat(*pSearchColl,
774  eStart, eEnd, bCancel,
775  static_cast<FindRanges>(eRanges), pReplaceColl );
776 
777  }
778  else
779  {
780  //todo/mba: assuming that notes should be omitted
781  bool bCancel;
782  nResult = pUnoCursor->Find_Text(aSearchOpt, false/*bSearchInNotes*/,
783  eStart, eEnd, bCancel,
784  static_cast<FindRanges>(eRanges),
785  true );
786  }
787  return static_cast<sal_Int32>(nResult);
788 
789 }
790 
791 Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor()
792 {
793  SolarMutexGuard aGuard;
794  Reference< util::XSearchDescriptor > xRet = new SwXTextSearch;
795  return xRet;
796 
797 }
798 
799 // Used for findAll/First/Next
800 
801 SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
802  Reference< XTextCursor > & xCursor,
803  bool bAll,
804  sal_Int32& nResult,
805  Reference< XInterface > const & xLastResult)
806 {
807  const auto pSearch = comphelper::getUnoTunnelImplementation<SwXTextSearch>(xDesc);
808  if(!IsValid() || !pSearch)
809  return nullptr;
810 
811  auto pUnoCursor(CreateCursorForSearch(xCursor));
812 
813  bool bParentInExtra = false;
814  if(xLastResult.is())
815  {
816  Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
817  OTextCursorHelper* pPosCursor = nullptr;
818  if(xCursorTunnel.is())
819  {
820  pPosCursor = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
822  }
823  SwPaM* pCursor = pPosCursor ? pPosCursor->GetPaM() : nullptr;
824  if(pCursor)
825  {
826  *pUnoCursor->GetPoint() = *pCursor->End();
827  pUnoCursor->DeleteMark();
828  }
829  else
830  {
831  SwXTextRange* pRange = nullptr;
832  if(xCursorTunnel.is())
833  {
834  pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
836  }
837  if(!pRange)
838  return nullptr;
839  pRange->GetPositions(*pUnoCursor);
840  if(pUnoCursor->HasMark())
841  {
842  if(*pUnoCursor->GetPoint() < *pUnoCursor->GetMark())
843  pUnoCursor->Exchange();
844  pUnoCursor->DeleteMark();
845  }
846  }
847  const SwNode& rRangeNode = pUnoCursor->GetNode();
848  bParentInExtra = rRangeNode.FindFlyStartNode() ||
849  rRangeNode.FindFootnoteStartNode() ||
850  rRangeNode.FindHeaderStartNode() ||
851  rRangeNode.FindFooterStartNode() ;
852  }
853 
854  i18nutil::SearchOptions2 aSearchOpt;
855  pSearch->FillSearchOptions( aSearchOpt );
856 
866  if(bParentInExtra)
867  eRanges = FindRanges::InOther;
868  if(bAll) //always - everywhere?
869  eRanges = FindRanges::InSelAll;
870  SwDocPositions eStart = !bAll ? SwDocPositions::Curr : pSearch->m_bBack ? SwDocPositions::End : SwDocPositions::Start;
871  SwDocPositions eEnd = pSearch->m_bBack ? SwDocPositions::Start : SwDocPositions::End;
872 
873  nResult = 0;
874  for (int nSearchProc = 0; nSearchProc < 2; ++nSearchProc)
875  {
876  //try attribute search first
877  if(pSearch->HasSearchAttributes())
878  {
879  SfxItemSet aSearch(
881  svl::Items<
886  pSearch->FillSearchItemSet(aSearch);
887  bool bCancel;
888  nResult = static_cast<sal_Int32>(pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
889  eStart, eEnd, bCancel,
890  eRanges,
891  !pSearch->m_sSearchText.isEmpty() ? &aSearchOpt : nullptr ));
892  }
893  else if(pSearch->m_bStyles)
894  {
895  SwTextFormatColl *pSearchColl = lcl_GetParaStyle(pSearch->m_sSearchText, pUnoCursor->GetDoc());
896  //pSearch->sReplaceText
897  SwTextFormatColl *pReplaceColl = nullptr;
898  bool bCancel;
899  nResult = static_cast<sal_Int32>(pUnoCursor->FindFormat(*pSearchColl,
900  eStart, eEnd, bCancel,
901  eRanges, pReplaceColl ));
902  }
903  else
904  {
905  //todo/mba: assuming that notes should be omitted
906  bool bCancel;
907  nResult = static_cast<sal_Int32>(pUnoCursor->Find_Text(aSearchOpt, false/*bSearchInNotes*/,
908  eStart, eEnd, bCancel,
909  eRanges ));
910  }
911  if(nResult || (eRanges&(FindRanges::InSelAll|FindRanges::InOther)))
912  break;
913  //second step - find in other
914  eRanges = FindRanges::InOther;
915  }
916  return pUnoCursor;
917 }
918 
919 Reference< XIndexAccess >
920  SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc)
921 {
922  SolarMutexGuard aGuard;
924  sal_Int32 nResult = 0;
925  Reference< XTextCursor > xCursor;
926  auto pResultCursor(FindAny(xDesc, xCursor, true, nResult, xTmp));
927  if(!pResultCursor)
928  throw RuntimeException("No result cursor");
929  Reference< XIndexAccess > xRet = SwXTextRanges::Create( nResult ? &(*pResultCursor) : nullptr );
930  return xRet;
931 }
932 
933 Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc)
934 {
935  SolarMutexGuard aGuard;
937  sal_Int32 nResult = 0;
938  Reference< XTextCursor > xCursor;
939  auto pResultCursor(FindAny(xDesc, xCursor, false, nResult, xTmp));
940  if(!pResultCursor)
941  throw RuntimeException("No result cursor");
943  if(nResult)
944  {
945  const uno::Reference< text::XText > xParent =
947  *pResultCursor->GetPoint());
948  xRet = *new SwXTextCursor(xParent, *pResultCursor);
949  }
950  return xRet;
951 }
952 
954  const Reference< util::XSearchDescriptor > & xDesc)
955 {
956  SolarMutexGuard aGuard;
957  sal_Int32 nResult = 0;
958  Reference< XTextCursor > xCursor;
959  if(!xStartAt.is())
960  throw RuntimeException("xStartAt missing");
961  auto pResultCursor(FindAny(xDesc, xCursor, false, nResult, xStartAt));
962  if(!pResultCursor)
963  throw RuntimeException("No result cursor");
965  if(nResult)
966  {
967  const uno::Reference< text::XText > xParent =
969  *pResultCursor->GetPoint());
970 
971  xRet = *new SwXTextCursor(xParent, *pResultCursor);
972  }
973  return xRet;
974 }
975 
977 {
978  SolarMutexGuard aGuard;
980  if(!IsValid())
981  throw DisposedException("", static_cast< XTextDocument* >(this));
982 
983  beans::PropertyValue* pArray = aSeq.getArray();
986  if(pData)
987  aData = *pData;
988  Any aVal;
989  aVal <<= static_cast<sal_Int16>(aData.GetRow());
990  pArray[0] = beans::PropertyValue("PageRows", -1, aVal, PropertyState_DIRECT_VALUE);
991  aVal <<= static_cast<sal_Int16>(aData.GetCol());
992  pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE);
993  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetLeftSpace()));
994  pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE);
995  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetRightSpace()));
996  pArray[3] = beans::PropertyValue("RightMargin", -1, aVal, PropertyState_DIRECT_VALUE);
997  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetTopSpace()));
998  pArray[4] = beans::PropertyValue("TopMargin", -1, aVal, PropertyState_DIRECT_VALUE);
999  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetBottomSpace()));
1000  pArray[5] = beans::PropertyValue("BottomMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1001  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetHorzSpace()));
1002  pArray[6] = beans::PropertyValue("HoriMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1003  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetVertSpace()));
1004  pArray[7] = beans::PropertyValue("VertMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1005  aVal <<= aData.GetLandscape();
1006  pArray[8] = beans::PropertyValue("IsLandscape", -1, aVal, PropertyState_DIRECT_VALUE);
1007 
1008  return aSeq;
1009 }
1010 
1011 static sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, bool& bException)
1012 {
1013  bException = false;
1014  TypeClass eType = rValue.getValueType().getTypeClass();
1015 
1016  sal_uInt32 nRet = 0;
1017  if( eType == TypeClass_UNSIGNED_LONG )
1018  rValue >>= nRet;
1019  else
1020  {
1021  sal_Int32 nVal=0;
1022  bException = !(rValue >>= nVal);
1023  if( !bException )
1024  nRet = static_cast<sal_uInt32>(nVal);
1025  }
1026 
1027  return nRet;
1028 }
1029 
1030 static OUString lcl_CreateOutlineString( size_t nIndex,
1031  const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
1032 {
1033  OUStringBuffer sEntry;
1034  const SwTextNode * pTextNd = rOutlineNodes[ nIndex ]->GetTextNode();
1035  SwNumberTree::tNumberVector aNumVector = pTextNd->GetNumberVector();
1036  if( pOutlRule && pTextNd->GetNumRule())
1037  for( int nLevel = 0;
1038  nLevel <= pTextNd->GetActualListLevel();
1039  nLevel++ )
1040  {
1041  tools::Long nVal = aNumVector[nLevel];
1042  nVal ++;
1043  nVal -= pOutlRule->Get(nLevel).GetStart();
1044  sEntry.append(OUString::number( nVal ));
1045  sEntry.append(".");
1046  }
1047  sEntry.append( rOutlineNodes[ nIndex ]->
1048  GetTextNode()->GetExpandText(nullptr) );
1049  return sEntry.makeStringAndClear();
1050 }
1051 
1053 {
1054  SolarMutexGuard aGuard;
1055  if(!IsValid())
1056  throw DisposedException("", static_cast< XTextDocument* >(this));
1057 
1059  //if only a few properties are coming, then use the current settings
1061  if(pData)
1062  aData = *pData;
1063  for(const beans::PropertyValue& rProperty : aSettings)
1064  {
1065  OUString sName = rProperty.Name;
1066  const Any& rVal = rProperty.Value;
1067  bool bException;
1068  sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
1069  if( sName == "PageRows" )
1070  {
1071  if(!nVal || nVal > 0xff)
1072  throw RuntimeException("Invalid value");
1073  aData.SetRow(static_cast<sal_uInt8>(nVal));
1074  }
1075  else if(sName == "PageColumns")
1076  {
1077  if(!nVal || nVal > 0xff)
1078  throw RuntimeException("Invalid value");
1079  aData.SetCol(static_cast<sal_uInt8>(nVal));
1080  }
1081  else if(sName == "LeftMargin")
1082  {
1083  aData.SetLeftSpace(convertMm100ToTwip(nVal));
1084  }
1085  else if(sName == "RightMargin")
1086  {
1087  aData.SetRightSpace(convertMm100ToTwip(nVal));
1088  }
1089  else if(sName == "TopMargin")
1090  {
1091  aData.SetTopSpace(convertMm100ToTwip(nVal));
1092  }
1093  else if(sName == "BottomMargin")
1094  {
1095  aData.SetBottomSpace(convertMm100ToTwip(nVal));
1096  }
1097  else if(sName == "HoriMargin")
1098  {
1099  aData.SetHorzSpace(convertMm100ToTwip(nVal));
1100  }
1101  else if(sName == "VertMargin")
1102  {
1103  aData.SetVertSpace(convertMm100ToTwip(nVal));
1104  }
1105  else if(sName == "IsLandscape")
1106  {
1107  auto b = o3tl::tryAccess<bool>(rVal);
1108  bException = !b;
1109  if (b)
1110  {
1111  aData.SetLandscape(*b);
1112  }
1113  }
1114  else
1115  bException = true;
1116  if(bException)
1117  throw RuntimeException();
1118  }
1119  m_pDocShell->GetDoc()->SetPreviewPrtData(&aData);
1120 
1121 }
1122 
1124 {
1125  SolarMutexGuard aGuard;
1126  if(!IsValid())
1127  throw DisposedException("", static_cast< XTextDocument* >(this));
1128 
1130  SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SfxCallMode::SYNCHRON,
1133 
1134  for ( const beans::PropertyValue &rProp : xOptions )
1135  {
1136  // get Property-Value from options
1137  Any aValue( rProp.Value );
1138 
1139  // FileName-Property?
1140  if ( rProp.Name == UNO_NAME_FILE_NAME )
1141  {
1142  OUString sFileURL;
1143  if ( rProp.Value >>= sFileURL )
1144  {
1145  // Convert the File URL into a system dependent path, as the SalPrinter expects
1146  OUString sSystemPath;
1147  FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
1148  aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
1149  }
1150  else if ( rProp.Value.getValueType() != cppu::UnoType<void>::get() )
1151  throw IllegalArgumentException();
1152  }
1153 
1154  // CopyCount-Property
1155  else if ( rProp.Name == UNO_NAME_COPY_COUNT )
1156  {
1157  sal_Int32 nCopies = 0;
1158  aValue >>= nCopies;
1159  aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, static_cast<sal_Int16>(nCopies) ) );
1160  }
1161 
1162  // Collate-Property
1163  else if ( rProp.Name == UNO_NAME_COLLATE )
1164  {
1165  auto b = o3tl::tryAccess<bool>(rProp.Value);
1166  if ( !b )
1167  throw IllegalArgumentException();
1168  aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *b ) );
1169 
1170  }
1171 
1172  // Sort-Property
1173  else if ( rProp.Name == UNO_NAME_SORT )
1174  {
1175  auto b = o3tl::tryAccess<bool>(rProp.Value);
1176  if ( !b )
1177  throw IllegalArgumentException();
1178 
1179  aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *b ) );
1180  }
1181 
1182  // Pages-Property
1183  else if ( rProp.Name == UNO_NAME_PAGES )
1184  {
1185  OUString sTmp;
1186  if ( !(rProp.Value >>= sTmp) )
1187  throw IllegalArgumentException();
1188 
1189  aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
1190 
1191  }
1192  }
1193 
1194  // #i117783#
1196  pFrame->GetViewShell()->ExecuteSlot(aReq);
1197  // Frame close
1198  pFrame->DoClose();
1199 
1200 }
1201 
1203 {
1204  SolarMutexGuard aGuard;
1205  if(!IsValid())
1206  throw DisposedException("", static_cast< XTextDocument* >(this));
1207  if(!mxXReferenceMarks.is())
1208  {
1210  }
1211  return mxXReferenceMarks;
1212 }
1213 
1214 Reference< XEnumerationAccess > SwXTextDocument::getTextFields()
1215 {
1216  SolarMutexGuard aGuard;
1217  if(!IsValid())
1218  throw DisposedException("", static_cast< XTextDocument* >(this));
1219  if(!mxXTextFieldTypes.is())
1220  {
1222  }
1223  return mxXTextFieldTypes;
1224 }
1225 
1227 {
1228  SolarMutexGuard aGuard;
1229  if(!IsValid())
1230  throw DisposedException("", static_cast< XTextDocument* >(this));
1231  if(!mxXTextFieldMasters.is())
1232  {
1234  }
1235  return mxXTextFieldMasters;
1236 }
1237 
1239 {
1240  SolarMutexGuard aGuard;
1241  if(!IsValid())
1242  throw DisposedException("", static_cast< XTextDocument* >(this));
1243  if(!mxXEmbeddedObjects.is())
1244  {
1246  }
1247  return mxXEmbeddedObjects;
1248 }
1249 
1251 {
1252  SolarMutexGuard aGuard;
1253  if(!IsValid())
1254  throw DisposedException("", static_cast< XTextDocument* >(this));
1255  if(!mxXBookmarks.is())
1256  {
1258  }
1259  return mxXBookmarks;
1260 }
1261 
1263 {
1264  SolarMutexGuard aGuard;
1265  if(!IsValid())
1266  throw DisposedException("", static_cast< XTextDocument* >(this));
1267  if(!mxXTextSections.is())
1268  {
1270  }
1271  return mxXTextSections;
1272 }
1273 
1275 {
1276  SolarMutexGuard aGuard;
1277  if(!IsValid())
1278  throw DisposedException("", static_cast< XTextDocument* >(this));
1279  if(!mxXTextTables.is())
1280  {
1282  }
1283  return mxXTextTables;
1284 }
1285 
1287 {
1288  SolarMutexGuard aGuard;
1289  if(!IsValid())
1290  throw DisposedException("", static_cast< XTextDocument* >(this));
1291  if(!mxXGraphicObjects.is())
1292  {
1294  }
1295  return mxXGraphicObjects;
1296 }
1297 
1299 {
1300  SolarMutexGuard aGuard;
1301  if(!IsValid())
1302  throw DisposedException("", static_cast< XTextDocument* >(this));
1303  if(!mxXTextFrames.is())
1304  {
1306  }
1307  return mxXTextFrames;
1308 }
1309 
1311 {
1312  SolarMutexGuard aGuard;
1313  if(!IsValid())
1314  throw DisposedException("", static_cast< XTextDocument* >(this));
1315  if(!mxXStyleFamilies.is())
1316  {
1318  }
1319  return mxXStyleFamilies;
1320 }
1321 
1322 uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
1323 {
1324  SolarMutexGuard aGuard;
1325  if(!IsValid())
1326  throw DisposedException("", static_cast< XTextDocument* >(this));
1327  if(!mxXAutoStyles.is())
1328  {
1330  }
1331  return mxXAutoStyles;
1332 
1333 }
1334 
1336 {
1337  SolarMutexGuard aGuard;
1338  if(!IsValid())
1339  throw DisposedException("", static_cast< XTextDocument* >(this));
1340  if(!mxXDrawPage.is())
1341  {
1344  // Create a Reference to trigger the complete initialization of the
1345  // object. Otherwise in some corner cases it would get initialized
1346  // at ::InitNewDoc -> which would get called during
1347  // close() or dispose() -> n#681746
1348  uno::Reference<lang::XComponent> xTriggerInit( mxXDrawPage, uno::UNO_QUERY );
1349  }
1350  return mxXDrawPage;
1351 }
1352 
1353 namespace {
1354 
1355 class SwDrawPagesObj : public cppu::WeakImplHelper<
1356  css::drawing::XDrawPages,
1357  css::lang::XServiceInfo>
1358 {
1359 private:
1360  css::uno::Reference< css::drawing::XDrawPageSupplier > m_xDoc;
1361 public:
1362  SwDrawPagesObj(const css::uno::Reference< css::drawing::XDrawPageSupplier >& rxDoc) : m_xDoc(rxDoc) {}
1363 
1364  // XDrawPages
1365  virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL
1366  insertNewByIndex(sal_Int32 /*nIndex*/) override { throw css::lang::NoSupportException(); }
1367 
1368  virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XDrawPage >& /*xPage*/) override
1369  {
1370  throw css::lang::NoSupportException();
1371  }
1372 
1373  // XIndexAccess
1374  virtual sal_Int32 SAL_CALL getCount() override { return 1; }
1375 
1376  virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
1377  {
1378  if (Index != 0)
1379  throw css::lang::IndexOutOfBoundsException("Writer documents have only one DrawPage!");
1380  return css::uno::Any(m_xDoc->getDrawPage());
1381  }
1382 
1383  // XElementAccess
1384  virtual css::uno::Type SAL_CALL getElementType() override
1385  {
1386  SolarMutexGuard aGuard;
1388  }
1389 
1390  virtual sal_Bool SAL_CALL hasElements() override { return true; }
1391 
1392  // XServiceInfo
1393  virtual OUString SAL_CALL getImplementationName() override
1394  {
1395  return "SwDrawPagesObj";
1396  }
1397 
1398  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override
1399  {
1400  return cppu::supportsService(this, ServiceName);
1401  }
1402 
1403  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1404  {
1405  return { "com.sun.star.drawing.DrawPages" };
1406  }
1407 };
1408 
1409 }
1410 
1411 // XDrawPagesSupplier
1412 
1413 uno::Reference<drawing::XDrawPages> SAL_CALL SwXTextDocument::getDrawPages()
1414 {
1415  SolarMutexGuard aGuard;
1416  return new SwDrawPagesObj(this);
1417 }
1418 
1420 {
1421  m_bObjectValid = false;
1422  if(m_xNumFormatAgg.is())
1423  {
1424  const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
1425  Any aNumTunnel = m_xNumFormatAgg->queryAggregation(rTunnelType);
1426  SvNumberFormatsSupplierObj* pNumFormat = nullptr;
1427  Reference< XUnoTunnel > xNumTunnel;
1428  if(aNumTunnel >>= xNumTunnel)
1429  {
1430  pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1431  xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1432  pNumFormat->SetNumberFormatter(nullptr);
1433  }
1434  OSL_ENSURE(pNumFormat, "No number formatter available");
1435  }
1436  InitNewDoc();
1437  m_pDocShell = nullptr;
1438  lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
1439  m_pImpl->m_RefreshListeners.disposeAndClear(ev);
1440 }
1441 
1443 {
1444  if(m_pDocShell && m_pDocShell != pNewDocShell)
1445  Invalidate();
1446  m_pDocShell = pNewDocShell;
1447  m_bObjectValid = true;
1448 }
1449 
1451 {
1452  // first invalidate all collections, then delete references and Set to zero
1453  if(mxXTextTables.is())
1454  {
1455  XNameAccess* pTables = mxXTextTables.get();
1456  static_cast<SwXTextTables*>(pTables)->Invalidate();
1457  mxXTextTables.clear();
1458  }
1459 
1460  if(mxXTextFrames.is())
1461  {
1462  XNameAccess* pFrames = mxXTextFrames.get();
1463  static_cast<SwXTextFrames*>(pFrames)->Invalidate();
1464  mxXTextFrames.clear();
1465  }
1466 
1467  if(mxXGraphicObjects.is())
1468  {
1469  XNameAccess* pFrames = mxXGraphicObjects.get();
1470  static_cast<SwXTextGraphicObjects*>(pFrames)->Invalidate();
1471  mxXGraphicObjects.clear();
1472  }
1473 
1474  if(mxXEmbeddedObjects.is())
1475  {
1476  XNameAccess* pOLE = mxXEmbeddedObjects.get();
1477  static_cast<SwXTextEmbeddedObjects*>(pOLE)->Invalidate();
1478  mxXEmbeddedObjects.clear();
1479  }
1480 
1481  if(m_xBodyText.is())
1482  {
1483  m_xBodyText = nullptr;
1484  m_pBodyText = nullptr;
1485  }
1486 
1487  if(m_xNumFormatAgg.is())
1488  {
1489  const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
1490  Any aNumTunnel = m_xNumFormatAgg->queryAggregation(rTunnelType);
1491  SvNumberFormatsSupplierObj* pNumFormat = nullptr;
1492  Reference< XUnoTunnel > xNumTunnel;
1493  if(aNumTunnel >>= xNumTunnel)
1494  {
1495  pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1496  xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1497 
1498  }
1499  OSL_ENSURE(pNumFormat, "No number formatter available");
1500  if (pNumFormat)
1501  pNumFormat->SetNumberFormatter(nullptr);
1502  }
1503 
1504  if(mxXTextFieldTypes.is())
1505  {
1506  XEnumerationAccess* pT = mxXTextFieldTypes.get();
1507  static_cast<SwXTextFieldTypes*>(pT)->Invalidate();
1508  mxXTextFieldTypes.clear();
1509  }
1510 
1511  if(mxXTextFieldMasters.is())
1512  {
1513  XNameAccess* pT = mxXTextFieldMasters.get();
1514  static_cast<SwXTextFieldMasters*>(pT)->Invalidate();
1515  mxXTextFieldMasters.clear();
1516  }
1517 
1518  if(mxXTextSections.is())
1519  {
1520  XNameAccess* pSect = mxXTextSections.get();
1521  static_cast<SwXTextSections*>(pSect)->Invalidate();
1522  mxXTextSections.clear();
1523  }
1524 
1525  if(mxXDrawPage.is())
1526  {
1527  // #i91798#, #i91895#
1528  // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
1529  uno::Reference<lang::XComponent> xComp( mxXDrawPage, uno::UNO_QUERY );
1530  xComp->dispose();
1532  mxXDrawPage.clear();
1533  }
1534 
1535  if ( mxXNumberingRules.is() )
1536  {
1537  XIndexAccess* pNum = mxXNumberingRules.get();
1538  static_cast<SwXNumberingRulesCollection*>(pNum)->Invalidate();
1539  mxXNumberingRules.clear();
1540  }
1541 
1542  if(mxXFootnotes.is())
1543  {
1544  XIndexAccess* pFootnote = mxXFootnotes.get();
1545  static_cast<SwXFootnotes*>(pFootnote)->Invalidate();
1546  mxXFootnotes.clear();
1547  }
1548 
1549  if(mxXEndnotes.is())
1550  {
1551  XIndexAccess* pFootnote = mxXEndnotes.get();
1552  static_cast<SwXFootnotes*>(pFootnote)->Invalidate();
1553  mxXEndnotes.clear();
1554  }
1555 
1556  if(mxXDocumentIndexes.is())
1557  {
1558  XIndexAccess* pIdxs = mxXDocumentIndexes.get();
1559  static_cast<SwXDocumentIndexes*>(pIdxs)->Invalidate();
1560  mxXDocumentIndexes.clear();
1561  }
1562 
1563  if(mxXStyleFamilies.is())
1564  {
1565  XNameAccess* pStyles = mxXStyleFamilies.get();
1566  static_cast<SwXStyleFamilies*>(pStyles)->Invalidate();
1567  mxXStyleFamilies.clear();
1568  }
1569  if(mxXAutoStyles.is())
1570  {
1571  XNameAccess* pStyles = mxXAutoStyles.get();
1572  static_cast<SwXAutoStyles*>(pStyles)->Invalidate();
1573  mxXAutoStyles.clear();
1574  }
1575 
1576  if(mxXBookmarks.is())
1577  {
1578  XNameAccess* pBm = mxXBookmarks.get();
1579  static_cast<SwXBookmarks*>(pBm)->Invalidate();
1580  mxXBookmarks.clear();
1581  }
1582 
1583  if(mxXChapterNumbering.is())
1584  {
1585  XIndexReplace* pCh = mxXChapterNumbering.get();
1586  static_cast<SwXChapterNumbering*>(pCh)->Invalidate();
1587  mxXChapterNumbering.clear();
1588  }
1589 
1590  if(mxXFootnoteSettings.is())
1591  {
1592  XPropertySet* pFntSet = mxXFootnoteSettings.get();
1593  static_cast<SwXFootnoteProperties*>(pFntSet)->Invalidate();
1594  mxXFootnoteSettings.clear();
1595  }
1596 
1597  if(mxXEndnoteSettings.is())
1598  {
1599  XPropertySet* pEndSet = mxXEndnoteSettings.get();
1600  static_cast<SwXEndnoteProperties*>(pEndSet)->Invalidate();
1601  mxXEndnoteSettings.clear();
1602  }
1603 
1605  {
1607  static_cast<SwXLineNumberingProperties*>(pLine)->Invalidate();
1609  }
1610  if(mxXReferenceMarks.is())
1611  {
1612  XNameAccess* pMarks = mxXReferenceMarks.get();
1613  static_cast<SwXReferenceMarks*>(pMarks)->Invalidate();
1614  mxXReferenceMarks.clear();
1615  }
1616  if(mxLinkTargetSupplier.is())
1617  {
1618  XNameAccess* pAccess = mxLinkTargetSupplier.get();
1619  static_cast<SwXLinkTargetSupplier*>(pAccess)->Invalidate();
1620  mxLinkTargetSupplier.clear();
1621  }
1622  if(mxXRedlines.is())
1623  {
1624  XEnumerationAccess* pMarks = mxXRedlines.get();
1625  static_cast<SwXRedlines*>(pMarks)->Invalidate();
1626  mxXRedlines.clear();
1627  }
1628  if(mxPropertyHelper.is())
1629  {
1630  mxPropertyHelper->Invalidate();
1631  mxPropertyHelper.clear();
1632  }
1633 }
1634 
1635 css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
1636  OUString const & rServiceName,
1637  css::uno::Sequence<css::uno::Any> const * arguments)
1638 {
1639  SolarMutexGuard aGuard;
1640  if (!IsValid())
1641  throw DisposedException("", static_cast< XTextDocument* >(this));
1642 
1644  if (nType != SwServiceType::Invalid)
1645  {
1647  }
1648  if (rServiceName == "com.sun.star.drawing.DashTable")
1649  {
1651  }
1652  if (rServiceName == "com.sun.star.drawing.GradientTable")
1653  {
1655  }
1656  if (rServiceName == "com.sun.star.drawing.HatchTable")
1657  {
1659  }
1660  if (rServiceName == "com.sun.star.drawing.BitmapTable")
1661  {
1663  }
1664  if (rServiceName == "com.sun.star.drawing.TransparencyGradientTable")
1665  {
1667  }
1668  if (rServiceName == "com.sun.star.drawing.MarkerTable")
1669  {
1671  }
1672  if (rServiceName == "com.sun.star.drawing.Defaults")
1673  {
1675  }
1676  if (rServiceName == "com.sun.star.document.Settings")
1677  {
1678  return Reference<XInterface>(*new SwXDocumentSettings(this));
1679  }
1680  if (rServiceName == "com.sun.star.document.ImportEmbeddedObjectResolver")
1681  {
1682  return static_cast<cppu::OWeakObject *>(
1684  *m_pDocShell, SvXMLEmbeddedObjectHelperMode::Read));
1685  }
1686  if (rServiceName == "com.sun.star.text.DocumentSettings")
1687  {
1688  return Reference<XInterface>(*new SwXDocumentSettings(this));
1689  }
1690  if (rServiceName == "com.sun.star.chart2.data.DataProvider")
1691  {
1692  return Reference<XInterface>(
1693  dynamic_cast<chart2::data::XDataProvider *>(
1695  GetChartDataProvider()));
1696  }
1697  if (!rServiceName.startsWith("com.sun.star.")
1698  || rServiceName.endsWith(".OLE2Shape"))
1699  {
1700  // We do not want to insert OLE2 Shapes (e.g.,
1701  // "com.sun.star.drawing.OLE2Shape", ...) like this (by creating them
1702  // with the documents factory and adding the shapes to the draw page);
1703  // for inserting OLE objects the proper way is to use
1704  // "com.sun.star.text.TextEmbeddedObject":
1705  throw ServiceNotRegisteredException();
1706  }
1707  // The XML import is allowed to create instances of
1708  // "com.sun.star.drawing.OLE2Shape"; thus, a temporary service name is
1709  // introduced to make this possible:
1710  OUString aTmpServiceName(rServiceName);
1711  if (rServiceName == "com.sun.star.drawing.temporaryForXMLImportOLE2Shape")
1712  {
1713  aTmpServiceName = "com.sun.star.drawing.OLE2Shape";
1714  }
1715  Reference<XInterface> xTmp(
1716  arguments == nullptr
1717  ? SvxFmMSFactory::createInstance(aTmpServiceName)
1719  aTmpServiceName, *arguments));
1720  if (rServiceName == "com.sun.star.drawing.GroupShape"
1721  || rServiceName == "com.sun.star.drawing.Shape3DSceneObject")
1722  {
1723  return *new SwXGroupShape(xTmp, m_pDocShell->GetDoc());
1724  }
1725  if (rServiceName.startsWith("com.sun.star.drawing."))
1726  {
1727  return *new SwXShape(xTmp, m_pDocShell->GetDoc());
1728  }
1729  return xTmp;
1730 }
1731 
1733 {
1734  return create(rServiceName, nullptr);
1735 }
1736 
1738  const OUString& ServiceSpecifier,
1739  const Sequence< Any >& Arguments)
1740 {
1741  return create(ServiceSpecifier, &Arguments);
1742 }
1743 
1745 {
1746  static Sequence< OUString > aServices;
1747  if ( !aServices.hasElements() )
1748  {
1750  auto i = comphelper::findValue(aRet, "com.sun.star.drawing.OLE2Shape");
1751  if (i != -1)
1752  {
1753  auto nLength = aRet.getLength();
1754  aRet[i] = aRet[nLength - 1];
1755  aRet.realloc( nLength - 1 );
1756  }
1758  aServices = comphelper::concatSequences(aRet, aOwn);
1759  }
1760 
1761  return aServices;
1762 }
1763 
1765 {
1766  return "SwXTextDocument";
1767  /* // Matching the .component information:
1768  return dynamic_cast<SwGlobalDocShell*>( pDocShell ) != nullptr
1769  ? OUString("com.sun.star.comp.Writer.GlobalDocument")
1770  : dynamic_cast<SwWebDocShell*>( pDocShell ) != nullptr
1771  ? OUString("com.sun.star.comp.Writer.WebDocument")
1772  : OUString("com.sun.star.comp.Writer.TextDocument");
1773  */
1774 }
1775 
1776 sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName)
1777 {
1778  return cppu::supportsService(this, rServiceName);
1779 }
1780 
1782 {
1783  bool bWebDoc = (dynamic_cast<SwWebDocShell*>( m_pDocShell) != nullptr );
1784  bool bGlobalDoc = (dynamic_cast<SwGlobalDocShell*>( m_pDocShell) != nullptr );
1785  bool bTextDoc = (!bWebDoc && !bGlobalDoc);
1786 
1787  Sequence< OUString > aRet (3);
1788  OUString* pArray = aRet.getArray();
1789 
1790  pArray[0] = "com.sun.star.document.OfficeDocument";
1791  pArray[1] = "com.sun.star.text.GenericTextDocument";
1792 
1793  if (bTextDoc)
1794  pArray[2] = "com.sun.star.text.TextDocument";
1795  else if (bWebDoc)
1796  pArray[2] = "com.sun.star.text.WebDocument";
1797  else if (bGlobalDoc)
1798  pArray[2] = "com.sun.star.text.GlobalDocument";
1799 
1800  return aRet;
1801 }
1802 
1803 Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes()
1804 {
1805  SolarMutexGuard aGuard;
1806  if(!IsValid())
1807  throw DisposedException("", static_cast< XTextDocument* >(this));
1808 
1809  if(!mxXDocumentIndexes.is())
1810  {
1812  }
1813  return mxXDocumentIndexes;
1814 }
1815 
1816 Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo()
1817 {
1818  static Reference< XPropertySetInfo > xRet = m_pPropSet->getPropertySetInfo();
1819  return xRet;
1820 }
1821 
1822 void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& aValue)
1823 {
1824  SolarMutexGuard aGuard;
1825  if(!IsValid())
1826  throw DisposedException("", static_cast< XTextDocument* >(this));
1827 
1828  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
1829 
1830  if(!pEntry)
1831  throw UnknownPropertyException(rPropertyName);
1832  if(pEntry->nFlags & PropertyAttribute::READONLY)
1833  throw PropertyVetoException();
1834  switch(pEntry->nWID)
1835  {
1836  case WID_DOC_CHAR_COUNT :
1837  case WID_DOC_PARA_COUNT :
1838  case WID_DOC_WORD_COUNT :
1839  throw RuntimeException(
1840  "bad WID",
1841  static_cast< cppu::OWeakObject * >(
1842  static_cast< SwXTextDocumentBaseClass * >(this)));
1843  case WID_DOC_WORD_SEPARATOR :
1844  {
1845  OUString sDelim;
1846  aValue >>= sDelim;
1847  SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim);
1848  }
1849  break;
1851  case WID_DOC_CHANGES_SHOW:
1852  {
1853  bool bSet = *o3tl::doAccess<bool>(aValue);
1855  if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
1856  {
1858  if( !bSet )
1860  }
1861  else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
1862  {
1863  eMode = bSet ? eMode|RedlineFlags::On : eMode&~RedlineFlags::On;
1864  }
1866  }
1867  break;
1869  {
1870  Sequence <sal_Int8> aNew;
1871  if(aValue >>= aNew)
1872  {
1873  SwDoc* pDoc = m_pDocShell->GetDoc();
1875  if(aNew.hasElements())
1876  {
1878  eMode |= RedlineFlags::On;
1879  pDoc->getIDocumentRedlineAccess().SetRedlineFlags( eMode );
1880  }
1881  }
1882  }
1883  break;
1884  case WID_DOC_AUTO_MARK_URL :
1885  {
1886  OUString sURL;
1887  aValue >>= sURL;
1889  }
1890  break;
1891  case WID_DOC_HIDE_TIPS :
1892  SW_MOD()->GetModuleConfig()->SetHideFieldTips(*o3tl::doAccess<bool>(aValue));
1893  break;
1895  {
1897  eRedMode = eRedMode & (~RedlineFlags::ShowMask);
1898  sal_Int16 nSet = 0;
1899  aValue >>= nSet;
1900  switch(nSet)
1901  {
1902  case RedlineDisplayType::NONE: break;
1903  case RedlineDisplayType::INSERTED: eRedMode |= RedlineFlags::ShowInsert; break;
1904  case RedlineDisplayType::REMOVED: eRedMode |= RedlineFlags::ShowDelete; break;
1905  case RedlineDisplayType::
1906  INSERTED_AND_REMOVED: eRedMode |= RedlineFlags::ShowInsert|RedlineFlags::ShowDelete;
1907  break;
1908  default: throw IllegalArgumentException();
1909  }
1911  }
1912  break;
1914  {
1915  sal_Int16 nYear = 0;
1916  aValue >>= nYear;
1917  SfxRequest aRequest ( SID_ATTR_YEAR2000, SfxCallMode::SLOT, m_pDocShell->GetDoc()->GetAttrPool());
1918  aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
1919  m_pDocShell->Execute ( aRequest );
1920  }
1921  break;
1923  {
1925  bool bAuto = *o3tl::doAccess<bool>(aValue);
1926 
1927  if ( nullptr != pDrawDoc )
1928  pDrawDoc->SetAutoControlFocus( bAuto );
1929  else if (bAuto)
1930  {
1931  // if setting to true, and we don't have an
1932  // SdrModel, then we are changing the default and
1933  // must thus create an SdrModel, if we don't have an
1934  // SdrModel and we are leaving the default at false,
1935  // we don't need to make an SdrModel and can do nothing
1936  // #i52858# - method name changed
1938  pDrawDoc->SetAutoControlFocus ( bAuto );
1939  }
1940  }
1941  break;
1943  {
1945  bool bMode = *o3tl::doAccess<bool>(aValue);
1946 
1947  if ( nullptr != pDrawDoc )
1948  pDrawDoc->SetOpenInDesignMode( bMode );
1949  else if (!bMode)
1950  {
1951  // if setting to false, and we don't have an
1952  // SdrModel, then we are changing the default and
1953  // must thus create an SdrModel, if we don't have an
1954  // SdrModel and we are leaving the default at true,
1955  // we don't need to make an SdrModel and can do
1956  // nothing
1957  // #i52858# - method name changed
1959  pDrawDoc->SetOpenInDesignMode ( bMode );
1960  }
1961  }
1962  break;
1963  // #i42634# New property to set the bInReading
1964  // flag at the document, used during binary import
1965  case WID_DOC_LOCK_UPDATES :
1966  {
1967  SwDoc* pDoc = m_pDocShell->GetDoc();
1968  bool bBool (false);
1969  if( aValue >>= bBool )
1970  {
1971  pDoc->SetInReading( bBool );
1972  }
1973  }
1974  break;
1975  case WID_DOC_WRITERFILTER:
1976  {
1977  SwDoc* pDoc = m_pDocShell->GetDoc();
1978  bool bBool = {};
1979  if (aValue >>= bBool)
1980  { // HACK: writerfilter has to use API to set this :(
1981  pDoc->SetInWriterfilterImport(bBool);
1982  }
1983  }
1984  break;
1985  case WID_DOC_BUILDID:
1986  aValue >>= maBuildId;
1987  break;
1988 
1990  {
1991  bool bDefaultPageMode( false );
1992  aValue >>= bDefaultPageMode;
1993  m_pDocShell->GetDoc()->SetDefaultPageMode( bDefaultPageMode );
1994  }
1995  break;
1997  setGrabBagItem(aValue);
1998  break;
1999 
2000  default:
2001  {
2002  const SfxPoolItem& rItem = m_pDocShell->GetDoc()->GetDefault(pEntry->nWID);
2003  std::unique_ptr<SfxPoolItem> pNewItem(rItem.Clone());
2004  pNewItem->PutValue(aValue, pEntry->nMemberId);
2005  m_pDocShell->GetDoc()->SetDefault(*pNewItem);
2006  }
2007  }
2008 }
2009 
2010 Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
2011 {
2012  SolarMutexGuard aGuard;
2013  if(!IsValid())
2014  throw DisposedException("", static_cast< XTextDocument* >(this));
2015 
2016  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
2017 
2018  if(!pEntry)
2019  throw UnknownPropertyException(rPropertyName);
2020  Any aAny;
2021  switch(pEntry->nWID)
2022  {
2023  case WID_DOC_ISTEMPLATEID :
2024  aAny <<= m_pDocShell->IsTemplate();
2025  break;
2026  case WID_DOC_CHAR_COUNT :
2027  case WID_DOC_PARA_COUNT :
2028  case WID_DOC_WORD_COUNT :
2029  {
2030  const SwDocStat& rStat(m_pDocShell->GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( false, true ));
2031  sal_Int32 nValue;
2032  switch(pEntry->nWID)
2033  {
2034  case WID_DOC_CHAR_COUNT :nValue = rStat.nChar;break;
2035  case WID_DOC_PARA_COUNT :nValue = rStat.nPara;break;
2036  case WID_DOC_WORD_COUNT :nValue = rStat.nWord;break;
2037  }
2038  aAny <<= nValue;
2039  }
2040  break;
2041  case WID_DOC_WORD_SEPARATOR :
2042  {
2043  aAny <<= SW_MOD()->GetDocStatWordDelim();
2044  }
2045  break;
2047  case WID_DOC_CHANGES_SHOW:
2048  {
2050  bool bSet = false;
2051  if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
2052  {
2054  }
2055  else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
2056  {
2057  bSet = bool(eMode & RedlineFlags::On);
2058  }
2059  aAny <<= bSet;
2060  }
2061  break;
2063  {
2064  SwDoc* pDoc = m_pDocShell->GetDoc();
2065  aAny <<= pDoc->getIDocumentRedlineAccess().GetRedlinePassword();
2066  }
2067  break;
2068  case WID_DOC_AUTO_MARK_URL :
2069  aAny <<= m_pDocShell->GetDoc()->GetTOIAutoMarkURL();
2070  break;
2071  case WID_DOC_HIDE_TIPS :
2072  aAny <<= SW_MOD()->GetModuleConfig()->IsHideFieldTips();
2073  break;
2075  {
2077  eRedMode = eRedMode & RedlineFlags::ShowMask;
2078  sal_Int16 nRet = RedlineDisplayType::NONE;
2079  if(RedlineFlags::ShowInsert == eRedMode)
2081  else if(RedlineFlags::ShowDelete == eRedMode)
2082  nRet = RedlineDisplayType::REMOVED;
2083  else if(RedlineFlags::ShowMask == eRedMode)
2084  nRet = RedlineDisplayType::INSERTED_AND_REMOVED;
2085  aAny <<= nRet;
2086  }
2087  break;
2089  {
2091  Reference<XForbiddenCharacters> xRet(static_cast<cppu::OWeakObject*>(mxPropertyHelper.get()), UNO_QUERY);
2092  aAny <<= xRet;
2093  }
2094  break;
2096  {
2097  aAny <<= static_cast < sal_Int16 > (m_pDocShell->GetDoc()->GetNumberFormatter ()->GetYear2000());
2098  }
2099  break;
2101  {
2103  bool bAuto;
2104  if ( nullptr != pDrawDoc )
2105  bAuto = pDrawDoc->GetAutoControlFocus();
2106  else
2107  bAuto = false;
2108  aAny <<= bAuto;
2109  }
2110  break;
2112  {
2114  bool bMode;
2115  if ( nullptr != pDrawDoc )
2116  bMode = pDrawDoc->GetOpenInDesignMode();
2117  else
2118  bMode = true;
2119  aAny <<= bMode;
2120  }
2121  break;
2123  aAny <<= m_pDocShell->GetBasicContainer();
2124  break;
2126  aAny <<= m_pDocShell->GetDialogContainer();
2127  break;
2128  case WID_DOC_VBA_DOCOBJ:
2129  {
2130  /* #i111553# This property provides the name of the constant that
2131  will be used to store this model in the global Basic manager.
2132  That constant will be equivalent to 'ThisComponent' but for
2133  each application, so e.g. a 'ThisExcelDoc' and a 'ThisWordDoc'
2134  constant can co-exist, as required by VBA. */
2135  aAny <<= OUString( "ThisWordDoc" );
2136  }
2137  break;
2138  case WID_DOC_RUNTIME_UID:
2139  aAny <<= getRuntimeUID();
2140  break;
2141  case WID_DOC_LOCK_UPDATES :
2142  aAny <<= m_pDocShell->GetDoc()->IsInReading();
2143  break;
2144  case WID_DOC_BUILDID:
2145  aAny <<= maBuildId;
2146  break;
2148  aAny <<= hasValidSignatures();
2149  break;
2151  getGrabBagItem(aAny);
2152  break;
2153 
2154  default:
2155  {
2156  const SfxPoolItem& rItem = m_pDocShell->GetDoc()->GetDefault(pEntry->nWID);
2157  rItem.QueryValue(aAny, pEntry->nMemberId);
2158  }
2159  }
2160  return aAny;
2161 }
2162 
2163 void SwXTextDocument::addPropertyChangeListener(const OUString& /*PropertyName*/,
2164  const Reference< XPropertyChangeListener > & /*aListener*/)
2165 {
2166  OSL_FAIL("not implemented");
2167 }
2168 
2169 void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/,
2170  const Reference< XPropertyChangeListener > & /*aListener*/)
2171 {
2172  OSL_FAIL("not implemented");
2173 }
2174 
2175 void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/,
2176  const Reference< XVetoableChangeListener > & /*aListener*/)
2177 {
2178  OSL_FAIL("not implemented");
2179 }
2180 
2181 void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/,
2182  const Reference< XVetoableChangeListener > & /*aListener*/)
2183 {
2184  OSL_FAIL("not implemented");
2185 }
2186 
2188 {
2189  if(!mxLinkTargetSupplier.is())
2190  {
2192  }
2193  return mxLinkTargetSupplier;
2194 }
2195 
2196 Reference< XEnumerationAccess > SwXTextDocument::getRedlines( )
2197 {
2198  if(!mxXRedlines.is())
2199  {
2201  }
2202  return mxXRedlines;
2203 }
2204 
2206 {
2207  // why does SwBaseShell not just call refresh? maybe because it's rSh is
2208  // (sometimes) a different shell than GetWrtShell()?
2209  lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
2210  m_pImpl->m_RefreshListeners.notifyEach(
2211  & util::XRefreshListener::refreshed, ev);
2212 }
2213 
2215 {
2216  SolarMutexGuard aGuard;
2217  if(!IsValid())
2218  throw DisposedException("", static_cast< XTextDocument* >(this));
2219 
2220  SwViewShell *pViewShell = m_pDocShell->GetWrtShell();
2222  if(pViewShell)
2223  pViewShell->CalcLayout();
2224 }
2225 
2227  const Reference<util::XRefreshListener> & xListener)
2228 {
2229  // no need to lock here as m_pImpl is const and container threadsafe
2230  m_pImpl->m_RefreshListeners.addInterface(xListener);
2231 }
2232 
2234  const Reference<util::XRefreshListener> & xListener)
2235 {
2236  // no need to lock here as m_pImpl is const and container threadsafe
2237  m_pImpl->m_RefreshListeners.removeInterface(xListener);
2238 }
2239 
2241 {
2242  SolarMutexGuard aGuard;
2243  if(!IsValid())
2244  throw DisposedException("", static_cast< XTextDocument* >(this));
2245 
2246  SwDoc* pDoc = m_pDocShell->GetDoc();
2248  if( !rLnkMan.GetLinks().empty() )
2249  {
2250  UnoActionContext aAction(pDoc);
2251  rLnkMan.UpdateAllLinks( false, true, nullptr );
2252  }
2253 }
2254 
2255 //XPropertyState
2256 PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName )
2257 {
2258  SolarMutexGuard aGuard;
2259  if(!IsValid())
2260  throw DisposedException("", static_cast< XTextDocument* >(this));
2261 
2262  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
2263  if(!pEntry)
2264  throw UnknownPropertyException(rPropertyName);
2265  return PropertyState_DIRECT_VALUE;
2266 }
2267 
2268 Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames )
2269 {
2270  const sal_Int32 nCount = rPropertyNames.getLength();
2271  Sequence < PropertyState > aRet ( nCount );
2272 
2273  std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.begin(),
2274  [this](const OUString& rName) -> PropertyState { return getPropertyState(rName); });
2275 
2276  return aRet;
2277 }
2278 
2279 void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName )
2280 {
2281  SolarMutexGuard aGuard;
2282  if(!IsValid())
2283  throw DisposedException("", static_cast< XTextDocument* >(this));
2284 
2285  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
2286  if(!pEntry)
2287  throw UnknownPropertyException(rPropertyName);
2288  switch(pEntry->nWID)
2289  {
2290  case 0:default:break;
2291  }
2292 }
2293 
2294 Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName )
2295 {
2296  SolarMutexGuard aGuard;
2297  if(!IsValid())
2298  throw DisposedException("", static_cast< XTextDocument* >(this));
2299 
2300  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
2301  if(!pEntry)
2302  throw UnknownPropertyException(rPropertyName);
2303  Any aAny;
2304  switch(pEntry->nWID)
2305  {
2306  case 0:default:break;
2307  }
2308  return aAny;
2309 }
2310 
2312 {
2314 
2315  uno::Any aAny( rPrintUIOptions.getValue( "RenderDevice" ));
2316  uno::Reference< awt::XDevice > xRenderDevice;
2317  aAny >>= xRenderDevice;
2318  if (xRenderDevice.is())
2319  {
2320  VCLXDevice* pDevice = comphelper::getUnoTunnelImplementation<VCLXDevice>( xRenderDevice );
2321  pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
2322  }
2323 
2324  return pOut;
2325 }
2326 
2328  const uno::Sequence< beans::PropertyValue >& rOptions,
2329  const char *pPropName )
2330 {
2331  return std::any_of(rOptions.begin(), rOptions.end(),
2332  [&pPropName](const beans::PropertyValue& rProp) {
2333  return rProp.Name.equalsAscii( pPropName ); });
2334 }
2335 
2337  const uno::Sequence< beans::PropertyValue >& rOptions,
2338  const char *pPropName )
2339 {
2340  bool bRes = false;
2341  auto pOption = std::find_if(rOptions.begin(), rOptions.end(),
2342  [&pPropName](const beans::PropertyValue& rProp) {
2343  return rProp.Name.equalsAscii( pPropName ); });
2344  if (pOption != rOptions.end())
2345  pOption->Value >>= bRes;
2346  return bRes;
2347 }
2348 
2350  bool &rbIsSwSrcView,
2351  const uno::Sequence< beans::PropertyValue >& rOptions,
2352  bool bIsPDFExport )
2353 {
2354  // get view shell to use
2355  SfxViewShell *pView = nullptr;
2356  if (bIsPDFExport)
2357  pView = GuessViewShell( rbIsSwSrcView );
2358  else
2359  {
2360  uno::Any aTmp;
2361  auto pOption = std::find_if(rOptions.begin(), rOptions.end(),
2362  [](const beans::PropertyValue& rProp) { return rProp.Name == "View"; });
2363  if (pOption != rOptions.end())
2364  aTmp = pOption->Value;
2365 
2366  uno::Reference< frame::XController > xController;
2367  if (aTmp >>= xController)
2368  {
2369  OSL_ENSURE( xController.is(), "controller is empty!" );
2370  pView = GuessViewShell( rbIsSwSrcView, xController );
2371  }
2372  }
2373  return pView;
2374 }
2375 
2376 /*
2377  * GetRenderDoc:
2378  * returns the document to be rendered, usually this will be the 'regular'
2379  * document but in case of PDF export of (multi-)selection it will
2380  * be a temporary document that gets created if not already done.
2381  * The rpView variable will be set (if not already done) to the used
2382  * SfxViewShell.
2383 */
2385  SfxViewShell *&rpView,
2386  const uno::Any& rSelection,
2387  bool bIsPDFExport )
2388 {
2389  SwDoc *pDoc = nullptr;
2390 
2391  uno::Reference< frame::XModel > xModel;
2392  rSelection >>= xModel;
2393  if (xModel == m_pDocShell->GetModel())
2394  pDoc = m_pDocShell->GetDoc();
2395  else
2396  {
2397  OSL_ENSURE( !xModel.is(), "unexpected model found" );
2398 
2399  if (rSelection.hasValue()) // is anything selected ?
2400  {
2401  // this part should only be called when a temporary document needs to be created,
2402  // for example for PDF export or printing of (multi-)selection only.
2403 
2404  if (!rpView)
2405  {
2406  bool bIsSwSrcView = false;
2407  // aside from maybe PDF export the view should always have been provided!
2408  OSL_ENSURE( bIsPDFExport, "view is missing, guessing one..." );
2409 
2410  rpView = GuessViewShell( bIsSwSrcView );
2411  }
2412  OSL_ENSURE( rpView, "SwViewShell missing" );
2413  // the view shell should be SwView for documents PDF export.
2414  // for the page preview no selection should be possible
2415  // (the export dialog does not allow for this option)
2416  if (auto pSwView = dynamic_cast<SwView *>( rpView ))
2417  {
2418  if (!m_pRenderData)
2419  {
2420  OSL_FAIL("GetRenderDoc: no renderdata");
2421  return nullptr;
2422  }
2423  SfxObjectShellLock xDocSh(m_pRenderData->GetTempDocShell());
2424  if (!xDocSh.Is())
2425  {
2426  xDocSh = pSwView->CreateTmpSelectionDoc();
2427  m_pRenderData->SetTempDocShell(xDocSh);
2428  }
2429  if (xDocSh.Is())
2430  {
2431  pDoc = static_cast<SwDocShell*>(&xDocSh)->GetDoc();
2432  rpView = pDoc->GetDocShell()->GetView();
2433  }
2434  }
2435  else
2436  {
2437  OSL_FAIL("unexpected SwViewShell" );
2438  }
2439  }
2440  }
2441  return pDoc;
2442 }
2443 
2445  SwDoc &rDoc,
2446  const SwPrintUIOptions &rPrintUIOptions,
2447  bool bIsPDFEXport )
2448 {
2449  SwPrintData aDocPrintData( rDoc.getIDocumentDeviceAccess().getPrintData() );
2450 
2451  aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() );
2452  aDocPrintData.SetPrintTable( true ); // for now it was decided that tables should always be printed
2453  aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() );
2454  aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() );
2455  aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() );
2456  aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() );
2457  aDocPrintData.SetPrintReverse( false ); /*handled by print dialog now*/
2458  aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() );
2459  aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) );
2460  aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() );
2461  aDocPrintData.SetPrintProspect( rPrintUIOptions.IsPrintProspect() );
2462  aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() );
2463  aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() );
2464  aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() );
2465  // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself
2466  // arDocPrintData.SetFaxName( s ); n/a in File/Print dialog
2467  aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() );
2468  aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() );
2469 
2470  rDoc.getIDocumentDeviceAccess().setPrintData( aDocPrintData );
2471 }
2472 
2474  const uno::Any& rSelection,
2475  const uno::Sequence< beans::PropertyValue >& rxOptions )
2476 {
2477  SolarMutexGuard aGuard;
2478  if(!IsValid())
2479  {
2480  throw DisposedException( OUString(),
2481  static_cast< XTextDocument* >(this) );
2482  }
2483 
2484  const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
2485  bool bIsSwSrcView = false;
2486  SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2487 
2488  if (!bIsSwSrcView && !m_pRenderData)
2489  m_pRenderData.reset(new SwRenderData);
2490  if (!m_pPrintUIOptions)
2492  bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions );
2493 
2494  SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2495  OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2496  if (!pDoc || !pView)
2497  return 0;
2498 
2499  // save current UI options from the print dialog for the next call to that dialog
2501 
2502  sal_Int32 nRet = 0;
2503  if (bIsSwSrcView)
2504  {
2505  SwSrcView& rSwSrcView = dynamic_cast<SwSrcView&>(*pView);
2507  nRet = rSwSrcView.PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ );
2508  }
2509  else
2510  {
2511  SwDocShell *pRenderDocShell = pDoc->GetDocShell();
2512 
2513  // TODO/mba: we really need a generic way to get the SwViewShell!
2514  SwViewShell* pViewShell = nullptr;
2515  SwView* pSwView = dynamic_cast<SwView*>( pView );
2516  if ( pSwView )
2517  {
2518  pViewShell = pSwView->GetWrtShellPtr();
2519  }
2520  else
2521  {
2522  if ( bIsPDFExport && bFormat )
2523  {
2524  //create a hidden view to be able to export as PDF also in print preview
2525  //pView and pSwView are not changed intentionally!
2527  pViewShell = static_cast<SwView*>(m_pHiddenViewFrame->GetViewShell())->GetWrtShellPtr();
2528  }
2529  else
2530  pViewShell = static_cast<SwPagePreview*>(pView)->GetViewShell();
2531  }
2532 
2533  if (!pViewShell || !pViewShell->GetLayout())
2534  return 0;
2535 
2536  if (bFormat)
2537  {
2538  // #i38289
2539  if( pViewShell->GetViewOptions()->getBrowseMode() ||
2540  pViewShell->GetViewOptions()->IsWhitespaceHidden() )
2541  {
2542  SwViewOption aOpt( *pViewShell->GetViewOptions() );
2543  aOpt.setBrowseMode( false );
2544  aOpt.SetHideWhitespaceMode( false );
2545  pViewShell->ApplyViewOptions( aOpt );
2546  if (pSwView)
2547  {
2548  pSwView->RecheckBrowseMode();
2549  }
2550  }
2551 
2552  // reformatting the document for printing will show the changes in the view
2553  // which is likely to produce many unwanted and not nice to view actions.
2554  // We don't want that! Thus we disable updating of the view.
2555  pViewShell->StartAction();
2556 
2557  if (pSwView)
2558  {
2559  if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) )
2560  m_pRenderData->ViewOptionAdjustStop();
2561  if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust())
2562  {
2563  m_pRenderData->ViewOptionAdjustStart(
2564  *pViewShell, *pViewShell->GetViewOptions() );
2565  }
2566  }
2567 
2568  m_pRenderData->MakeSwPrtOptions( pRenderDocShell,
2569  m_pPrintUIOptions.get(), bIsPDFExport );
2570 
2571  if (pSwView)
2572  {
2573  // PDF export should not make use of the SwPrtOptions
2574  const SwPrintData *pPrtOptions = bIsPDFExport
2575  ? nullptr : m_pRenderData->GetSwPrtOptions();
2576  bool setShowPlaceHoldersInPDF = false;
2577  if(bIsPDFExport)
2578  setShowPlaceHoldersInPDF = lcl_GetBoolProperty( rxOptions, "ExportPlaceholders" );
2579  m_pRenderData->ViewOptionAdjust( pPrtOptions, setShowPlaceHoldersInPDF );
2580  }
2581 
2582  // since printing now also use the API for PDF export this option
2583  // should be set for printing as well ...
2584  pViewShell->SetPDFExportOption( true );
2585 
2586  // there is some redundancy between those two function calls, but right now
2587  // there is no time to sort this out.
2588  //TODO: check what exactly needs to be done and make just one function for that
2589  pViewShell->CalcLayout();
2590 
2591  // #122919# Force field update before PDF export, but after layout init (tdf#121962)
2592  bool bStateChanged = false;
2593  // check configuration: shall update of printing information in DocInfo set the document to "modified"?
2595  {
2596  pRenderDocShell->EnableSetModified( false );
2597  bStateChanged = true;
2598  }
2599  pViewShell->SwViewShell::UpdateFields(true);
2600  if( bStateChanged )
2601  pRenderDocShell->EnableSetModified();
2602 
2603  pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );
2604 
2605  pViewShell->SetPDFExportOption( false );
2606 
2607  // enable view again
2608  pViewShell->EndAction();
2609  }
2610 
2611  const sal_Int32 nPageCount = pViewShell->GetPageCount();
2612 
2613  // get number of pages to be rendered
2614 
2615  const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect" );
2616  if (bPrintProspect)
2617  {
2619  nRet = m_pRenderData->GetPagePairsForProspectPrinting().size();
2620  }
2621  else
2622  {
2623  const SwPostItMode nPostItMode = static_cast<SwPostItMode>( m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 ) );
2624  if (nPostItMode != SwPostItMode::NONE)
2625  {
2627  m_pRenderData->CreatePostItData(*pDoc, pViewShell->GetViewOptions(), pOutDev);
2628  }
2629 
2630  // get set of valid document pages (according to the current settings)
2631  // and their start frames
2632  SwDoc::CalculatePagesForPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount );
2633 
2634  if (nPostItMode != SwPostItMode::NONE)
2635  {
2637  *m_pPrintUIOptions, nPageCount );
2638  }
2639 
2640  nRet = m_pRenderData->GetPagesToPrint().size();
2641  }
2642  }
2643  OSL_ENSURE( nRet >= 0, "negative number of pages???" );
2644 
2645  return nRet;
2646 }
2647 
2648 uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
2649  sal_Int32 nRenderer,
2650  const uno::Any& rSelection,
2651  const uno::Sequence< beans::PropertyValue >& rxOptions )
2652 {
2653  SolarMutexGuard aGuard;
2654  if(!IsValid())
2655  {
2656  throw DisposedException("", static_cast< XTextDocument* >(this));
2657  }
2658 
2659  const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
2660  bool bIsSwSrcView = false;
2661  SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2662 
2663  // m_pRenderData should NOT be created here!
2664  // That should only be done in getRendererCount. If this function is called before
2665  // getRendererCount was called then the caller will probably just retrieve the extra UI options
2666  // and is not interested in getting valid information about the other data that would
2667  // otherwise be provided here!
2668 // if( ! m_pRenderData )
2669 // m_pRenderData = new SwRenderData;
2670  if (!m_pPrintUIOptions)
2672  m_pPrintUIOptions->processProperties( rxOptions );
2673  const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect" );
2674  const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
2675  const bool bPrintPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup" );
2676 
2677  SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2678  OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2679  if (!pDoc || !pView)
2680  return uno::Sequence< beans::PropertyValue >();
2681 
2682  // due to #110067# (document page count changes sometimes during
2683  // PDF export/printing) we can not check for the upper bound properly.
2684  // Thus instead of throwing the exception we silently return.
2685  if (0 > nRenderer)
2686  throw IllegalArgumentException();
2687 
2688  // TODO/mba: we really need a generic way to get the SwViewShell!
2689  SwViewShell* pVwSh = nullptr;
2690  SwView* pSwView = dynamic_cast<SwView*>( pView );
2691  if ( pSwView )
2692  pVwSh = pSwView->GetWrtShellPtr();
2693  else
2694  pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell();
2695 
2696  sal_Int32 nMaxRenderer = 0;
2697  if (!bIsSwSrcView && m_pRenderData)
2698  {
2699  OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
2700  nMaxRenderer = bPrintProspect?
2701  m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
2702  m_pRenderData->GetPagesToPrint().size() - 1;
2703  }
2704  // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
2705  // we obmit checking of the upper bound in this case.
2706  if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer)
2707  return uno::Sequence< beans::PropertyValue >();
2708 
2709  uno::Sequence< beans::PropertyValue > aRenderer;
2710  if (m_pRenderData)
2711  {
2712  // #i114210#
2713  // determine the correct page number from the renderer index
2714  // #i114875
2715  // consider brochure print
2716  const sal_Int32 nPage = bPrintProspect
2717  ? nRenderer + 1
2718  : m_pRenderData->GetPagesToPrint()[ nRenderer ];
2719 
2720  // get paper tray to use ...
2721  sal_Int32 nPrinterPaperTray = -1;
2722  if (! bPrintPaperFromSetup)
2723  {
2724  // ... from individual page style (see the page tab in Format/Page dialog)
2725  const std::map< sal_Int32, sal_Int32 > &rPaperTrays = m_pRenderData->GetPrinterPaperTrays();
2726  std::map< sal_Int32, sal_Int32 >::const_iterator aIt( rPaperTrays.find( nPage ) );
2727  if (aIt != rPaperTrays.end())
2728  nPrinterPaperTray = aIt->second;
2729  }
2730 
2731  awt::Size aPageSize;
2732  awt::Point aPagePos;
2733  awt::Size aPreferredPageSize;
2734  Size aTmpSize;
2735  if (bIsSwSrcView || bPrintProspect)
2736  {
2737  // for printing of HTML source code and prospect printing we should use
2738  // the printers paper size since
2739  // a) HTML source view has no page size
2740  // b) prospect printing has a different page size from the documents page
2741  // since two document pages will get rendered on one printer page
2742 
2743  // since PageIncludesNonprintableArea will be set to true we can return the
2744  // printers paper size here.
2745  // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this
2746  // case we won't get an OutputDevice here, but then the caller also has no need
2747  // for the correct PageSize right now...
2748  VclPtr< Printer > pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions ).get());
2749  if (pPrinter)
2750  {
2751  // HTML source view and prospect adapt to the printer's paper size
2752  aTmpSize = pPrinter->GetPaperSize();
2753  aTmpSize = OutputDevice::LogicToLogic( aTmpSize,
2754  pPrinter->GetMapMode(), MapMode( MapUnit::Map100thMM ));
2755  aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() );
2756  #if 0
2757  // #i115048# it seems users didn't like getting double the formatted page size
2758  // revert to "old" behavior scaling to the current paper size of the printer
2759  if (bPrintProspect)
2760  {
2761  // we just state what output size we would need
2762  // which may cause vcl to set that page size on the printer
2763  // (if available and not overridden by the user)
2764  aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
2765  aPreferredPageSize = awt::Size ( convertTwipToMm100( 2 * aTmpSize.Width() ),
2766  convertTwipToMm100( aTmpSize.Height() ));
2767  }
2768  #else
2769  if( bPrintProspect )
2770  {
2771  // just switch to an appropriate portrait/landscape format
2772  // FIXME: brochure printing with landscape pages puts the
2773  // pages next to each other, so landscape is currently always
2774  // the better choice
2775  if( aPageSize.Width < aPageSize.Height )
2776  {
2777  aPreferredPageSize.Width = aPageSize.Height;
2778  aPreferredPageSize.Height = aPageSize.Width;
2779  }
2780  }
2781  #endif
2782  }
2783  }
2784  else
2785  {
2786  aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
2787  aPageSize = awt::Size ( convertTwipToMm100( aTmpSize.Width() ),
2788  convertTwipToMm100( aTmpSize.Height() ));
2789  Point aPoint = pVwSh->GetPagePos(nPage);
2790  aPagePos = awt::Point(convertTwipToMm100(aPoint.X()), convertTwipToMm100(aPoint.Y()));
2791  }
2792 
2793  sal_Int32 nLen = 3;
2794  aRenderer.realloc(3);
2795  aRenderer[0].Name = "PageSize";
2796  aRenderer[0].Value <<= aPageSize;
2797  aRenderer[1].Name = "PageIncludesNonprintableArea";
2798  aRenderer[1].Value <<= true;
2799  aRenderer[2].Name = "PagePos";
2800  aRenderer[2].Value <<= aPagePos;
2801  if (aPreferredPageSize.Width && aPreferredPageSize.Height)
2802  {
2803  ++nLen;
2804  aRenderer.realloc( nLen );
2805  aRenderer[ nLen - 1 ].Name = "PreferredPageSize";
2806  aRenderer[ nLen - 1 ].Value <<= aPreferredPageSize;
2807  }
2808  if (nPrinterPaperTray >= 0)
2809  {
2810  ++nLen;
2811  aRenderer.realloc( nLen );
2812  aRenderer[ nLen - 1 ].Name = "PrinterPaperTray";
2813  aRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray;
2814  }
2815  }
2816 
2817  // #i117783#
2819  {
2820  const SwPagePreviewPrtData* pPagePrintSettings =
2822  if ( pPagePrintSettings &&
2823  ( pPagePrintSettings->GetRow() > 1 ||
2824  pPagePrintSettings->GetCol() > 1 ) )
2825  {
2826  // extend render data by page print settings attributes
2827  sal_Int32 nLen = aRenderer.getLength();
2828  const sal_Int32 nRenderDataIdxStart = nLen;
2829  nLen += 9;
2830  aRenderer.realloc( nLen );
2831  // put page print settings attribute into render data
2832  const sal_Int32 nRow = pPagePrintSettings->GetRow();
2833  aRenderer[ nRenderDataIdxStart + 0 ].Name = "NUpRows";
2834  aRenderer[ nRenderDataIdxStart + 0 ].Value <<= std::max<sal_Int32>( nRow, 1);
2835  const sal_Int32 nCol = pPagePrintSettings->GetCol();
2836  aRenderer[ nRenderDataIdxStart + 1 ].Name = "NUpColumns";
2837  aRenderer[ nRenderDataIdxStart + 1 ].Value <<= std::max<sal_Int32>( nCol, 1);
2838  aRenderer[ nRenderDataIdxStart + 2 ].Name = "NUpPageMarginLeft";
2839  aRenderer[ nRenderDataIdxStart + 2 ].Value <<= pPagePrintSettings->GetLeftSpace();
2840  aRenderer[ nRenderDataIdxStart + 3 ].Name = "NUpPageMarginRight";
2841  aRenderer[ nRenderDataIdxStart + 3 ].Value <<= pPagePrintSettings->GetRightSpace();
2842  aRenderer[ nRenderDataIdxStart + 4 ].Name = "NUpPageMarginTop";
2843  aRenderer[ nRenderDataIdxStart + 4 ].Value <<= pPagePrintSettings->GetTopSpace();
2844  aRenderer[ nRenderDataIdxStart + 5 ].Name = "NUpPageMarginBottom";
2845  aRenderer[ nRenderDataIdxStart + 5 ].Value <<= pPagePrintSettings->GetBottomSpace();
2846  aRenderer[ nRenderDataIdxStart + 6 ].Name = "NUpHorizontalSpacing";
2847  aRenderer[ nRenderDataIdxStart + 6 ].Value <<= pPagePrintSettings->GetHorzSpace();
2848  aRenderer[ nRenderDataIdxStart + 7 ].Name = "NUpVerticalSpacing";
2849  aRenderer[ nRenderDataIdxStart + 7 ].Value <<= pPagePrintSettings->GetVertSpace();
2850  {
2851  Printer* pPrinter = m_pDocShell->GetDoc()->getIDocumentDeviceAccess().getPrinter( false );
2852  if ( pPrinter )
2853  {
2854  awt::Size aNewPageSize;
2855  const Size aPageSize = pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
2856  aNewPageSize = awt::Size( aPageSize.Width(), aPageSize.Height() );
2857  if ( ( pPagePrintSettings->GetLandscape() &&
2858  aPageSize.Width() < aPageSize.Height() ) ||
2859  ( !pPagePrintSettings->GetLandscape() &&
2860  aPageSize.Width() > aPageSize.Height() ) )
2861  {
2862  aNewPageSize = awt::Size( aPageSize.Height(), aPageSize.Width() );
2863  }
2864  aRenderer[ nRenderDataIdxStart + 8 ].Name = "NUpPaperSize";
2865  aRenderer[ nRenderDataIdxStart + 8 ].Value <<= aNewPageSize;
2866  }
2867  }
2868  }
2869 
2871  }
2872 
2873  m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
2874 
2875  return aRenderer;
2876 }
2877 
2879  /* out */ bool &rbIsSwSrcView,
2880  const uno::Reference< css::frame::XController >& rController )
2881 {
2882  // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell()
2883  // must not be used (see comment from MBA)
2884 
2885  SfxViewShell *pView = nullptr;
2886  SwView *pSwView = nullptr;
2887  SwPagePreview *pSwPagePreview = nullptr;
2888  SwSrcView *pSwSrcView = nullptr;
2889  SfxViewFrame *pFrame = SfxViewFrame::GetFirst( m_pDocShell, false );
2890 
2891  // look for the view shell with the same controller in use,
2892  // otherwise look for a suitable view, preferably a SwView,
2893  // if that one is not found use a SwPagePreview if found.
2894  while (pFrame)
2895  {
2896  pView = pFrame->GetViewShell();
2897  pSwView = dynamic_cast< SwView * >(pView);
2898  pSwSrcView = dynamic_cast< SwSrcView * >(pView);
2899  if (!pSwPagePreview)
2900  pSwPagePreview = dynamic_cast< SwPagePreview * >(pView);
2901  if (rController.is())
2902  {
2903  if (pView && pView->GetController() == rController)
2904  break;
2905  }
2906  else if (pSwView || pSwSrcView)
2907  break;
2908  pFrame = SfxViewFrame::GetNext( *pFrame, m_pDocShell, false );
2909  }
2910 
2911  OSL_ENSURE( pSwView || pSwPagePreview || pSwSrcView, "failed to get view shell" );
2912  if (pView)
2913  rbIsSwSrcView = pSwSrcView != nullptr;
2914  return pView;
2915 }
2916 
2918  sal_Int32 nRenderer,
2919  const uno::Any& rSelection,
2920  const uno::Sequence< beans::PropertyValue >& rxOptions )
2921 {
2922  SolarMutexGuard aGuard;
2923  if(!IsValid())
2924  {
2925  throw DisposedException( OUString(),
2926  static_cast< XTextDocument* >(this) );
2927  }
2928 
2929  // due to #110067# (document page count changes sometimes during
2930  // PDF export/printing) we can not check for the upper bound properly.
2931  // Thus instead of throwing the exception we silently return.
2932  if (0 > nRenderer)
2933  throw IllegalArgumentException();
2934 
2935  // tdf#135244: prevent jumping to cursor at any temporary modification
2936  auto aLock = m_pDocShell->LockAllViews();
2937 
2938  const bool bHasPDFExtOutDevData = lcl_SeqHasProperty( rxOptions, "HasPDFExtOutDevData" );
2939  const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ) || bHasPDFExtOutDevData;
2940  bool bIsSwSrcView = false;
2941  SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2942 
2943  OSL_ENSURE( m_pRenderData, "data should have been created already in getRendererCount..." );
2944  OSL_ENSURE( m_pPrintUIOptions, "data should have been created already in getRendererCount..." );
2945  if (!bIsSwSrcView && !m_pRenderData)
2946  m_pRenderData.reset(new SwRenderData);
2947  if (!m_pPrintUIOptions)
2949  m_pPrintUIOptions->processProperties( rxOptions );
2950  const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect" );
2951  const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage" );
2952 
2953  SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2954  OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2955  if (pDoc && pView)
2956  {
2957  sal_Int32 nMaxRenderer = 0;
2958  if (!bIsSwSrcView)
2959  {
2960  OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
2961  nMaxRenderer = bPrintProspect?
2962  m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
2963  m_pRenderData->GetPagesToPrint().size() - 1;
2964  }
2965  // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
2966  // we obmit checking of the upper bound in this case.
2967  if (bIsSwSrcView || nRenderer <= nMaxRenderer)
2968  {
2969  if (bIsSwSrcView)
2970  {
2971  SwSrcView& rSwSrcView = dynamic_cast<SwSrcView&>(*pView);
2973  rSwSrcView.PrintSource(pOutDev, nRenderer + 1, false);
2974  }
2975  else
2976  {
2977  // the view shell should be SwView for documents PDF export
2978  // or SwPagePreview for PDF export of the page preview
2979  SwViewShell* pVwSh = nullptr;
2980  // TODO/mba: we really need a generic way to get the SwViewShell!
2981  const SwView* pSwView = dynamic_cast<const SwView*>(pView);
2982  if (pSwView)
2983  pVwSh = pSwView->GetWrtShellPtr();
2984  else
2985  pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell();
2986 
2987  // get output device to use
2989 
2990  if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
2991  {
2992  const OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange" );
2993  const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage" );
2994  bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
2995 
2996  OSL_ENSURE((pSwView && m_pRenderData->IsViewOptionAdjust())
2997  || (!pSwView && !m_pRenderData->IsViewOptionAdjust()),
2998  "SwView / SwViewOptionAdjust_Impl availability mismatch" );
2999 
3000  // since printing now also use the API for PDF export this option
3001  // should be set for printing as well ...
3002  pVwSh->SetPDFExportOption( true );
3003 
3004  // #i12836# enhanced pdf export
3005 
3006  // First, we have to export hyperlinks, notes, and outline to pdf.
3007  // During this process, additional information required for tagging
3008  // the pdf file are collected, which are evaluated during painting.
3009 
3010  SwWrtShell* pWrtShell = pSwView ? pSwView->GetWrtShellPtr() : nullptr;
3011 
3012  SwPrintData const& rSwPrtOptions =
3013  *m_pRenderData->GetSwPrtOptions();
3014 
3015  if (bIsPDFExport && (bFirstPage || bHasPDFExtOutDevData) && pWrtShell)
3016  {
3017  SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, false, rSwPrtOptions );
3018  }
3019 
3020  if (bPrintProspect)
3021  pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer );
3022  else // normal printing and PDF export
3023  pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer, bIsPDFExport );
3024 
3025  // #i35176#
3026 
3027  // After printing the last page, we take care for the links coming
3028  // from the EditEngine. The links are generated during the painting
3029  // process, but the destinations are still missing.
3030 
3031  if (bIsPDFExport && bLastPage && pWrtShell)
3032  {
3033  SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, true, rSwPrtOptions );
3034  }
3035 
3036  pVwSh->SetPDFExportOption( false );
3037 
3038  // last page to be rendered? (not necessarily the last page of the document)
3039  // -> do clean-up of data
3040  if (bLastPage)
3041  {
3042  // #i96167# haggai: delete ViewOptionsAdjust here because it makes use
3043  // of the shell, which might get destroyed in lcl_DisposeView!
3044  if (m_pRenderData->IsViewOptionAdjust())
3045  m_pRenderData->ViewOptionAdjustStop();
3046 
3047  if (m_pRenderData->HasPostItData())
3048  m_pRenderData->DeletePostItData();
3049  if (m_pHiddenViewFrame)
3050  {
3052  m_pHiddenViewFrame = nullptr;
3053 
3054  // prevent crash described in #i108805
3055  SwDocShell *pRenderDocShell = pDoc->GetDocShell();
3056  SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet();
3057  pSet->Put( SfxBoolItem( SID_HIDDEN, false ) );
3058 
3059  }
3060  }
3061  }
3062  }
3063  }
3064  }
3065  if( bLastPage )
3066  {
3067  m_pRenderData.reset();
3068  m_pPrintUIOptions.reset();
3069  }
3070 }
3071 
3072 // xforms::XFormsSupplier
3073 Reference<XNameContainer> SAL_CALL SwXTextDocument::getXForms()
3074 {
3075  SolarMutexGuard aGuard;
3076  if ( !m_pDocShell )
3077  throw DisposedException( OUString(), static_cast< XTextDocument* >( this ) );
3078  SwDoc* pDoc = m_pDocShell->GetDoc();
3079  return pDoc->getXForms();
3080 }
3081 
3082 uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
3083 {
3084  SolarMutexGuard aGuard;
3085  if (!IsValid())
3086  {
3087  throw DisposedException("SwXTextDocument not valid",
3088  static_cast<XTextDocument*>(this));
3089  }
3090 
3092  *m_pDocShell->GetDoc(), nTextMarkupType, bAutomatic);
3093 }
3094 
3095 uno::Reference< util::XCloneable > SwXTextDocument::createClone( )
3096 {
3097  SolarMutexGuard aGuard;
3098  if(!IsValid())
3099  throw DisposedException("", static_cast< XTextDocument* >(this));
3100 
3101  // create a new document - hidden - copy the storage and return it
3102  // SfxObjectShellRef is used here, since the model should control object lifetime after creation
3103  // and thus SfxObjectShellLock is not allowed here
3104  // the model holds reference to the shell, so the shell will not destructed at the end of method
3105  SfxObjectShellRef pShell = m_pDocShell->GetDoc()->CreateCopy(false, false);
3106  uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
3107  uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( );
3108  uno::Sequence< beans::PropertyValue > aTempMediaDescriptor;
3109  storeToStorage( xNewStorage, aTempMediaDescriptor );
3110  uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY );
3111  xStorageDoc->loadFromStorage( xNewStorage, aTempMediaDescriptor );
3112  return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
3113 }
3114 
3115 void SwXTextDocument::addPasteEventListener(const uno::Reference<text::XPasteListener>& xListener)
3116 {
3117  SolarMutexGuard aGuard;
3118 
3119  if (IsValid() && xListener.is())
3121 }
3122 
3124  const uno::Reference<text::XPasteListener>& xListener)
3125 {
3126  SolarMutexGuard aGuard;
3127 
3128  if (IsValid() && xListener.is())
3130 }
3131 
3133  int nOutputWidth, int nOutputHeight,
3134  int nTilePosX, int nTilePosY,
3135  tools::Long nTileWidth, tools::Long nTileHeight )
3136 {
3137  SwViewShell* pViewShell = m_pDocShell->GetWrtShell();
3138  pViewShell->PaintTile(rDevice, nOutputWidth, nOutputHeight,
3139  nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3140 
3141  LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
3142  nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3143 }
3144 
3146 {
3147  SwViewShell* pViewShell = m_pDocShell->GetWrtShell();
3148  Size aDocSize = pViewShell->GetDocSize();
3149 
3150  return Size(aDocSize.Width() + 2 * DOCUMENTBORDER,
3151  aDocSize.Height() + 2 * DOCUMENTBORDER);
3152 }
3153 
3155 {
3156  SolarMutexGuard aGuard;
3157 
3158  SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
3159  if (!pWrtShell)
3160  return;
3161 
3162  pWrtShell->GotoPage(nPart + 1, true);
3163 }
3164 
3166 {
3167  SolarMutexGuard aGuard;
3168 
3169  SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
3170  if (!pWrtShell)
3171  return 0;
3172 
3173  return pWrtShell->GetPageCnt();
3174 }
3175 
3177 {
3178  SolarMutexGuard aGuard;
3179 
3180  SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
3181  if (!pWrtShell)
3182  return OUString();
3183 
3184  return pWrtShell->getPageRectangles();
3185 }
3186 
3187 void SwXTextDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
3188 {
3189  SolarMutexGuard aGuard;
3190 
3191  SwView* pView = m_pDocShell->GetView();
3192  if (pView)
3193  pView->GetEditWin().SetClipboard(xClipboard);
3194 }
3195 
3197 {
3198  SolarMutexGuard aGuard;
3199 
3200  SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
3201  if (!pWrtShell)
3202  return false;
3203 
3205  if (SdrView* pSdrView = pWrtShell->GetDrawView())
3206  {
3207  if (pSdrView->GetTextEditObject())
3208  // Editing shape text
3209  return EditEngine::HasValidData(aDataHelper.GetTransferable());
3210  }
3211 
3212  return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper);
3213 }
3214 
3216 {
3217  if (SwView* pView = m_pDocShell->GetView())
3218  {
3219  // set the PgUp/PgDown offset
3220  pView->ForcePageUpDownOffset(2 * rRectangle.GetHeight() / 3);
3221  }
3222 
3223  if (SwViewShell* pViewShell = m_pDocShell->GetWrtShell())
3224  {
3225  pViewShell->setLOKVisibleArea(rRectangle);
3226  }
3227 }
3228 
3229 void SwXTextDocument::setClientZoom(int nTilePixelWidth_, int /*nTilePixelHeight_*/,
3230  int nTileTwipWidth_, int /*nTileTwipHeight_*/)
3231 {
3232  // Here we set the zoom value as it has been set by the user in the client.
3233  // This value is used in postMouseEvent and setGraphicSelection methods
3234  // for in place chart editing. We assume that x and y scale is roughly
3235  // the same.
3236  SfxInPlaceClient* pIPClient = m_pDocShell->GetView()->GetIPClient();
3237  if (!pIPClient)
3238  return;
3239 
3240  SwViewShell* pWrtViewShell = m_pDocShell->GetWrtShell();
3241  double fScale = nTilePixelWidth_ * TWIPS_PER_PIXEL / (nTileTwipWidth_ * 1.0);
3242  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3243  if (aOption.GetZoom() != fScale * 100)
3244  {
3245  aOption.SetZoom(fScale * 100);
3246  pWrtViewShell->ApplyViewOptions(aOption);
3247 
3248  // Changing the zoom value doesn't always trigger the updating of
3249  // the client ole object area, so we call it directly.
3250  pIPClient->VisAreaChanged();
3251  }
3252 }
3253 
3255 {
3256  SolarMutexGuard aGuard;
3257 
3258  SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
3259  if (!pWrtShell)
3260  return PointerStyle::Arrow;
3261 
3262  return pWrtShell->GetView().GetEditWin().GetPointer();
3263 }
3264 
3266 {
3267  auto redlinesNode = rJson.startNode("redlines");
3268 
3269  // Disable since usability is very low beyond some small number of changes.
3270  static bool bDisableRedlineComments = getenv("DISABLE_REDLINE") != nullptr;
3271  if (bDisableRedlineComments)
3272  return;
3273 
3274  const SwRedlineTable& rRedlineTable
3276  for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
3277  {
3278  auto redlineNode = rJson.startNode("");
3279  rJson.put("index", rRedlineTable[i]->GetId());
3280  rJson.put("author", rRedlineTable[i]->GetAuthorString(1));
3281  rJson.put("type", SwRedlineTypeToOUString(
3282  rRedlineTable[i]->GetRedlineData().GetType()));
3283  rJson.put("comment",
3284  rRedlineTable[i]->GetRedlineData().GetComment());
3285  rJson.put("description", rRedlineTable[i]->GetDescr());
3286  OUString sDateTime = utl::toISO8601(
3287  rRedlineTable[i]->GetRedlineData().GetTimeStamp().GetUNODateTime());
3288  rJson.put("dateTime", sDateTime);
3289 
3290  SwContentNode* pContentNd = rRedlineTable[i]->GetContentNode();
3291  SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
3292  if (pView && pContentNd)
3293  {
3294  SwShellCursor aCursor(pView->GetWrtShell(), *(rRedlineTable[i]->Start()));
3295  aCursor.SetMark();
3296  aCursor.GetMark()->nNode = *pContentNd;
3297  aCursor.GetMark()->nContent.Assign(pContentNd,
3298  rRedlineTable[i]->End()->nContent.GetIndex());
3299 
3300  aCursor.FillRects();
3301 
3302  SwRects* pRects(&aCursor);
3303  std::vector<OString> aRects;
3304  for (const SwRect& rNextRect : *pRects)
3305  aRects.push_back(rNextRect.SVRect().toString());
3306 
3307  const OString sRects = comphelper::string::join("; ", aRects);
3308  rJson.put("textRange", sRects);
3309  }
3310  }
3311 }
3312 
3314 {
3315  SW_MOD()->GetRedlineAuthorInfo(rJsonWriter);
3316 }
3317 
3319 {
3320  SwView* pView = m_pDocShell->GetView();
3321  dynamic_cast<SwCommentRuler&>(pView->GetHRuler()).CreateJsonNotification(rJsonWriter);
3322 }
3323 
3325 {
3326  SolarMutexGuard aGuard;
3327  auto commentsNode = rJsonWriter.startNode("comments");
3328  for (auto const& sidebarItem : *m_pDocShell->GetView()->GetPostItMgr())
3329  {
3330  sw::annotation::SwAnnotationWin* pWin = sidebarItem->mpPostIt.get();
3331 
3332  const SwPostItField* pField = pWin->GetPostItField();
3333  const SwRect& aRect = pWin->GetAnchorRect();
3334  tools::Rectangle aSVRect(aRect.Pos().getX(),
3335  aRect.Pos().getY(),
3336  aRect.Pos().getX() + aRect.SSize().Width(),
3337  aRect.Pos().getY() + aRect.SSize().Height());
3338 
3339  if (!sidebarItem->maLayoutInfo.mPositionFromCommentAnchor)
3340  {
3341  // Comments on frames: anchor position is the corner position, not the whole frame.
3342  aSVRect.SetSize(Size(0, 0));
3343  }
3344 
3345  std::vector<OString> aRects;
3346  for (const basegfx::B2DRange& aRange : pWin->GetAnnotationTextRanges())
3347  {
3348  const SwRect rect(aRange.getMinX(), aRange.getMinY(), aRange.getWidth(), aRange.getHeight());
3349  aRects.push_back(rect.SVRect().toString());
3350  }
3351  const OString sRects = comphelper::string::join("; ", aRects);
3352 
3353  auto commentNode = rJsonWriter.startNode("");
3354  rJsonWriter.put("id", pField->GetPostItId());
3355  rJsonWriter.put("parent", pWin->CalcParent());
3356  rJsonWriter.put("author", pField->GetPar1());
3357  rJsonWriter.put("text", pField->GetPar2());
3358  rJsonWriter.put("resolved", pField->GetResolved() ? "true" : "false");
3359  rJsonWriter.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime()));
3360  rJsonWriter.put("anchorPos", aSVRect.toString());
3361  rJsonWriter.put("textRange", sRects);
3362  }
3363 }
3364 
3366 {
3367  auto aIter = aArguments.find("type");
3368  if (aIter == aArguments.end() || aIter->second != "drop-down")
3369  return;
3370 
3371  aIter = aArguments.find("cmd");
3372  if (aIter == aArguments.end() || aIter->second != "selected")
3373  return;
3374 
3375  aIter = aArguments.find("data");
3376  if (aIter == aArguments.end())
3377  return;
3378 
3379  sal_Int32 nSelection = aIter->second.toInt32();
3382  if ( !pFieldBM )
3383  {
3384  --aPos.nContent;
3386  }
3387  if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN)
3388  {
3389  if (nSelection >= 0)
3390  {
3391  (*pFieldBM->GetParameters())[ODF_FORMDROPDOWN_RESULT] <<= nSelection;
3392  pFieldBM->Invalidate();
3395  }
3396  }
3397 }
3398 
3400 {
3401  SolarMutexGuard aGuard;
3402 
3403  SwView* pView = m_pDocShell->GetView();
3404  if (!pView)
3405  return 0;
3406 
3407  return pView->getPart();
3408 }
3409 
3410 OUString SwXTextDocument::getPartName(int nPart)
3411 {
3412  SolarMutexGuard aGuard;
3413 
3414  return SwResId(STR_PAGE) + OUString::number(nPart + 1);
3415 }
3416 
3417 OUString SwXTextDocument::getPartHash(int nPart)
3418 {
3419  SolarMutexGuard aGuard;
3420  OUString sPart(SwResId(STR_PAGE) + OUString::number(nPart + 1));
3421 
3422  return OUString::number(sPart.hashCode());
3423 }
3424 
3426 {
3427  SolarMutexGuard aGuard;
3428  VclPtr<vcl::Window> pWindow;
3429  SwView* pView = m_pDocShell->GetView();
3430  if (pView)
3431  pWindow = &(pView->GetEditWin());
3432 
3433  LokChartHelper aChartHelper(pView);
3434  VclPtr<vcl::Window> pChartWindow = aChartHelper.GetWindow();
3435  if (pChartWindow)
3436  pWindow = pChartWindow;
3437 
3438  return pWindow;
3439 }
3440 
3441 void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
3442 {
3443  SolarMutexGuard aGuard;
3444 
3445  SwViewShell* pViewShell = m_pDocShell->GetWrtShell();
3446 
3447  SwView* pView = m_pDocShell->GetView();
3448  if (!pView)
3449  return;
3450 
3451  pView->SetViewLayout(1/*nColumns*/, false/*bBookMode*/, true);
3452 
3453  // Tiled rendering defaults.
3454  SwViewOption aViewOption(*pViewShell->GetViewOptions());
3455  aViewOption.SetHardBlank(false);
3456  for (const beans::PropertyValue& rValue : rArguments)
3457  {
3458  if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has<bool>())
3459  aViewOption.SetHideWhitespaceMode(rValue.Value.get<bool>());
3460  else if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>())
3462  else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
3463  {
3464  // Store the author name in the view.
3465  pView->SetRedlineAuthor(rValue.Value.get<OUString>());
3466  // Let the actual author name pick up the value from the current
3467  // view, which would normally happen only during the next view
3468  // switch.
3469  m_pDocShell->SetView(pView);
3470  }
3471  }
3472 
3473  // Set the initial zoom value to 1; usually it is set in setClientZoom and
3474  // SwViewShell::PaintTile; zoom value is used for chart in place
3475  // editing, see postMouseEvent and setGraphicSelection methods.
3476  aViewOption.SetZoom(1 * 100);
3477 
3478  aViewOption.SetPostIts(comphelper::LibreOfficeKit::isTiledAnnotations());
3479  pViewShell->ApplyViewOptions(aViewOption);
3480 
3481  // position the pages again after setting view options. Eg: if postit
3482  // rendering is false, then there would be no sidebar, so width of the
3483  // document needs to be adjusted
3484  pViewShell->GetLayout()->CheckViewLayout( pViewShell->GetViewOptions(), nullptr );
3485 
3486  // Disable map mode, so that it's possible to send mouse event coordinates
3487  // directly in twips.
3488  SwEditWin& rEditWin = m_pDocShell->GetView()->GetEditWin();
3489  rEditWin.EnableMapMode(false);
3490 
3491  // when the "This document may contain formatting or content that cannot
3492  // be saved..." dialog appears, it is auto-cancelled with tiled rendering,
3493  // causing 'Save' being disabled; so let's always save to the original
3494  // format
3496 
3497  // disable word auto-completion suggestions, the tooltips are not visible,
3498  // and the editeng-like auto-completion is annoying
3500 
3501  // don't change the whitespace at the beginning of paragraphs, this is
3502  // annoying when taking minutes without further formatting
3504 }
3505 
3506 void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
3507 {
3508  SolarMutexGuard aGuard;
3509  SfxLokHelper::postKeyEventAsync(getDocWindow(), nType, nCharCode, nKeyCode);
3510 }
3511 
3512 void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
3513 {
3514  SolarMutexGuard aGuard;
3515 
3516  SwViewShell* pWrtViewShell = m_pDocShell->GetWrtShell();
3517  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3518  double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0);
3519 
3520  // check if the user hit a chart which is being edited by this view
3521  SfxViewShell* pViewShell = m_pDocShell->GetView();
3522  LokChartHelper aChartHelper(pViewShell);
3523  if (aChartHelper.postMouseEvent(nType, nX, nY,
3524  nCount, nButtons, nModifier,
3525  fScale, fScale))
3526  return;
3527 
3528  // check if the user hit a chart which is being edited by someone else
3529  // and, if so, skip current mouse event
3530  if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
3531  {
3532  if (LokChartHelper::HitAny(Point(nX, nY)))
3533  return;
3534  }
3535 
3536  SwEditWin& rEditWin = m_pDocShell->GetView()->GetEditWin();
3537  LokMouseEventData aMouseEventData(nType, Point(nX, nY), nCount,
3538  MouseEventModifiers::SIMPLECLICK,
3539  nButtons, nModifier);
3540  SfxLokHelper::postMouseEventAsync(&rEditWin, aMouseEventData);
3541 }
3542 
3543 void SwXTextDocument::setTextSelection(int nType, int nX, int nY)
3544 {
3545  SolarMutexGuard aGuard;
3546 
3547  SfxViewShell* pViewShell = m_pDocShell->GetView();
3548  LokChartHelper aChartHelper(pViewShell);
3549  if (aChartHelper.setTextSelection(nType, nX, nY))
3550  return;
3551 
3552  SwEditWin& rEditWin = m_pDocShell->GetView()->GetEditWin();
3553  switch (nType)
3554  {
3555  case LOK_SETTEXTSELECTION_START:
3556  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/false, /*bClearMark=*/false);
3557  break;
3558  case LOK_SETTEXTSELECTION_END:
3559  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/true, /*bClearMark=*/false);
3560  break;
3561  case LOK_SETTEXTSELECTION_RESET:
3562  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/true, /*bClearMark=*/true);
3563  break;
3564  default:
3565  assert(false);
3566  break;
3567  }
3568 }
3569 
3570 uno::Reference<datatransfer::XTransferable> SwXTextDocument::getSelection()
3571 {
3572  SolarMutexGuard aGuard;
3573 
3574  uno::Reference<datatransfer::XTransferable> xTransferable;
3575 
3576  SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
3577  if (SdrView* pSdrView = pWrtShell->GetDrawView())
3578  {
3579  if (pSdrView->GetTextEditObject())
3580  {
3581  // Editing shape text
3582  EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
3583  xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
3584  }
3585  }
3586 
3587  if (SwPostItMgr* pPostItMgr = m_pDocShell->GetView()->GetPostItMgr())
3588  {
3589  if (sw::annotation::SwAnnotationWin* pWin = pPostItMgr->GetActiveSidebarWin())
3590  {
3591  // Editing postit text.
3592  EditView& rEditView = pWin->GetOutlinerView()->GetEditView();
3593  xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
3594  }
3595  }
3596 
3597  if (!xTransferable.is())
3598  xTransferable = new SwTransferable(*pWrtShell);
3599 
3600  return xTransferable;
3601 }
3602 
3603 void SwXTextDocument::setGraphicSelection(int nType, int nX, int nY)
3604 {
3605  SolarMutexGuard aGuard;
3606 
3607  SwViewShell* pWrtViewShell = m_pDocShell->GetWrtShell();
3608  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3609  double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0);
3610 
3611  SfxViewShell* pViewShell = m_pDocShell->GetView();
3612  LokChartHelper aChartHelper(pViewShell);
3613  if (aChartHelper.setGraphicSelection(nType, nX, nY, fScale, fScale))
3614  return;
3615 
3616  SwEditWin& rEditWin = m_pDocShell->GetView()->GetEditWin();
3617  switch (nType)
3618  {
3619  case LOK_SETGRAPHICSELECTION_START:
3620  rEditWin.SetGraphicTwipPosition(/*bStart=*/true, Point(nX, nY));
3621  break;
3622  case LOK_SETGRAPHICSELECTION_END:
3623  rEditWin.SetGraphicTwipPosition(/*bStart=*/false, Point(nX, nY));
3624  break;
3625  default:
3626  assert(false);
3627  break;
3628  }
3629 }
3630 
3632 {
3633  SolarMutexGuard aGuard;
3634 
3635  SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
3636  pWrtShell->ResetSelect(nullptr, false);
3637 }
3638 
3639 void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight )
3640 {
3642  aData.nSize = sizeof(SystemGraphicsData);
3643  #if defined(_WIN32)
3644  sal_Int64 nWindowHandle;
3645  Parent >>= nWindowHandle;
3646  aData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
3647  ScopedVclPtrInstance<VirtualDevice> xDevice(aData, Size(1, 1), DeviceFormat::DEFAULT);
3648  paintTile(*xDevice, nOutputWidth, nOutputHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3649  #else
3650  // TODO: support other platforms
3651  (void)Parent;
3652  (void)nOutputWidth;
3653  (void)nOutputHeight;
3654  (void)nTilePosX;
3655  (void)nTilePosY;
3656  (void)nTileWidth;
3657  (void)nTileHeight;
3658  #endif
3659 }
3660 
3664 uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
3665  ::sal_Int16 nScriptTypes,
3666  ::sal_Int16 nMaxCount )
3667 {
3668  SolarMutexGuard aGuard;
3669 
3670  // possible canonical values for nScriptTypes
3671  // any bit wise combination is allowed
3672  const sal_Int16 nLatin = 0x001;
3673  const sal_Int16 nAsian = 0x002;
3674  const sal_Int16 nComplex = 0x004;
3675 
3676  // script types for which to get the languages
3677  const bool bLatin = 0 != (nScriptTypes & nLatin);
3678  const bool bAsian = 0 != (nScriptTypes & nAsian);
3679  const bool bComplex = 0 != (nScriptTypes & nComplex);
3680 
3681  if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex))
3682  throw IllegalArgumentException("nScriptTypes ranges from 1 to 7!", Reference< XInterface >(), 1);
3683  if (!m_pDocShell)
3684  throw DisposedException();
3685  SwDoc* pDoc = m_pDocShell->GetDoc();
3686 
3687  // avoid duplicate values
3688  std::set< LanguageType > aAllLangs;
3689 
3690  //USER STYLES
3691 
3692  const SwCharFormats *pFormats = pDoc->GetCharFormats();
3693  for(size_t i = 0; i < pFormats->size(); ++i)
3694  {
3695  const SwAttrSet &rAttrSet = (*pFormats)[i]->GetAttrSet();
3697  if (bLatin)
3698  {
3699  nLang = rAttrSet.GetLanguage( false ).GetLanguage();
3700  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3701  aAllLangs.insert( nLang );
3702  }
3703  if (bAsian)
3704  {
3705  nLang = rAttrSet.GetCJKLanguage( false ).GetLanguage();
3706  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3707  aAllLangs.insert( nLang );
3708  }
3709  if (bComplex)
3710  {
3711  nLang = rAttrSet.GetCTLLanguage( false ).GetLanguage();
3712  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3713  aAllLangs.insert( nLang );
3714  }
3715  }
3716 
3717  const SwTextFormatColls *pColls = pDoc->GetTextFormatColls();
3718  for (size_t i = 0; i < pColls->size(); ++i)
3719  {
3720  const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
3722  if (bLatin)
3723  {
3724  nLang = rAttrSet.GetLanguage( false ).GetLanguage();
3725  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3726  aAllLangs.insert( nLang );
3727  }
3728  if (bAsian)
3729  {
3730  nLang = rAttrSet.GetCJKLanguage( false ).GetLanguage();
3731  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3732  aAllLangs.insert( nLang );
3733  }
3734  if (bComplex)
3735  {
3736  nLang = rAttrSet.GetCTLLanguage( false ).GetLanguage();
3737  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3738  aAllLangs.insert( nLang );
3739  }
3740  }
3741 
3742  //AUTO STYLES
3743  const IStyleAccess::SwAutoStyleFamily aFam[2] =
3744  {
3747  };
3748  for (IStyleAccess::SwAutoStyleFamily i : aFam)
3749  {
3750  std::vector< std::shared_ptr<SfxItemSet> > rStyles;
3751  pDoc->GetIStyleAccess().getAllStyles(rStyles, i);
3752  while (!rStyles.empty())
3753  {
3754  std::shared_ptr<SfxItemSet> pStyle = rStyles.back();
3755  rStyles.pop_back();
3756  const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
3757 
3759  if (bLatin)
3760  {
3761  assert(pSet);
3762  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, false )).GetLanguage();
3763  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3764  aAllLangs.insert( nLang );
3765  }
3766  if (bAsian)
3767  {
3768  assert(pSet);
3769  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, false )).GetLanguage();
3770  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3771  aAllLangs.insert( nLang );
3772  }
3773  if (bComplex)
3774  {
3775  assert(pSet);
3776  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, false )).GetLanguage();
3777  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3778  aAllLangs.insert( nLang );
3779  }
3780  }
3781  }
3782 
3783  //TODO/mba: it's a strange concept that a view is needed to retrieve core data
3784  SwWrtShell *pWrtSh = m_pDocShell->GetWrtShell();
3785  SdrView *pSdrView = pWrtSh->GetDrawView();
3786 
3787  if( pSdrView )
3788  {
3789  SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
3790  if(pOutliner)
3791  {
3792  EditEngine& rEditEng = const_cast<EditEngine&>(pOutliner->GetEditEngine());
3793  sal_Int32 nParCount = pOutliner->GetParagraphCount();
3794  for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
3795  {
3796  //every paragraph
3797  std::vector<sal_Int32> aPortions;
3798  rEditEng.GetPortions( nPar, aPortions );
3799 
3800  for ( size_t nPos = aPortions.size(); nPos; )
3801  {
3802  //every position
3803  --nPos;
3804  sal_Int32 nEnd = aPortions[ nPos ];
3805  sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
3806  ESelection aSelection( nPar, nStart, nPar, nEnd );
3807  SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );
3808 
3810  if (bLatin)
3811  {
3812  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, false )).GetLanguage();
3813  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3814  aAllLangs.insert( nLang );
3815  }
3816  if (bAsian)
3817  {
3818  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, false )).GetLanguage();
3819  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3820  aAllLangs.insert( nLang );
3821  }
3822  if (bComplex)
3823  {
3824  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, false )).GetLanguage();
3825  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3826  aAllLangs.insert( nLang );
3827  }
3828  }
3829  }
3830  }
3831  }
3832  // less than nMaxCount languages
3833  if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() ))
3834  nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() );
3835 
3836  // build return value
3837  uno::Sequence< lang::Locale > aLanguages( nMaxCount );
3838  lang::Locale* pLanguage = aLanguages.getArray();
3839  if (nMaxCount > 0)
3840  {
3841  sal_Int32 nCount = 0;
3842  for (const auto& rLang : aAllLangs)
3843  {
3844  if (nCount >= nMaxCount)
3845  break;
3846  if (LANGUAGE_NONE != rLang)
3847  {
3848  pLanguage[nCount] = LanguageTag::convertToLocale( rLang );
3849  pLanguage[nCount].Language = SvtLanguageTable::GetLanguageString( rLang );
3850  nCount += 1;
3851  }
3852  }
3853  }
3854 
3855  return aLanguages;
3856 }
3857 
3859  m_pxDoc(&rxDoc)
3860 {
3861  m_sTables = SwResId(STR_CONTENT_TYPE_TABLE);
3862  m_sFrames = SwResId(STR_CONTENT_TYPE_FRAME);
3863  m_sGraphics = SwResId(STR_CONTENT_TYPE_GRAPHIC);
3864  m_sOLEs = SwResId(STR_CONTENT_TYPE_OLE);
3865  m_sSections = SwResId(STR_CONTENT_TYPE_REGION);
3866  m_sOutlines = SwResId(STR_CONTENT_TYPE_OUTLINE);
3867  m_sBookmarks = SwResId(STR_CONTENT_TYPE_BOOKMARK);
3868 }
3869 
3871 {
3872 }
3873 
3875 {
3876  Any aRet;
3877  if(!m_pxDoc)
3878  throw RuntimeException("No document available");
3879  OUString sSuffix("|");
3880  if(rName == m_sTables)
3881  {
3882  sSuffix += "table";
3883 
3885  m_pxDoc->getTextTables(), rName, sSuffix );
3886  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3887  }
3888  else if(rName == m_sFrames)
3889  {
3890  sSuffix += "frame";
3892  m_pxDoc->getTextFrames(), rName, sSuffix );
3893  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3894  }
3895  else if(rName == m_sSections)
3896  {
3897  sSuffix += "region";
3899  m_pxDoc->getTextSections(), rName, sSuffix );
3900  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3901  }
3902  else if(rName == m_sGraphics)
3903  {
3904  sSuffix += "graphic";
3906  m_pxDoc->getGraphicObjects(), rName, sSuffix );
3907  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3908  }
3909  else if(rName == m_sOLEs)
3910  {
3911  sSuffix += "ole";
3913  m_pxDoc->getEmbeddedObjects(), rName, sSuffix );
3914  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3915  }
3916  else if(rName == m_sOutlines)
3917  {
3918  sSuffix += "outline";
3920  *m_pxDoc, rName, sSuffix );
3921  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3922  }
3923  else if(rName == m_sBookmarks)
3924  {
3925  sSuffix.clear();
3927  m_pxDoc->getBookmarks(), rName, sSuffix );
3928  aRet <<= Reference< XPropertySet >(xBkms, UNO_QUERY);
3929  }
3930  else
3931  throw NoSuchElementException();
3932  return aRet;
3933 }
3934 
3936 {
3937  return { m_sTables,
3938  m_sFrames,
3939  m_sGraphics,
3940  m_sOLEs,
3941  m_sSections,
3942  m_sOutlines,
3943  m_sBookmarks };
3944 }
3945 
3947 {
3948  if( rName == m_sTables ||
3949  rName == m_sFrames ||
3950  rName == m_sGraphics||
3951  rName == m_sOLEs ||
3952  rName == m_sSections ||
3953  rName == m_sOutlines ||
3954  rName == m_sBookmarks )
3955  return true;
3956  return false;
3957 }
3958 
3960 {
3962 
3963 }
3964 
3966 {
3967  return nullptr != m_pxDoc;
3968 }
3969 
3971 {
3972  return "SwXLinkTargetSupplier";
3973 }
3974 
3976 {
3977  return cppu::supportsService(this, rServiceName);
3978 }
3979 
3981 {
3982  Sequence< OUString > aRet { "com.sun.star.document.LinkTargets" };
3983  return aRet;
3984 }
3985 
3987  Reference< XNameAccess > const & xAccess, const OUString& rLinkDisplayName, const OUString& sSuffix ) :
3988  m_xRealAccess(xAccess),
3989  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3990  m_sLinkSuffix(sSuffix),
3991  m_sLinkDisplayName(rLinkDisplayName),
3992  m_pxDoc(nullptr)
3993 {
3994 }
3995 
3997  const OUString& rLinkDisplayName, const OUString& sSuffix) :
3998  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3999  m_sLinkSuffix(sSuffix),
4000  m_sLinkDisplayName(rLinkDisplayName),
4001  m_pxDoc(&rxDoc)
4002 {
4003 }
4004 
4006 {
4007 }
4008 
4010 {
4011  Any aRet;
4012  bool bFound = false;
4013  //cut link extension and call the real NameAccess
4014  OUString sParam = rName;
4015  OUString sSuffix(m_sLinkSuffix);
4016  if(sParam.getLength() > sSuffix.getLength() )
4017  {
4018  OUString sCmp = sParam.copy(sParam.getLength() - sSuffix.getLength(),
4019  sSuffix.getLength());
4020  if(sCmp == sSuffix)
4021  {
4022  if(m_pxDoc)
4023  {
4024  sParam = sParam.copy(0, sParam.getLength() - sSuffix.getLength());
4025  if(!m_pxDoc->GetDocShell())
4026  throw RuntimeException("No document shell available");
4027  SwDoc* pDoc = m_pxDoc->GetDocShell()->GetDoc();
4028  const size_t nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
4029 
4030  for (size_t i = 0; i < nOutlineCount && !bFound; ++i)
4031  {
4032  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4033  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4034  if(sParam == lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
4035  {
4036  Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
4037  aRet <<= xOutline;
4038  bFound = true;
4039  }
4040  }
4041  }
4042  else
4043  {
4044  aRet = m_xRealAccess->getByName(sParam.copy(0, sParam.getLength() - sSuffix.getLength()));
4046  if(!(aRet >>= xInt))
4047  throw RuntimeException("Could not retrieve property");
4048  Reference< XPropertySet > xProp(xInt, UNO_QUERY);
4049  aRet <<= xProp;
4050  bFound = true;
4051  }
4052  }
4053  }
4054  if(!bFound)
4055  throw NoSuchElementException();
4056  return aRet;
4057 }
4058 
4060 {
4061  Sequence< OUString > aRet;
4062  if(m_pxDoc)
4063  {
4064  if(!m_pxDoc->GetDocShell())
4065  throw RuntimeException("No document shell available");
4066 
4067  SwDoc* pDoc = m_pxDoc->GetDocShell()->GetDoc();
4068  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4069  const size_t nOutlineCount = rOutlineNodes.size();
4070  aRet.realloc(nOutlineCount);
4071  OUString* pResArr = aRet.getArray();
4072  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4073  for (size_t i = 0; i < nOutlineCount; ++i)
4074  {
4075  OUString sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule) + "|outline";
4076  pResArr[i] = sEntry;
4077  }
4078  }
4079  else
4080  {
4081  Sequence< OUString > aOrg = m_xRealAccess->getElementNames();
4082  aRet.realloc(aOrg.getLength());
4083  std::transform(aOrg.begin(), aOrg.end(), aRet.begin(),
4084  [this](const OUString& rOrg) -> OUString { return rOrg + m_sLinkSuffix; });
4085  }
4086  return aRet;
4087 }
4088 
4090 {
4091  bool bRet = false;
4092  OUString sParam(rName);
4093  if(sParam.getLength() > m_sLinkSuffix.getLength() )
4094  {
4095  OUString sCmp = sParam.copy(sParam.getLength() - m_sLinkSuffix.getLength(),
4096  m_sLinkSuffix.getLength());
4097  if(sCmp == m_sLinkSuffix)
4098  {
4099  sParam = sParam.copy(0, sParam.getLength() - m_sLinkSuffix.getLength());
4100  if(m_pxDoc)
4101  {
4102  if(!m_pxDoc->GetDocShell())
4103  throw RuntimeException("No document shell available");
4104  SwDoc* pDoc = m_pxDoc->GetDocShell()->GetDoc();
4105  const size_t nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
4106 
4107  for (size_t i = 0; i < nOutlineCount && !bRet; ++i)
4108  {
4109  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4110  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4111  if(sParam ==
4112  lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
4113  {
4114  bRet = true;
4115  }
4116  }
4117  }
4118  else
4119  {
4120  bRet = m_xRealAccess->hasByName(sParam);
4121  }
4122  }
4123  }
4124  return bRet;
4125 }
4126 
4128 {
4130 }
4131 
4133 {
4134  bool bRet = false;
4135  if(m_pxDoc)
4136  {
4137  OSL_FAIL("not implemented");
4138  }
4139  else
4140  {
4141  bRet = m_xRealAccess->hasElements();
4142  }
4143  return bRet;
4144 }
4145 
4146 Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo()
4147 {
4148  static Reference< XPropertySetInfo > xRet = m_pPropSet->getPropertySetInfo();
4149  return xRet;
4150 }
4151 
4153  const OUString& rPropName, const Any& )
4154 {
4155  throw UnknownPropertyException(rPropName);
4156 }
4157 
4158 static Any lcl_GetDisplayBitmap(const OUString& _sLinkSuffix)
4159 {
4160  Any aRet;
4161  OUString sLinkSuffix = _sLinkSuffix;
4162  if(!sLinkSuffix.isEmpty())
4163  sLinkSuffix = sLinkSuffix.copy(1);
4164  OUString sImgId;
4165 
4166  if(sLinkSuffix == "outline")
4167  sImgId = RID_BMP_NAVI_OUTLINE;
4168  else if(sLinkSuffix == "table")
4169  sImgId = RID_BMP_NAVI_TABLE;
4170  else if(sLinkSuffix == "frame")
4171  sImgId = RID_BMP_NAVI_FRAME;
4172  else if(sLinkSuffix == "graphic")
4173  sImgId = RID_BMP_NAVI_GRAPHIC;
4174  else if(sLinkSuffix == "ole")
4175  sImgId = RID_BMP_NAVI_OLE;
4176  else if(sLinkSuffix.isEmpty())
4177  sImgId = RID_BMP_NAVI_BOOKMARK;
4178  else if(sLinkSuffix == "region")
4179  sImgId = RID_BMP_NAVI_REGION;
4180 
4181  if (!sImgId.isEmpty())
4182  {
4183  aRet <<= VCLUnoHelper::CreateBitmap(BitmapEx(sImgId));
4184  }
4185  return aRet;
4186 }
4187 
4188 Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName)
4189 {
4190  Any aRet;
4191  if( rPropertyName == UNO_LINK_DISPLAY_NAME )
4192  {
4193  aRet <<= m_sLinkDisplayName;
4194  }
4195  else if( rPropertyName == UNO_LINK_DISPLAY_BITMAP )
4196  {
4198  }
4199  else
4200  throw UnknownPropertyException(rPropertyName);
4201  return aRet;
4202 }
4203 
4205  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4206 {}
4207 
4209  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4210 {}
4211 
4213  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4214 {}
4215 
4217  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4218 {}
4219 
4221 {
4222  return this;
4223 }
4224 
4226 {
4227  return "SwXLinkNameAccessWrapper";
4228 }
4229 
4231 {
4232  return cppu::supportsService(this, rServiceName);
4233 }
4234 
4236 {
4237  Sequence< OUString > aRet { "com.sun.star.document.LinkTargets" };
4238  return aRet;
4239 }
4240 
4241 SwXOutlineTarget::SwXOutlineTarget(const OUString& rOutlineText) :
4242  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
4243  m_sOutlineText(rOutlineText)
4244 {
4245 }
4246 
4248 {
4249 }
4250 
4251 Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo()
4252 {
4253  static Reference< XPropertySetInfo > xRet = m_pPropSet->getPropertySetInfo();
4254  return xRet;
4255 }
4256 
4258  const OUString& rPropertyName, const Any& /*aValue*/)
4259 {
4260  throw UnknownPropertyException(rPropertyName);
4261 }
4262 
4263 Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
4264 {
4265  if(rPropertyName != UNO_LINK_DISPLAY_NAME)
4266  throw UnknownPropertyException(rPropertyName);
4267 
4268  return Any(m_sOutlineText);
4269 }
4270 
4272  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4273 {
4274 }
4275 
4277  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4278 {
4279 }
4280 
4282  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4283 {
4284 }
4285 
4287  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4288 {
4289 }
4290 
4292 {
4293  return "SwXOutlineTarget";
4294 }
4295 
4296 sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName)
4297 {
4298  return cppu::supportsService(this, ServiceName);
4299 }
4300 
4302 {
4303  Sequence<OUString> aRet { "com.sun.star.document.LinkTarget" };
4304 
4305  return aRet;
4306 }
4307 
4309 SvxUnoForbiddenCharsTable ( rDoc.getIDocumentSettingAccess().getForbiddenCharacterTable() )
4310 ,m_pDoc(&rDoc)
4311 {
4312 }
4313 
4315 {
4316 }
4317 
4319 {
4320  Reference<XInterface> xRet;
4321  if(m_pDoc)
4322  {
4323  switch(nWhich)
4324  {
4325  // #i52858#
4326  // assure that Draw model is created, if it doesn't exist.
4328  if(!m_xDashTable.is())
4330  xRet = m_xDashTable;
4331  break;
4333  if(!m_xGradientTable.is())
4335  xRet = m_xGradientTable;
4336  break;
4338  if(!m_xHatchTable.is())
4340  xRet = m_xHatchTable;
4341  break;
4343  if(!m_xBitmapTable.is())
4345  xRet = m_xBitmapTable;
4346  break;
4348  if(!m_xTransGradientTable.is())
4350  xRet = m_xTransGradientTable;
4351  break;
4353  if(!m_xMarkerTable.is())
4355  xRet = m_xMarkerTable;
4356  break;
4358  if(!m_xDrawDefaults.is())
4359  m_xDrawDefaults = static_cast<cppu::OWeakObject*>(new SwSvxUnoDrawPool(*m_pDoc));
4360  xRet = m_xDrawDefaults;
4361  break;
4362 #if OSL_DEBUG_LEVEL > 0
4363  default: OSL_FAIL("which table?");
4364 #endif
4365  }
4366  }
4367  return xRet;
4368 }
4369 
4371 {
4372  m_xDashTable = nullptr;
4373  m_xGradientTable = nullptr;
4374  m_xHatchTable = nullptr;
4375  m_xBitmapTable = nullptr;
4376  m_xTransGradientTable = nullptr;
4377  m_xMarkerTable = nullptr;
4378  m_xDrawDefaults = nullptr;
4379  m_pDoc = nullptr;
4381 }
4382 
4384 {
4385  if(m_pDoc)
4387 }
4388 
4390  SwViewShell& rSh, const SwViewOption &rViewOptions)
4391  : m_pShell(&rSh)
4392  , m_aOldViewOptions( rViewOptions )
4393 {
4394 }
4395 
4397 {
4398  if (m_pShell)
4399  {
4401  }
4402 }
4403 
4404 void
4405 SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const pPrtOptions, bool setShowPlaceHoldersInPDF)
4406 {
4407  // to avoid unnecessary reformatting the view options related to the content
4408  // below should only change if necessary, that is if respective content is present
4409  const bool bContainsHiddenChars = m_pShell->GetDoc()->ContainsHiddenChars();
4411  const bool bContainsHiddenFields = pFieldType && pFieldType->HasWriterListeners();
4413  const bool bContainsHiddenParagraphs = pFieldType && pFieldType->HasWriterListeners();
4415  const bool bContainsPlaceHolders = pFieldType && pFieldType->HasWriterListeners();
4416  const bool bContainsFields = m_pShell->IsAnyFieldInDoc();
4417 
4418  SwViewOption aRenderViewOptions( m_aOldViewOptions );
4419 
4420  // disable anything in the view that should not be printed (or exported to PDF) by default
4421  // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids"
4422  // in section "Display of ...")
4423  aRenderViewOptions.SetParagraph( false ); // paragraph end
4424  aRenderViewOptions.SetSoftHyph( false ); // aka custom hyphens
4425  aRenderViewOptions.SetBlank( false ); // spaces
4426  aRenderViewOptions.SetHardBlank( false ); // non-breaking spaces
4427  aRenderViewOptions.SetTab( false ); // tabs
4428  aRenderViewOptions.SetShowBookmarks( false ); // bookmarks
4429  aRenderViewOptions.SetLineBreak( false ); // breaks (type 1)
4430  aRenderViewOptions.SetPageBreak( false ); // breaks (type 2)
4431  aRenderViewOptions.SetColumnBreak( false ); // breaks (type 3)
4432  bool bVal = pPrtOptions && pPrtOptions->m_bPrintHiddenText;
4433  if (bContainsHiddenChars)
4434  aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text
4435  if (bContainsHiddenFields)
4436  aRenderViewOptions.SetShowHiddenField( bVal );
4437  if (bContainsHiddenParagraphs)
4438  aRenderViewOptions.SetShowHiddenPara( bVal );
4439 
4440  if (bContainsPlaceHolders)
4441  {
4442  // should always be printed in PDF export!
4443  bVal = !pPrtOptions ? setShowPlaceHoldersInPDF : pPrtOptions->m_bPrintTextPlaceholder;
4444  aRenderViewOptions.SetShowPlaceHolderFields( bVal );
4445  }
4446 
4447  if (bContainsFields)
4448  aRenderViewOptions.SetFieldName( false );
4449 
4450  // we need to set this flag in order to get to see the visible effect of
4451  // some of the above settings (needed for correct rendering)
4452  aRenderViewOptions.SetViewMetaChars( true );
4453 
4454  if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary
4455  {
4456  aRenderViewOptions.SetPrinting( pPrtOptions != nullptr );
4457  m_pShell->ApplyViewOptions( aRenderViewOptions );
4458  }
4459 }
4460 
4461 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual VclPtr< vcl::Window > getDocWindow() override
Definition: unotxdoc.cxx:3425
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
virtual css::uno::Any SAL_CALL getByName(const OUString &Name) override
Definition: unotxdoc.cxx:4009
virtual void SAL_CALL acquire() override
OUString const & getRuntimeUID() const
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:240
void SetLineBreak(bool b)
Definition: viewopt.hxx:254
static void UpdatePagesForPrintingWithPostItData(SwRenderData &rData, const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount)
Definition: doc.cxx:759
sal_Int32 GetBottomSpace() const
Definition: pvprtdat.hxx:48
bool setGraphicSelection(int nType, int nX, int nY, double fScaleX=1.0, double fScaleY=1.0)
void SetShowPlaceHolderFields(bool bSet)
Definition: viewopt.hxx:631
void SetCol(sal_uInt8 n)
Definition: pvprtdat.hxx:61
#define LANGUAGE_NONE
css::uno::Reference< css::container::XNameAccess > mxXTextFieldMasters
Definition: unotxdoc.hxx:163
void setGrabBagItem(const css::uno::Any &rVal)
IDocumentStatistics const & getIDocumentStatistics() const
Definition: doc.cxx:373
bool hasValidSignatures() const
SwViewShell * GetViewShell() const
Definition: pview.hxx:235
virtual ~SwXOutlineTarget() override
Definition: unotxdoc.cxx:4247
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotxdoc.cxx:4263
bool hasValue()
const SwStartNode * FindHeaderStartNode() const
Definition: node.hxx:202
bool IsPaperFromSetup() const
Definition: printdata.hxx:191
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
css::uno::Reference< css::text::XText > m_xBodyText
Definition: unotxdoc.hxx:152
static SvxAutoCorrCfg & Get()
virtual void ApplyViewOptions(const SwViewOption &rOpt)
Definition: viewsh.cxx:2115
Marks a position in the document model.
Definition: pam.hxx:35
static bool HasValidData(const css::uno::Reference< css::datatransfer::XTransferable > &rTransferable)
const OUString & GetTOIAutoMarkURL() const
Definition: doc.hxx:948
void SetSoftHyph(bool b)
Definition: viewopt.hxx:265
virtual OUString SAL_CALL getImplementationName() override
Definition: unotxdoc.cxx:3970
static bool HitAny(const Point &aPos)
std::map< const OUString, OUString > StringMap
bool HasReplaceAttributes() const
Definition: unosrch.cxx:633
bool IsValid() const
Definition: unotxdoc.hxx:456
css::uno::Reference< css::container::XNameAccess > mxXTextSections
Definition: unotxdoc.hxx:164
SdrView * GetDrawView()
Definition: vnew.cxx:375
virtual sal_Bool SAL_CALL hasByName(const OUString &Name) override
Definition: unotxdoc.cxx:3946
void SetAutoControlFocus(bool _bAutoControlFocus)
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:189
static bool lcl_SeqHasProperty(const uno::Sequence< beans::PropertyValue > &rOptions, const char *pPropName)
Definition: unotxdoc.cxx:2327
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotxdoc.cxx:4216
#define WID_DOC_WORD_COUNT
Definition: unomap.hxx:231
void SetZoom(sal_uInt16 n)
Definition: viewopt.hxx:495
virtual const css::uno::Sequence< sal_Int8 > & GetRedlinePassword() const =0
uno::Reference< text::XFlatParagraphIterator > CreateFlatParagraphIterator(SwDoc &rDoc, sal_Int32 const nTextMarkupType, bool const bAutomatic)
Definition: unoflatpara.cxx:59
static void PaintAllChartsOnTile(VirtualDevice &rDevice, int nOutputWidth, int nOutputHeight, int nTilePosX, int nTilePosY, tools::Long nTileWidth, tools::Long nTileHeight)
const char aData[]
Definition: ww8scan.hxx:47
OUString getPageRectangles()
Implementation of lok::Document::getPartPageRectangles() for Writer.
Definition: crsrsh.cxx:1296
const SwStartNode * FindFooterStartNode() const
Definition: node.hxx:204
virtual sal_Bool SAL_CALL attachResource(const OUString &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
Definition: unotxdoc.cxx:559
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getFootnotes() override
Definition: unotxdoc.cxx:653
OUString toISO8601(const css::util::DateTime &rDateTime)
SwDocShell * GetDocShell()
Definition: doc.hxx:1348
const SwRect & GetAnchorRect() const
static SwXTextRanges * Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1460
virtual ~SwXLinkNameAccessWrapper() override
Definition: unotxdoc.cxx:4005
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks() override
Definition: unotxdoc.cxx:4220
virtual void CalcLayout()
Definition: viewsh.cxx:976
std::unique_ptr< ContentProperties > pData
SwUnoCursor * FindAny(const css::uno::Reference< css::util::XSearchDescriptor > &xDesc, css::uno::Reference< css::text::XTextCursor > &xCursor, bool bAll, sal_Int32 &nResult, css::uno::Reference< css::uno::XInterface > const &xLastResult)
Definition: unotxdoc.cxx:801
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1407
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getFootnoteSettings() override
Definition: unotxdoc.cxx:666
bool HasSearchAttributes() const
Definition: unosrch.cxx:628
virtual void initializeForTiledRendering(const css::uno::Sequence< css::beans::PropertyValue > &rArguments) override
Definition: unotxdoc.cxx:3441
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:238
static void lcl_SavePrintUIOptionsToDocumentPrintData(SwDoc &rDoc, const SwPrintUIOptions &rPrintUIOptions, bool bIsPDFEXport)
Definition: unotxdoc.cxx:2444
void SetViewLayout(sal_uInt16 nColumns, bool bBookMode, bool bViewOnly=false)
Definition: viewmdi.cxx:223
css::uno::Reference< css::drawing::XDrawPage > mxXDrawPage
Definition: unotxdoc.hxx:150
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
SwNodeIndex nNode
Definition: pam.hxx:37
bool postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, double fScaleX=1.0, double fScaleY=1.0)
#define WID_DOC_CHAR_COUNT
Definition: unomap.hxx:229
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
virtual void SAL_CALL render(sal_Int32 nRenderer, const css::uno::Any &aSelection, const css::uno::Sequence< css::beans::PropertyValue > &xOptions) override
Definition: unotxdoc.cxx:2917
static bool lcl_GetBoolProperty(const uno::Sequence< beans::PropertyValue > &rOptions, const char *pPropName)
Definition: unotxdoc.cxx:2336
View of a document.
Definition: pview.hxx:161
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:796
void SetRedlineAuthor(const OUString &rAuthor)
Definition: viewprt.cxx:276
SwXOutlineTarget(const OUString &rOutlineText)
Definition: unotxdoc.cxx:4241
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
css::uno::Reference< css::container::XNameAccess > mxXBookmarks
Definition: unotxdoc.hxx:165
virtual void resetSelection() override
Definition: unotxdoc.cxx:3631
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unotxdoc.cxx:485
sal_Int32 GetRightSpace() const
Definition: pvprtdat.hxx:42
static VclPtr< OutputDevice > lcl_GetOutputDevice(const SwPrintUIOptions &rPrintUIOptions)
Definition: unotxdoc.cxx:2311
static bool IsPaste(const SwWrtShell &, const TransferableDataHelper &)
Definition: swdtflvr.cxx:1310
virtual void SetModified()=0
Must be called manually at changes of format.
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unotxdoc.cxx:606
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
long Long
virtual void SAL_CALL release() override
Definition: unotxdoc.cxx:341
const SwPosition * GetMark() const
Definition: pam.hxx:209
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unotxdoc.cxx:3935
virtual void SAL_CALL connectController(const css::uno::Reference< css::frame::XController > &xController) override
void LogicInvalidate(const tools::Rectangle *pRectangle) override
Definition: edtwin.cxx:6484
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:399
SfxViewShell * GuessViewShell(bool &rbIsSwSrcView, const css::uno::Reference< css::frame::XController > &rController=css::uno::Reference< css::frame::XController >())
Definition: unotxdoc.cxx:2878
void FillSearchOptions(i18nutil::SearchOptions2 &rSearchOpt) const
Definition: unosrch.cxx:653
css::uno::Reference< css::uno::XInterface > create(OUString const &rServiceName, css::uno::Sequence< css::uno::Any > const *arguments)
Definition: unotxdoc.cxx:1635
Find "all" in Footer/Header/Fly...
sal_Int32 addInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
virtual void setGraphicSelection(int nType, int nX, int nY) override
Definition: unotxdoc.cxx:3603
const SvxLanguageItem & GetLanguage(bool=true) const
Definition: charatr.hxx:92
virtual css::uno::Any SAL_CALL getByName(const OUString &Name) override
Definition: unotxdoc.cxx:3874
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:651
void SetLandscape(bool b)
Definition: pvprtdat.hxx:64
Definition: doc.hxx:184
ScopedJsonWriterNode startNode(const char *)
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotxdoc.cxx:3965
const SvxLanguageItem & GetCJKLanguage(bool=true) const
Definition: charatr.hxx:94
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:260
OUString m_sSearchText
Definition: unosrch.hxx:46
SwViewShell * m_pShell
Definition: unotxdoc.hxx:613
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getNumberingRules() override
Definition: unotxdoc.cxx:641
comphelper::OInterfaceContainerHelper2 & GetPasteListeners()
Definition: fecopy.cxx:1167
sal_Int16 nId
css::uno::Reference< css::container::XIndexReplace > mxXChapterNumbering
Definition: unotxdoc.hxx:172
css::uno::Sequence< OUString > getSupportedServiceNames()
SwDocShell * m_pDocShell
Definition: unotxdoc.hxx:146
OUString getImplementationName()
SwXDocumentPropertyHelper * GetPropertyHelper()
Definition: unotxdoc.cxx:441
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotxdoc.cxx:2181
virtual OUString GetPar1() const override
Author.
Definition: docufld.cxx:1798
const MapMode & GetMapMode() const
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotxdoc.cxx:2175
void AdjustViewOptions(SwPrintData const *const pPrtOptions, bool setShowPlaceHoldersInPDF)
Definition: unotxdoc.cxx:4405
::sw::DocumentRedlineManager const & GetDocumentRedlineManager() const
Definition: doc.cxx:345
virtual void SAL_CALL printPages(const css::uno::Sequence< css::beans::PropertyValue > &xOptions) override
Definition: unotxdoc.cxx:1123
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const OUString &ServiceSpecifier, const css::uno::Sequence< css::uno::Any > &Arguments) override
void SetRow(sal_uInt8 n)
Definition: pvprtdat.hxx:58
bool setTextSelection(int nType, int nX, int nY)
virtual std::unique_ptr< LockAllViewsGuard > LockAllViews() override
Definition: docsh.cxx:372
const OUString m_sLinkDisplayName
Definition: unotxdoc.hxx:516
SwEditWin & GetEditWin()
Definition: view.hxx:401
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotxdoc.cxx:4281
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: unotxdoc.cxx:2226
OUString m_sOutlineText
Definition: unotxdoc.hxx:561
std::shared_ptr< SvxForbiddenCharactersTable > mxForbiddenChars
void Pos(const Point &rNew)
Definition: swrect.hxx:169
#define WID_DOC_REDLINE_DISPLAY
Definition: unomap.hxx:237
virtual const SwDocStat & GetUpdatedDocStat(bool bCompleteAsync, bool bFields)=0
Updates the document statistics if the document has been modified and returns a reference to the resu...
OString join(const OString &rSeparator, const std::vector< OString > &rSequence)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies() override
Definition: unotxdoc.cxx:1310
sal_uInt8 GetCol() const
Definition: pvprtdat.hxx:60
void RecheckBrowseMode()
Definition: view0.cxx:166
void EnableMapMode(bool bEnable=true)
css::uno::Reference< css::frame::XModel > GetModel() const
bool GetAutoControlFocus() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void SetModified()
Definition: edws.cxx:70
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
virtual OUString SAL_CALL getImplementationName() override
Definition: unotxdoc.cxx:4291
void SetHardBlank(bool b)
Definition: viewopt.hxx:232
virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getRedlines() override
Definition: unotxdoc.cxx:2196
virtual void SAL_CALL disconnectController(const css::uno::Reference< css::frame::XController > &xController) override
Definition: unotxdoc.cxx:579
void SetShowHiddenChar(bool b)
Definition: viewopt.hxx:314
bool HasWriterListeners() const
Definition: calbck.hxx:210
virtual ~SwXDocumentPropertyHelper() override
Definition: unotxdoc.cxx:4314
void SetOpenInDesignMode(bool _bOpenDesignMode)
The root element of a Writer document layout.
Definition: rootfrm.hxx:80
void SetPrintGraphic(bool b)
Definition: printdata.hxx:150
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unotxdoc.cxx:1744
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4082
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
#define ODF_FORMDROPDOWN_RESULT
bool m_bApplyPagePrintSettingsFromXPagePrintable
Definition: unotxdoc.hxx:203
void SetColumnBreak(bool b)
Definition: viewopt.hxx:260
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getReferenceMarks() override
Definition: unotxdoc.cxx:1202
static void lcl_DisposeView(SfxViewFrame *pToClose, SwDocShell const *pDocShell)
Definition: unotxdoc.cxx:242
#define WID_DOC_CHANGES_PASSWORD
Definition: unomap.hxx:239
SwXTextCursor * CreateTextCursor(const bool bIgnoreTables=false)
Definition: unotext.cxx:2371
SfxItemSet GetAttribs(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags=GetAttribsFlags::ALL) const
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getDocumentIndexes() override
Definition: unotxdoc.cxx:1803
css::uno::Reference< css::container::XNameAccess > mxXTextFrames
Definition: unotxdoc.hxx:167
virtual OUString SAL_CALL getURL() override
bool IsAnyFieldInDoc() const
Check if the DocNodesArray contains fields.
Definition: vprint.cxx:612
SVXCORE_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoMarkerTable_createInstance(SdrModel *pModel)
void SetClipboard(css::uno::Reference< css::datatransfer::clipboard::XClipboard > const &xClipboard)
#define UNO_LINK_DISPLAY_BITMAP
Definition: unoprnms.hxx:455
static bool IsShowChanges(const RedlineFlags eM)
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getEndnoteSettings() override
Definition: unotxdoc.cxx:690
SwWrtShell & GetWrtShell() const
Definition: view.hxx:398
show all inserts
static LanguageType nLang
Definition: srtdlg.cxx:51
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPagePrintSettings() override
Definition: unotxdoc.cxx:976
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
const SwPostItField * GetPostItField() const
void CheckViewLayout(const SwViewOption *pViewOpt, const SwRect *pVisArea)
Definition: pagechg.cxx:2065
size_type size() const
Definition: docary.hxx:266
SwDocPositions
Definition: cshtyp.hxx:103
css::uno::Reference< css::container::XIndexAccess > mxXDocumentIndexes
Definition: unotxdoc.hxx:173
virtual css::uno::Reference< css::util::XReplaceDescriptor > SAL_CALL createReplaceDescriptor() override
Definition: unotxdoc.cxx:702
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
vcl::Window * GetWindow()
bool bAFormatByInpDelSpacesAtSttEnd
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
css::uno::Reference< css::uno::XInterface > m_xMarkerTable
Definition: unotxdoc.hxx:593
css::uno::Any const & rValue
virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getDrawPage() override
Definition: unotxdoc.cxx:1335
virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController() override
tools::Long ResetSelect(const Point *, bool)
Definition: select.cxx:332
void Reactivate(SwDocShell *pNewDocShell)
Definition: unotxdoc.cxx:1442
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotxdoc.cxx:1816
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotxdoc.cxx:351
void CallAutomationDocumentEventSinks(const OUString &Method, css::uno::Sequence< css::uno::Any > &Arguments)
Definition: docsh.cxx:1398
const SwView & GetView() const
Definition: wrtsh.hxx:428
SwXLinkNameAccessWrapper(css::uno::Reference< css::container::XNameAccess > const &xAccess, const OUString &rLinkDisplayName, const OUString &sSuffix)
Reference< XController > xController
A class that stores temporary data that is needed for rendering the document.
Definition: printdata.hxx:203
bool IsPrintProspect() const
Definition: printdata.hxx:185
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getRenderer(sal_Int32 nRenderer, const css::uno::Any &aSelection, const css::uno::Sequence< css::beans::PropertyValue > &xOptions) override
Definition: unotxdoc.cxx:2648
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
sal_Int32 PrintSource(OutputDevice *pOutDev, sal_Int32 nPage, bool bCalcNumPagesOnly)
Definition: srcview.cxx:661
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override