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 
24 #include <comphelper/string.hxx>
25 #include <AnnotationWin.hxx>
26 #include <o3tl/any.hxx>
27 #include <osl/mutex.hxx>
28 #include <vcl/commandevent.hxx>
29 #include <vcl/image.hxx>
30 #include <vcl/vclevent.hxx>
31 #include <vcl/virdev.hxx>
32 #include <vcl/sysdata.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/print.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/lokhelper.hxx>
38 #include <sfx2/docfile.hxx>
39 #include <sfx2/msg.hxx>
40 #include <sfx2/msgpool.hxx>
41 #include <sfx2/printer.hxx>
44 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
45 #include <sfx2/lokcharthelper.hxx>
46 #include <sfx2/ipclient.hxx>
47 #include <editeng/svxacorr.hxx>
48 #include <editeng/acorrcfg.hxx>
49 #include <cmdid.h>
50 #include <swtypes.hxx>
51 #include <wdocsh.hxx>
52 #include <wrtsh.hxx>
53 #include <pview.hxx>
54 #include <viewsh.hxx>
55 #include <pvprtdat.hxx>
56 #include <printdata.hxx>
57 #include <pagefrm.hxx>
58 #include <rootfrm.hxx>
59 #include <svl/stritem.hxx>
60 #include <unotxdoc.hxx>
61 #include <svl/numuno.hxx>
62 #include <fldbas.hxx>
63 #include <unomap.hxx>
64 #include <unotextbodyhf.hxx>
65 #include <unotextrange.hxx>
66 #include <unotextcursor.hxx>
67 #include <unosett.hxx>
68 #include <unocoll.hxx>
69 #include <unoredlines.hxx>
70 #include <unosrch.hxx>
71 #include <sfx2/dispatch.hxx>
72 #include <sfx2/request.hxx>
73 #include <sfx2/objsh.hxx>
74 #include <unoprnms.hxx>
75 #include <unostyle.hxx>
76 #include <unodraw.hxx>
77 #include <svl/eitem.hxx>
78 #include <pagedesc.hxx>
79 #include <unotools/datetime.hxx>
80 #include <unotools/textsearch.hxx>
81 #include <unocrsr.hxx>
82 #include <unofieldcoll.hxx>
83 #include <unoidxcoll.hxx>
84 #include <unocrsrhelper.hxx>
85 #include <unotxvw.hxx>
86 #include <poolfmt.hxx>
87 #include <globdoc.hxx>
88 #include <viewopt.hxx>
89 #include <unochart.hxx>
90 #include <charatr.hxx>
91 #include <svx/xmleohlp.hxx>
92 #include <globals.hrc>
93 #include <unomid.h>
95 #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
96 #include <com/sun/star/lang/DisposedException.hpp>
97 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
98 #include <com/sun/star/lang/NoSupportException.hpp>
99 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
100 #include <com/sun/star/beans/PropertyAttribute.hpp>
101 #include <com/sun/star/beans/XFastPropertySet.hpp>
102 #include <com/sun/star/document/RedlineDisplayType.hpp>
103 #include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
104 #include <com/sun/star/frame/XController.hpp>
105 #include <com/sun/star/frame/XFrame.hpp>
106 #include <com/sun/star/script/XInvocation.hpp>
107 #include <sfx2/linkmgr.hxx>
108 #include <svx/unofill.hxx>
109 #include <editeng/unolingu.hxx>
110 #include <sfx2/progress.hxx>
111 #include <swmodule.hxx>
112 #include <docstat.hxx>
113 #include <modcfg.hxx>
114 #include <ndtxt.hxx>
115 #include <strings.hrc>
116 #include <bitmaps.hlst>
117 #include <swcont.hxx>
118 #include "unodefaults.hxx"
119 #include "SwXDocumentSettings.hxx"
120 #include <doc.hxx>
122 #include <IDocumentDeviceAccess.hxx>
127 #include <IDocumentFieldsAccess.hxx>
128 #include <IDocumentStatistics.hxx>
130 #include <IDocumentLayoutAccess.hxx>
131 #include <IDocumentState.hxx>
133 #include <svl/zforlist.hxx>
134 #include <drawdoc.hxx>
135 #include <SwStyleNameMapper.hxx>
136 #include <osl/file.hxx>
137 #include <comphelper/lok.hxx>
140 #include <unotools/saveopt.hxx>
141 #include <swruler.hxx>
142 #include <docufld.hxx>
143 
144 
146 #include <numrule.hxx>
147 
148 #include <editeng/langitem.hxx>
149 #include <docary.hxx>
151 #include <i18nutil/searchopt.hxx>
152 
153 #include <format.hxx>
154 #include <charfmt.hxx>
155 #include <fmtcol.hxx>
156 #include <istyleaccess.hxx>
157 
158 #include <svl/stylepool.hxx>
159 #include <swatrset.hxx>
160 #include <view.hxx>
161 #include <viscrs.hxx>
162 #include <srcview.hxx>
163 #include <edtwin.hxx>
164 #include <swdtflvr.hxx>
165 #include <PostItMgr.hxx>
166 
167 #include <svtools/langtab.hxx>
168 #include <map>
169 #include <set>
170 #include <vector>
171 
172 #include <editeng/eeitem.hxx>
173 #include <editeng/editeng.hxx>
174 #include <editeng/editview.hxx>
175 #include <svx/svdoutl.hxx>
176 #include <svl/languageoptions.hxx>
177 #include <svx/svdview.hxx>
180 #include <memory>
181 #include <fchrfmt.hxx>
182 #include <redline.hxx>
184 
185 #define TWIPS_PER_PIXEL 15
186 
187 using namespace ::com::sun::star;
188 using namespace ::com::sun::star::text;
189 using namespace ::com::sun::star::i18n;
190 using namespace ::com::sun::star::uno;
191 using namespace ::com::sun::star::beans;
192 using namespace ::com::sun::star::lang;
193 using namespace ::com::sun::star::container;
194 using namespace ::com::sun::star::document;
195 using ::osl::FileBase;
196 
197 static std::unique_ptr<SwPrintUIOptions> lcl_GetPrintUIOptions(
198  SwDocShell * pDocShell,
199  const SfxViewShell * pView )
200 {
201  if (!pDocShell)
202  return nullptr;
203 
204  const bool bWebDoc = nullptr != dynamic_cast< const SwWebDocShell * >(pDocShell);
205  const bool bSwSrcView = nullptr != dynamic_cast< const SwSrcView * >(pView);
206  const SwView * pSwView = dynamic_cast< const SwView * >(pView);
207  const bool bHasSelection = pSwView && pSwView->HasSelection( false ); // check for any selection, not just text selection
208  const bool bHasPostIts = sw_GetPostIts( &pDocShell->GetDoc()->getIDocumentFieldsAccess(), nullptr );
209 
210  // get default values to use in dialog from documents SwPrintData
211  const SwPrintData &rPrintData = pDocShell->GetDoc()->getIDocumentDeviceAccess().getPrintData();
212 
213  // Get current page number
214  sal_uInt16 nCurrentPage = 1;
215  const SwWrtShell* pSh = pDocShell->GetWrtShell();
216  const SwRootFrame *pFrame = nullptr;
217  if (pSh)
218  {
219  SwPaM* pShellCursor = pSh->GetCursor();
220  nCurrentPage = pShellCursor->GetPageNum();
221  pFrame = pSh->GetLayout();
222  }
223  else if (!bSwSrcView)
224  {
225  const SwPagePreview* pPreview = dynamic_cast< const SwPagePreview* >(pView);
226  OSL_ENSURE(pPreview, "Unexpected type of the view shell");
227  if (pPreview)
228  {
229  nCurrentPage = pPreview->GetSelectedPage();
230  pFrame = pPreview->GetViewShell()->GetLayout();
231  }
232  }
233 
234  // If blanks are skipped, account for them in initial page range value
235  if (pFrame && !rPrintData.IsPrintEmptyPages())
236  {
237  sal_uInt16 nMax = nCurrentPage;
238  const SwPageFrame *pPage = dynamic_cast<const SwPageFrame*>(pFrame->Lower());
239  while (pPage && nMax-- > 0)
240  {
241  if (pPage->getFrameArea().Height() == 0)
242  nCurrentPage--;
243  pPage = static_cast<const SwPageFrame*>(pPage->GetNext());
244  }
245  }
246  return std::make_unique<SwPrintUIOptions>( nCurrentPage, bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData );
247 }
248 
249 static SwTextFormatColl *lcl_GetParaStyle(const OUString& rCollName, SwDoc* pDoc)
250 {
251  SwTextFormatColl* pColl = pDoc->FindTextFormatCollByName( rCollName );
252  if( !pColl )
253  {
254  const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
255  rCollName, SwGetPoolIdFromName::TxtColl );
256  if( USHRT_MAX != nId )
257  pColl = pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( nId );
258  }
259  return pColl;
260 }
261 
262 static void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell const * pDocShell )
263 {
264  // check if the view frame still exists
265  SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell, false );
266  while(pFound)
267  {
268  if( pFound == pToClose)
269  {
270  pToClose->DoClose();
271  break;
272  }
273  pFound = SfxViewFrame::GetNext( *pFound, pDocShell, false );
274  }
275 }
276 
278 {
279 private:
280  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
281 
282 public:
284 
285  Impl() : m_RefreshListeners(m_Mutex) { }
286 
287 };
288 
289 namespace
290 {
291  class theSwXTextDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextDocumentUnoTunnelId > {};
292 }
293 
295 {
296  return theSwXTextDocumentUnoTunnelId::get().getSeq();
297 }
298 
299 sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId )
300 {
301  if( isUnoTunnelId<SwXTextDocument>(rId) )
302  {
303  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
304  }
305  if( isUnoTunnelId<SfxObjectShell>(rId) )
306  {
307  return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell ));
308  }
309 
310  sal_Int64 nRet = SfxBaseModel::getSomething( rId );
311  if (nRet)
312  return nRet;
313 
315  if (!xNumFormatAgg.is()) // may happen if not valid or no SwDoc
316  return 0;
317  Any aNumTunnel = xNumFormatAgg->queryAggregation(cppu::UnoType<XUnoTunnel>::get());
318  Reference<XUnoTunnel> xNumTunnel;
319  aNumTunnel >>= xNumTunnel;
320  return (xNumTunnel.is()) ? xNumTunnel->getSomething(rId) : 0;
321 }
322 
324 {
325  Any aRet = SwXTextDocumentBaseClass::queryInterface(rType);
326  if ( !aRet.hasValue() )
327  aRet = SfxBaseModel::queryInterface(rType);
328  if ( !aRet.hasValue() &&
330  {
332  aRet <<= xTmp;
333  }
334  if ( !aRet.hasValue() &&
336  {
337  Reference<tiledrendering::XTiledRenderable> xTmp = this;
338  aRet <<= xTmp;
339  }
340 
341  if ( !aRet.hasValue()
348  {
350  if(xNumFormatAgg.is())
351  aRet = xNumFormatAgg->queryAggregation(rType);
352  }
353  return aRet;
354 }
355 
356 void SAL_CALL SwXTextDocument::acquire()throw()
357 {
359 }
360 
361 void SAL_CALL SwXTextDocument::release()throw()
362 {
364 }
365 
367 {
368  return SfxBaseModel::queryAdapter();
369 }
370 
371 Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes()
372 {
373  Sequence< uno::Type > aNumTypes;
375  if(xNumFormatAgg.is())
376  {
377  const uno::Type& rProvType = cppu::UnoType<XTypeProvider>::get();
378  Any aNumProv = xNumFormatAgg->queryAggregation(rProvType);
379  Reference<XTypeProvider> xNumProv;
380  if(aNumProv >>= xNumProv)
381  {
382  aNumTypes = xNumProv->getTypes();
383  }
384  }
387  SwXTextDocumentBaseClass::getTypes(),
388  aNumTypes,
389  Sequence {
392 }
393 
395  : SfxBaseModel(pShell)
396  , m_pImpl(new Impl)
397  ,
398  pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)),
399 
400  pDocShell(pShell),
401 
402  bObjectValid(pShell != nullptr),
403 
404  pDrawPage(nullptr),
405  mxXDrawPage(),
406  pBodyText(nullptr),
407  mxXNumberingRules(),
408  mxXFootnotes(),
409  mxXFootnoteSettings(),
410  mxXEndnotes(),
411  mxXEndnoteSettings(),
412  mxXReferenceMarks(),
413  mxXTextFieldTypes(),
414  mxXTextFieldMasters(),
415  mxXTextSections(),
416  mxXBookmarks(),
417  mxXTextTables(),
418  mxXTextFrames(),
419  mxXGraphicObjects(),
420  mxXEmbeddedObjects(),
421  mxXStyleFamilies(),
422  mxXAutoStyles(),
423  mxXChapterNumbering(),
424  mxXDocumentIndexes(),
425 
426  mxXLineNumberingProperties(),
427  mxLinkTargetSupplier(),
428  mxXRedlines(),
429  m_pHiddenViewFrame(nullptr),
430  // #i117783#
431  bApplyPagePrintSettingsFromXPagePrintable( false )
432 {
433 }
434 
436 {
437  OSL_ENSURE(pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetOrCreateDrawModel(), "No SdrModel in SwDoc, should not happen");
439 }
440 
442 {
443  InitNewDoc();
444  if(xNumFormatAgg.is())
445  {
447  xNumFormatAgg->setDelegator(x0);
448  xNumFormatAgg = nullptr;
449  }
450  m_pPrintUIOptions.reset();
451  if (m_pRenderData && m_pRenderData->IsViewOptionAdjust())
452  { // rhbz#827695: this can happen if the last page is not printed
453  // the SwViewShell has been deleted already by SwView::~SwView
454  // FIXME: replace this awful implementation of XRenderable with
455  // something less insane that has its own view
456  m_pRenderData->ViewOptionAdjustCrashPreventionKludge();
457  }
458  m_pRenderData.reset();
459 }
460 
462 {
463  if(!mxPropertyHelper.is())
464  {
466  }
467  return mxPropertyHelper.get();
468 }
469 
471 {
472  if(IsValid())
473  {
474  if(!xNumFormatAgg.is())
475  {
476  if ( pDocShell->GetDoc() )
477  {
480  Reference< util::XNumberFormatsSupplier > xTmp = pNumFormat;
481  xNumFormatAgg.set(xTmp, UNO_QUERY);
482  }
483  if(xNumFormatAgg.is())
484  xNumFormatAgg->setDelegator(static_cast<cppu::OWeakObject*>(static_cast<SwXTextDocumentBaseClass*>(this)));
485  }
486  else
487  {
488  const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
489  Any aNumTunnel = xNumFormatAgg->queryAggregation(rTunnelType);
490  SvNumberFormatsSupplierObj* pNumFormat = nullptr;
491  Reference< XUnoTunnel > xNumTunnel;
492  if(aNumTunnel >>= xNumTunnel)
493  {
494  pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
495  xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
496 
497  }
498  OSL_ENSURE(pNumFormat, "No number formatter available");
499  if (pNumFormat && !pNumFormat->GetNumberFormatter())
501  }
502  }
503 }
504 
505 Reference< XText > SwXTextDocument::getText()
506 {
507  SolarMutexGuard aGuard;
508  if(!IsValid())
509  throw DisposedException("", static_cast< XTextDocument* >(this));
510  if(!xBodyText.is())
511  {
514  }
515  return xBodyText;
516 }
517 
519 {
520  SolarMutexGuard aGuard;
521  if(!IsValid())
522  throw DisposedException("", static_cast< XTextDocument* >(this));
523 }
524 
526 {
527  SolarMutexGuard aGuard;
528  if(!IsValid())
529  throw DisposedException("", static_cast< XTextDocument* >(this));
530 
531  maActionArr.emplace_front(new UnoActionContext(pDocShell->GetDoc()));
532 }
533 
535 {
536  SolarMutexGuard aGuard;
537  if(maActionArr.empty())
538  throw RuntimeException("Nothing to unlock");
539 
540  maActionArr.pop_front();
541 }
542 
544 {
545  SolarMutexGuard aGuard;
546  return !maActionArr.empty();
547 }
548 
549 Reference< frame::XController > SwXTextDocument::getCurrentController()
550 {
552 }
553 
554 void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController)
555 {
557 }
558 
560 {
561  SolarMutexGuard aGuard;
563  if(IsValid())
564  {
565  SwView* pView = static_cast<SwView*>(SfxViewShell::GetFirst(true, checkSfxViewShell<SwView>));
566  while(pView && pView->GetObjectShell() != pDocShell)
567  {
568  pView = static_cast<SwView*>(SfxViewShell::GetNext(*pView, true, checkSfxViewShell<SwView>));
569  }
570  if(pView)
571  {
572  Any aRef = pView->GetUNOObject()->getSelection();
573  aRef >>= xRef;
574  }
575  }
576  return xRef;
577 }
578 
580 {
581  return SfxBaseModel::attachResource(aURL, aArgs);
582 }
583 
585 {
586  return SfxBaseModel::getURL();
587 }
588 
590 {
591  return SfxBaseModel::getArgs();
592 }
593 
594 void SwXTextDocument::connectController(const Reference< frame::XController > & xController)
595 {
596  SfxBaseModel::connectController(xController);
597 }
598 
599 void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController)
600 {
602 }
603 
605 {
607 }
608 
609 void SwXTextDocument::close( sal_Bool bDeliverOwnership )
610 {
611  if(pDocShell)
612  {
613  uno::Sequence< uno::Any > aArgs;
614  pDocShell->CallAutomationDocumentEventSinks( "Close", aArgs );
615  }
616  SolarMutexGuard aGuard;
617  if(IsValid() && m_pHiddenViewFrame)
619  SfxBaseModel::close(bDeliverOwnership);
620 }
621 
622 void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener)
623 {
625 }
626 
627 void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener)
628 {
630 }
631 
633 {
634  SolarMutexGuard aGuard;
635  if(!IsValid())
636  throw DisposedException("", static_cast< XTextDocument* >(this));
637 
639  {
641  }
643 }
644 
645 Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules()
646 {
647  SolarMutexGuard aGuard;
648  if(!IsValid())
649  throw DisposedException("", static_cast< XTextDocument* >(this));
650  if(!mxXChapterNumbering.is())
651  {
653  }
654  return mxXChapterNumbering;
655 }
656 
657 Reference< XIndexAccess > SwXTextDocument::getNumberingRules()
658 {
659  SolarMutexGuard aGuard;
660  if(!IsValid())
661  throw DisposedException("", static_cast< XTextDocument* >(this));
662  if(!mxXNumberingRules.is() )
663  {
665  }
666  return mxXNumberingRules;
667 }
668 
669 Reference< XIndexAccess > SwXTextDocument::getFootnotes()
670 {
671  SolarMutexGuard aGuard;
672  if(!IsValid())
673  throw DisposedException("", static_cast< XTextDocument* >(this));
674  if(!mxXFootnotes.is())
675  {
676  mxXFootnotes = new SwXFootnotes(false, pDocShell->GetDoc());
677  }
678  return mxXFootnotes;
679 }
680 
681 Reference< XPropertySet > SAL_CALL
683 {
684  SolarMutexGuard aGuard;
685  if(!IsValid())
686  throw DisposedException("", static_cast< XTextDocument* >(this));
687  if(!mxXFootnoteSettings.is())
688  {
690  }
691  return mxXFootnoteSettings;
692 }
693 
694 Reference< XIndexAccess > SwXTextDocument::getEndnotes()
695 {
696  SolarMutexGuard aGuard;
697  if(!IsValid())
698  throw DisposedException("", static_cast< XTextDocument* >(this));
699  if(!mxXEndnotes.is())
700  {
701  mxXEndnotes = new SwXFootnotes(true, pDocShell->GetDoc());
702  }
703  return mxXEndnotes;
704 }
705 
706 Reference< XPropertySet > SwXTextDocument::getEndnoteSettings()
707 {
708  SolarMutexGuard aGuard;
709  if(!IsValid())
710  throw DisposedException("", static_cast< XTextDocument* >(this));
711  if(!mxXEndnoteSettings.is())
712  {
714  }
715  return mxXEndnoteSettings;
716 }
717 
718 Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor()
719 {
720  SolarMutexGuard aGuard;
721  Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch;
722  return xRet;
723 }
724 
725 SwUnoCursor* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCursor)
726 {
727  getText();
728  XText *const pText = xBodyText.get();
729  SwXBodyText* pBText = static_cast<SwXBodyText*>(pText);
730  SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true);
731  xCursor.set( static_cast<text::XWordCursor*>(pXTextCursor) );
732 
733  auto& rUnoCursor(pXTextCursor->GetCursor());
734  rUnoCursor.SetRemainInSection(false);
735  return &rUnoCursor;
736 }
737 
738 sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc)
739 {
740  SolarMutexGuard aGuard;
741  Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY_THROW);
742  if(!IsValid() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
743  throw DisposedException("", static_cast< XTextDocument* >(this));
744 
745  Reference< XTextCursor > xCursor;
746  auto pUnoCursor(CreateCursorForSearch(xCursor));
747 
748  const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
749  xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
750 
752 
753  i18nutil::SearchOptions2 aSearchOpt;
754  pSearch->FillSearchOptions( aSearchOpt );
755 
758 
759  // Search should take place anywhere
760  pUnoCursor->SetRemainInSection(false);
761  sal_uInt32 nResult;
762  UnoActionContext aContext(pDocShell->GetDoc());
763  //try attribute search first
764  if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes())
765  {
766  SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
770  SfxItemSet aReplace(pDocShell->GetDoc()->GetAttrPool(),
771  svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1,
772  RES_PARATR_BEGIN, RES_PARATR_END-1,
774  pSearch->FillSearchItemSet(aSearch);
775  pSearch->FillReplaceItemSet(aReplace);
776  bool bCancel;
777  nResult = static_cast<sal_Int32>(pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
778  eStart, eEnd, bCancel,
779  static_cast<FindRanges>(eRanges),
780  !pSearch->m_sSearchText.isEmpty() ? &aSearchOpt : nullptr,
781  &aReplace ));
782  }
783  else if(pSearch->m_bStyles)
784  {
785  SwTextFormatColl *pSearchColl = lcl_GetParaStyle(pSearch->m_sSearchText, pUnoCursor->GetDoc());
786  SwTextFormatColl *pReplaceColl = lcl_GetParaStyle(pSearch->m_sReplaceText, pUnoCursor->GetDoc());
787 
788  bool bCancel;
789  nResult = pUnoCursor->FindFormat(*pSearchColl,
790  eStart, eEnd, bCancel,
791  static_cast<FindRanges>(eRanges), pReplaceColl );
792 
793  }
794  else
795  {
796  //todo/mba: assuming that notes should be omitted
797  bool bCancel;
798  nResult = pUnoCursor->Find_Text(aSearchOpt, false/*bSearchInNotes*/,
799  eStart, eEnd, bCancel,
800  static_cast<FindRanges>(eRanges),
801  true );
802  }
803  return static_cast<sal_Int32>(nResult);
804 
805 }
806 
807 Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor()
808 {
809  SolarMutexGuard aGuard;
810  Reference< util::XSearchDescriptor > xRet = new SwXTextSearch;
811  return xRet;
812 
813 }
814 
815 // Used for findAll/First/Next
816 
817 SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
818  Reference< XTextCursor > & xCursor,
819  bool bAll,
820  sal_Int32& nResult,
821  Reference< XInterface > const & xLastResult)
822 {
823  const auto pSearch = comphelper::getUnoTunnelImplementation<SwXTextSearch>(xDesc);
824  if(!IsValid() || !pSearch)
825  return nullptr;
826 
827  auto pUnoCursor(CreateCursorForSearch(xCursor));
828 
829  bool bParentInExtra = false;
830  if(xLastResult.is())
831  {
832  Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
833  OTextCursorHelper* pPosCursor = nullptr;
834  if(xCursorTunnel.is())
835  {
836  pPosCursor = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
838  }
839  SwPaM* pCursor = pPosCursor ? pPosCursor->GetPaM() : nullptr;
840  if(pCursor)
841  {
842  *pUnoCursor->GetPoint() = *pCursor->End();
843  pUnoCursor->DeleteMark();
844  }
845  else
846  {
847  SwXTextRange* pRange = nullptr;
848  if(xCursorTunnel.is())
849  {
850  pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
852  }
853  if(!pRange)
854  return nullptr;
855  pRange->GetPositions(*pUnoCursor);
856  if(pUnoCursor->HasMark())
857  {
858  if(*pUnoCursor->GetPoint() < *pUnoCursor->GetMark())
859  pUnoCursor->Exchange();
860  pUnoCursor->DeleteMark();
861  }
862  }
863  const SwNode& rRangeNode = pUnoCursor->GetNode();
864  bParentInExtra = rRangeNode.FindFlyStartNode() ||
865  rRangeNode.FindFootnoteStartNode() ||
866  rRangeNode.FindHeaderStartNode() ||
867  rRangeNode.FindFooterStartNode() ;
868  }
869 
870  i18nutil::SearchOptions2 aSearchOpt;
871  pSearch->FillSearchOptions( aSearchOpt );
872 
882  if(bParentInExtra)
883  eRanges = FindRanges::InOther;
884  if(bAll) //always - everywhere?
885  eRanges = FindRanges::InSelAll;
886  SwDocPositions eStart = !bAll ? SwDocPositions::Curr : pSearch->m_bBack ? SwDocPositions::End : SwDocPositions::Start;
887  SwDocPositions eEnd = pSearch->m_bBack ? SwDocPositions::Start : SwDocPositions::End;
888 
889  nResult = 0;
890  for (int nSearchProc = 0; nSearchProc < 2; ++nSearchProc)
891  {
892  //try attribute search first
893  if(pSearch->HasSearchAttributes())
894  {
895  SfxItemSet aSearch(
897  svl::Items<
902  pSearch->FillSearchItemSet(aSearch);
903  bool bCancel;
904  nResult = static_cast<sal_Int32>(pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
905  eStart, eEnd, bCancel,
906  eRanges,
907  !pSearch->m_sSearchText.isEmpty() ? &aSearchOpt : nullptr ));
908  }
909  else if(pSearch->m_bStyles)
910  {
911  SwTextFormatColl *pSearchColl = lcl_GetParaStyle(pSearch->m_sSearchText, pUnoCursor->GetDoc());
912  //pSearch->sReplaceText
913  SwTextFormatColl *pReplaceColl = nullptr;
914  bool bCancel;
915  nResult = static_cast<sal_Int32>(pUnoCursor->FindFormat(*pSearchColl,
916  eStart, eEnd, bCancel,
917  eRanges, pReplaceColl ));
918  }
919  else
920  {
921  //todo/mba: assuming that notes should be omitted
922  bool bCancel;
923  nResult = static_cast<sal_Int32>(pUnoCursor->Find_Text(aSearchOpt, false/*bSearchInNotes*/,
924  eStart, eEnd, bCancel,
925  eRanges ));
926  }
927  if(nResult || (eRanges&(FindRanges::InSelAll|FindRanges::InOther)))
928  break;
929  //second step - find in other
930  eRanges = FindRanges::InOther;
931  }
932  return pUnoCursor;
933 }
934 
935 Reference< XIndexAccess >
936  SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc)
937 {
938  SolarMutexGuard aGuard;
940  sal_Int32 nResult = 0;
941  Reference< XTextCursor > xCursor;
942  auto pResultCursor(FindAny(xDesc, xCursor, true, nResult, xTmp));
943  if(!pResultCursor)
944  throw RuntimeException("No result cursor");
945  Reference< XIndexAccess > xRet = SwXTextRanges::Create( nResult ? &(*pResultCursor) : nullptr );
946  return xRet;
947 }
948 
949 Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc)
950 {
951  SolarMutexGuard aGuard;
953  sal_Int32 nResult = 0;
954  Reference< XTextCursor > xCursor;
955  auto pResultCursor(FindAny(xDesc, xCursor, false, nResult, xTmp));
956  if(!pResultCursor)
957  throw RuntimeException("No result cursor");
959  if(nResult)
960  {
961  const uno::Reference< text::XText > xParent =
963  *pResultCursor->GetPoint());
964  xRet = *new SwXTextCursor(xParent, *pResultCursor);
965  }
966  return xRet;
967 }
968 
970  const Reference< util::XSearchDescriptor > & xDesc)
971 {
972  SolarMutexGuard aGuard;
973  sal_Int32 nResult = 0;
974  Reference< XTextCursor > xCursor;
975  if(!xStartAt.is())
976  throw RuntimeException("xStartAt missing");
977  auto pResultCursor(FindAny(xDesc, xCursor, false, nResult, xStartAt));
978  if(!pResultCursor)
979  throw RuntimeException("No result cursor");
981  if(nResult)
982  {
983  const uno::Reference< text::XText > xParent =
985  *pResultCursor->GetPoint());
986 
987  xRet = *new SwXTextCursor(xParent, *pResultCursor);
988  }
989  return xRet;
990 }
991 
993 {
994  SolarMutexGuard aGuard;
996  if(!IsValid())
997  throw DisposedException("", static_cast< XTextDocument* >(this));
998 
999  beans::PropertyValue* pArray = aSeq.getArray();
1002  if(pData)
1003  aData = *pData;
1004  Any aVal;
1005  aVal <<= static_cast<sal_Int16>(aData.GetRow());
1006  pArray[0] = beans::PropertyValue("PageRows", -1, aVal, PropertyState_DIRECT_VALUE);
1007  aVal <<= static_cast<sal_Int16>(aData.GetCol());
1008  pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE);
1009  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetLeftSpace()));
1010  pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1011  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetRightSpace()));
1012  pArray[3] = beans::PropertyValue("RightMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1013  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetTopSpace()));
1014  pArray[4] = beans::PropertyValue("TopMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1015  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetBottomSpace()));
1016  pArray[5] = beans::PropertyValue("BottomMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1017  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetHorzSpace()));
1018  pArray[6] = beans::PropertyValue("HoriMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1019  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetVertSpace()));
1020  pArray[7] = beans::PropertyValue("VertMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1021  aVal <<= aData.GetLandscape();
1022  pArray[8] = beans::PropertyValue("IsLandscape", -1, aVal, PropertyState_DIRECT_VALUE);
1023 
1024  return aSeq;
1025 }
1026 
1027 static sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, bool& bException)
1028 {
1029  bException = false;
1030  TypeClass eType = rValue.getValueType().getTypeClass();
1031 
1032  sal_uInt32 nRet = 0;
1033  if( eType == TypeClass_UNSIGNED_LONG )
1034  rValue >>= nRet;
1035  else
1036  {
1037  sal_Int32 nVal=0;
1038  bException = !(rValue >>= nVal);
1039  if( !bException )
1040  nRet = static_cast<sal_uInt32>(nVal);
1041  }
1042 
1043  return nRet;
1044 }
1045 
1046 static OUString lcl_CreateOutlineString( size_t nIndex,
1047  const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
1048 {
1049  OUStringBuffer sEntry;
1050  const SwTextNode * pTextNd = rOutlineNodes[ nIndex ]->GetTextNode();
1051  SwNumberTree::tNumberVector aNumVector = pTextNd->GetNumberVector();
1052  if( pOutlRule && pTextNd->GetNumRule())
1053  for( int nLevel = 0;
1054  nLevel <= pTextNd->GetActualListLevel();
1055  nLevel++ )
1056  {
1057  long nVal = aNumVector[nLevel];
1058  nVal ++;
1059  nVal -= pOutlRule->Get(nLevel).GetStart();
1060  sEntry.append(OUString::number( nVal ));
1061  sEntry.append(".");
1062  }
1063  sEntry.append( rOutlineNodes[ nIndex ]->
1064  GetTextNode()->GetExpandText(nullptr) );
1065  return sEntry.makeStringAndClear();
1066 }
1067 
1069 {
1070  SolarMutexGuard aGuard;
1071  if(!IsValid())
1072  throw DisposedException("", static_cast< XTextDocument* >(this));
1073 
1075  //if only a few properties are coming, then use the current settings
1077  if(pData)
1078  aData = *pData;
1079  for(const beans::PropertyValue& rProperty : aSettings)
1080  {
1081  OUString sName = rProperty.Name;
1082  const Any& rVal = rProperty.Value;
1083  bool bException;
1084  sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
1085  if( sName == "PageRows" )
1086  {
1087  if(!nVal || nVal > 0xff)
1088  throw RuntimeException("Invalid value");
1089  aData.SetRow(static_cast<sal_uInt8>(nVal));
1090  }
1091  else if(sName == "PageColumns")
1092  {
1093  if(!nVal || nVal > 0xff)
1094  throw RuntimeException("Invalid value");
1095  aData.SetCol(static_cast<sal_uInt8>(nVal));
1096  }
1097  else if(sName == "LeftMargin")
1098  {
1099  aData.SetLeftSpace(convertMm100ToTwip(nVal));
1100  }
1101  else if(sName == "RightMargin")
1102  {
1103  aData.SetRightSpace(convertMm100ToTwip(nVal));
1104  }
1105  else if(sName == "TopMargin")
1106  {
1107  aData.SetTopSpace(convertMm100ToTwip(nVal));
1108  }
1109  else if(sName == "BottomMargin")
1110  {
1111  aData.SetBottomSpace(convertMm100ToTwip(nVal));
1112  }
1113  else if(sName == "HoriMargin")
1114  {
1115  aData.SetHorzSpace(convertMm100ToTwip(nVal));
1116  }
1117  else if(sName == "VertMargin")
1118  {
1119  aData.SetVertSpace(convertMm100ToTwip(nVal));
1120  }
1121  else if(sName == "IsLandscape")
1122  {
1123  auto b = o3tl::tryAccess<bool>(rVal);
1124  bException = !b;
1125  if (b)
1126  {
1127  aData.SetLandscape(*b);
1128  }
1129  }
1130  else
1131  bException = true;
1132  if(bException)
1133  throw RuntimeException();
1134  }
1135  pDocShell->GetDoc()->SetPreviewPrtData(&aData);
1136 
1137 }
1138 
1140 {
1141  SolarMutexGuard aGuard;
1142  if(!IsValid())
1143  throw DisposedException("", static_cast< XTextDocument* >(this));
1144 
1146  SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SfxCallMode::SYNCHRON,
1147  pDocShell->GetDoc()->GetAttrPool());
1149 
1150  for ( const beans::PropertyValue &rProp : xOptions )
1151  {
1152  // get Property-Value from options
1153  Any aValue( rProp.Value );
1154 
1155  // FileName-Property?
1156  if ( rProp.Name == UNO_NAME_FILE_NAME )
1157  {
1158  OUString sFileURL;
1159  if ( rProp.Value >>= sFileURL )
1160  {
1161  // Convert the File URL into a system dependent path, as the SalPrinter expects
1162  OUString sSystemPath;
1163  FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
1164  aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
1165  }
1166  else if ( rProp.Value.getValueType() != cppu::UnoType<void>::get() )
1167  throw IllegalArgumentException();
1168  }
1169 
1170  // CopyCount-Property
1171  else if ( rProp.Name == UNO_NAME_COPY_COUNT )
1172  {
1173  sal_Int32 nCopies = 0;
1174  aValue >>= nCopies;
1175  aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, static_cast<sal_Int16>(nCopies) ) );
1176  }
1177 
1178  // Collate-Property
1179  else if ( rProp.Name == UNO_NAME_COLLATE )
1180  {
1181  auto b = o3tl::tryAccess<bool>(rProp.Value);
1182  if ( !b )
1183  throw IllegalArgumentException();
1184  aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *b ) );
1185 
1186  }
1187 
1188  // Sort-Property
1189  else if ( rProp.Name == UNO_NAME_SORT )
1190  {
1191  auto b = o3tl::tryAccess<bool>(rProp.Value);
1192  if ( !b )
1193  throw IllegalArgumentException();
1194 
1195  aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *b ) );
1196  }
1197 
1198  // Pages-Property
1199  else if ( rProp.Name == UNO_NAME_PAGES )
1200  {
1201  OUString sTmp;
1202  if ( !(rProp.Value >>= sTmp) )
1203  throw IllegalArgumentException();
1204 
1205  aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
1206 
1207  }
1208  }
1209 
1210  // #i117783#
1212  pFrame->GetViewShell()->ExecuteSlot(aReq);
1213  // Frame close
1214  pFrame->DoClose();
1215 
1216 }
1217 
1219 {
1220  SolarMutexGuard aGuard;
1221  if(!IsValid())
1222  throw DisposedException("", static_cast< XTextDocument* >(this));
1223  if(!mxXReferenceMarks.is())
1224  {
1226  }
1227  return mxXReferenceMarks;
1228 }
1229 
1230 Reference< XEnumerationAccess > SwXTextDocument::getTextFields()
1231 {
1232  SolarMutexGuard aGuard;
1233  if(!IsValid())
1234  throw DisposedException("", static_cast< XTextDocument* >(this));
1235  if(!mxXTextFieldTypes.is())
1236  {
1238  }
1239  return mxXTextFieldTypes;
1240 }
1241 
1243 {
1244  SolarMutexGuard aGuard;
1245  if(!IsValid())
1246  throw DisposedException("", static_cast< XTextDocument* >(this));
1247  if(!mxXTextFieldMasters.is())
1248  {
1250  }
1251  return mxXTextFieldMasters;
1252 }
1253 
1255 {
1256  SolarMutexGuard aGuard;
1257  if(!IsValid())
1258  throw DisposedException("", static_cast< XTextDocument* >(this));
1259  if(!mxXEmbeddedObjects.is())
1260  {
1262  }
1263  return mxXEmbeddedObjects;
1264 }
1265 
1267 {
1268  SolarMutexGuard aGuard;
1269  if(!IsValid())
1270  throw DisposedException("", static_cast< XTextDocument* >(this));
1271  if(!mxXBookmarks.is())
1272  {
1274  }
1275  return mxXBookmarks;
1276 }
1277 
1279 {
1280  SolarMutexGuard aGuard;
1281  if(!IsValid())
1282  throw DisposedException("", static_cast< XTextDocument* >(this));
1283  if(!mxXTextSections.is())
1284  {
1286  }
1287  return mxXTextSections;
1288 }
1289 
1291 {
1292  SolarMutexGuard aGuard;
1293  if(!IsValid())
1294  throw DisposedException("", static_cast< XTextDocument* >(this));
1295  if(!mxXTextTables.is())
1296  {
1298  }
1299  return mxXTextTables;
1300 }
1301 
1303 {
1304  SolarMutexGuard aGuard;
1305  if(!IsValid())
1306  throw DisposedException("", static_cast< XTextDocument* >(this));
1307  if(!mxXGraphicObjects.is())
1308  {
1310  }
1311  return mxXGraphicObjects;
1312 }
1313 
1315 {
1316  SolarMutexGuard aGuard;
1317  if(!IsValid())
1318  throw DisposedException("", static_cast< XTextDocument* >(this));
1319  if(!mxXTextFrames.is())
1320  {
1322  }
1323  return mxXTextFrames;
1324 }
1325 
1327 {
1328  SolarMutexGuard aGuard;
1329  if(!IsValid())
1330  throw DisposedException("", static_cast< XTextDocument* >(this));
1331  if(!mxXStyleFamilies.is())
1332  {
1334  }
1335  return mxXStyleFamilies;
1336 }
1337 
1338 uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
1339 {
1340  SolarMutexGuard aGuard;
1341  if(!IsValid())
1342  throw DisposedException("", static_cast< XTextDocument* >(this));
1343  if(!mxXAutoStyles.is())
1344  {
1346  }
1347  return mxXAutoStyles;
1348 
1349 }
1350 
1352 {
1353  SolarMutexGuard aGuard;
1354  if(!IsValid())
1355  throw DisposedException("", static_cast< XTextDocument* >(this));
1356  if(!mxXDrawPage.is())
1357  {
1360  // Create a Reference to trigger the complete initialization of the
1361  // object. Otherwise in some corner cases it would get initialized
1362  // at ::InitNewDoc -> which would get called during
1363  // close() or dispose() -> n#681746
1364  uno::Reference<lang::XComponent> xComp( mxXDrawPage, uno::UNO_QUERY );
1365  }
1366  return mxXDrawPage;
1367 }
1368 
1369 class SwDrawPagesObj : public cppu::WeakImplHelper<
1370  css::drawing::XDrawPages,
1371  css::lang::XServiceInfo>
1372 {
1373 private:
1374  css::uno::Reference< css::drawing::XDrawPageSupplier > m_xDoc;
1375 public:
1376  SwDrawPagesObj(const css::uno::Reference< css::drawing::XDrawPageSupplier >& rxDoc) : m_xDoc(rxDoc) {}
1377 
1378  // XDrawPages
1379  virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL
1380  insertNewByIndex(sal_Int32 /*nIndex*/) override { throw css::lang::NoSupportException(); }
1381 
1382  virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XDrawPage >& /*xPage*/) override
1383  {
1384  throw css::lang::NoSupportException();
1385  }
1386 
1387  // XIndexAccess
1388  virtual sal_Int32 SAL_CALL getCount() override { return 1; }
1389 
1390  virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
1391  {
1392  if (Index != 0)
1393  throw css::lang::IndexOutOfBoundsException("Writer documents have only one DrawPage!");
1394  return css::uno::Any(m_xDoc->getDrawPage());
1395  }
1396 
1397  // XElementAccess
1398  virtual css::uno::Type SAL_CALL getElementType() override
1399  {
1400  SolarMutexGuard aGuard;
1402  }
1403 
1404  virtual sal_Bool SAL_CALL hasElements() override { return true; }
1405 
1406  // XServiceInfo
1407  virtual OUString SAL_CALL getImplementationName() override
1408  {
1409  return "SwDrawPagesObj";
1410  }
1411 
1412  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override
1413  {
1414  return cppu::supportsService(this, ServiceName);
1415  }
1416 
1417  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1418  {
1419  return { "com.sun.star.drawing.DrawPages" };
1420  }
1421 };
1422 
1423 // XDrawPagesSupplier
1424 
1425 uno::Reference<drawing::XDrawPages> SAL_CALL SwXTextDocument::getDrawPages()
1426 {
1427  SolarMutexGuard aGuard;
1428  return new SwDrawPagesObj(this);
1429 }
1430 
1432 {
1433  bObjectValid = false;
1434  if(xNumFormatAgg.is())
1435  {
1436  const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
1437  Any aNumTunnel = xNumFormatAgg->queryAggregation(rTunnelType);
1438  SvNumberFormatsSupplierObj* pNumFormat = nullptr;
1439  Reference< XUnoTunnel > xNumTunnel;
1440  if(aNumTunnel >>= xNumTunnel)
1441  {
1442  pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1443  xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1444  pNumFormat->SetNumberFormatter(nullptr);
1445  }
1446  OSL_ENSURE(pNumFormat, "No number formatter available");
1447  }
1448  InitNewDoc();
1449  pDocShell = nullptr;
1450  lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
1451  m_pImpl->m_RefreshListeners.disposeAndClear(ev);
1452 }
1453 
1455 {
1456  if(pDocShell && pDocShell != pNewDocShell)
1457  Invalidate();
1458  pDocShell = pNewDocShell;
1459  bObjectValid = true;
1460 }
1461 
1463 {
1464  // first invalidate all collections, then delete references and Set to zero
1465  if(mxXTextTables.is())
1466  {
1467  XNameAccess* pTables = mxXTextTables.get();
1468  static_cast<SwXTextTables*>(pTables)->Invalidate();
1469  mxXTextTables.clear();
1470  }
1471 
1472  if(mxXTextFrames.is())
1473  {
1474  XNameAccess* pFrames = mxXTextFrames.get();
1475  static_cast<SwXTextFrames*>(pFrames)->Invalidate();
1476  mxXTextFrames.clear();
1477  }
1478 
1479  if(mxXGraphicObjects.is())
1480  {
1481  XNameAccess* pFrames = mxXGraphicObjects.get();
1482  static_cast<SwXTextGraphicObjects*>(pFrames)->Invalidate();
1483  mxXGraphicObjects.clear();
1484  }
1485 
1486  if(mxXEmbeddedObjects.is())
1487  {
1488  XNameAccess* pOLE = mxXEmbeddedObjects.get();
1489  static_cast<SwXTextEmbeddedObjects*>(pOLE)->Invalidate();
1490  mxXEmbeddedObjects.clear();
1491  }
1492 
1493  if(xBodyText.is())
1494  {
1495  xBodyText = nullptr;
1496  pBodyText = nullptr;
1497  }
1498 
1499  if(xNumFormatAgg.is())
1500  {
1501  const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
1502  Any aNumTunnel = xNumFormatAgg->queryAggregation(rTunnelType);
1503  SvNumberFormatsSupplierObj* pNumFormat = nullptr;
1504  Reference< XUnoTunnel > xNumTunnel;
1505  if(aNumTunnel >>= xNumTunnel)
1506  {
1507  pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1508  xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1509 
1510  }
1511  OSL_ENSURE(pNumFormat, "No number formatter available");
1512  if (pNumFormat)
1513  pNumFormat->SetNumberFormatter(nullptr);
1514  }
1515 
1516  if(mxXTextFieldTypes.is())
1517  {
1518  XEnumerationAccess* pT = mxXTextFieldTypes.get();
1519  static_cast<SwXTextFieldTypes*>(pT)->Invalidate();
1520  mxXTextFieldTypes.clear();
1521  }
1522 
1523  if(mxXTextFieldMasters.is())
1524  {
1525  XNameAccess* pT = mxXTextFieldMasters.get();
1526  static_cast<SwXTextFieldMasters*>(pT)->Invalidate();
1527  mxXTextFieldMasters.clear();
1528  }
1529 
1530  if(mxXTextSections.is())
1531  {
1532  XNameAccess* pSect = mxXTextSections.get();
1533  static_cast<SwXTextSections*>(pSect)->Invalidate();
1534  mxXTextSections.clear();
1535  }
1536 
1537  if(mxXDrawPage.is())
1538  {
1539  // #i91798#, #i91895#
1540  // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
1541  uno::Reference<lang::XComponent> xComp( mxXDrawPage, uno::UNO_QUERY );
1542  xComp->dispose();
1544  mxXDrawPage.clear();
1545  }
1546 
1547  if ( mxXNumberingRules.is() )
1548  {
1549  XIndexAccess* pNum = mxXNumberingRules.get();
1550  static_cast<SwXNumberingRulesCollection*>(pNum)->Invalidate();
1551  mxXNumberingRules.clear();
1552  }
1553 
1554  if(mxXFootnotes.is())
1555  {
1556  XIndexAccess* pFootnote = mxXFootnotes.get();
1557  static_cast<SwXFootnotes*>(pFootnote)->Invalidate();
1558  mxXFootnotes.clear();
1559  }
1560 
1561  if(mxXEndnotes.is())
1562  {
1563  XIndexAccess* pFootnote = mxXEndnotes.get();
1564  static_cast<SwXFootnotes*>(pFootnote)->Invalidate();
1565  mxXEndnotes.clear();
1566  }
1567 
1568  if(mxXDocumentIndexes.is())
1569  {
1570  XIndexAccess* pIdxs = mxXDocumentIndexes.get();
1571  static_cast<SwXDocumentIndexes*>(pIdxs)->Invalidate();
1572  mxXDocumentIndexes.clear();
1573  }
1574 
1575  if(mxXStyleFamilies.is())
1576  {
1577  XNameAccess* pStyles = mxXStyleFamilies.get();
1578  static_cast<SwXStyleFamilies*>(pStyles)->Invalidate();
1579  mxXStyleFamilies.clear();
1580  }
1581  if(mxXAutoStyles.is())
1582  {
1583  XNameAccess* pStyles = mxXAutoStyles.get();
1584  static_cast<SwXAutoStyles*>(pStyles)->Invalidate();
1585  mxXAutoStyles.clear();
1586  }
1587 
1588  if(mxXBookmarks.is())
1589  {
1590  XNameAccess* pBm = mxXBookmarks.get();
1591  static_cast<SwXBookmarks*>(pBm)->Invalidate();
1592  mxXBookmarks.clear();
1593  }
1594 
1595  if(mxXChapterNumbering.is())
1596  {
1597  XIndexReplace* pCh = mxXChapterNumbering.get();
1598  static_cast<SwXChapterNumbering*>(pCh)->Invalidate();
1599  mxXChapterNumbering.clear();
1600  }
1601 
1602  if(mxXFootnoteSettings.is())
1603  {
1604  XPropertySet* pFntSet = mxXFootnoteSettings.get();
1605  static_cast<SwXFootnoteProperties*>(pFntSet)->Invalidate();
1606  mxXFootnoteSettings.clear();
1607  }
1608 
1609  if(mxXEndnoteSettings.is())
1610  {
1611  XPropertySet* pEndSet = mxXEndnoteSettings.get();
1612  static_cast<SwXEndnoteProperties*>(pEndSet)->Invalidate();
1613  mxXEndnoteSettings.clear();
1614  }
1615 
1617  {
1619  static_cast<SwXLineNumberingProperties*>(pLine)->Invalidate();
1621  }
1622  if(mxXReferenceMarks.is())
1623  {
1624  XNameAccess* pMarks = mxXReferenceMarks.get();
1625  static_cast<SwXReferenceMarks*>(pMarks)->Invalidate();
1626  mxXReferenceMarks.clear();
1627  }
1628  if(mxLinkTargetSupplier.is())
1629  {
1630  XNameAccess* pAccess = mxLinkTargetSupplier.get();
1631  static_cast<SwXLinkTargetSupplier*>(pAccess)->Invalidate();
1632  mxLinkTargetSupplier.clear();
1633  }
1634  if(mxXRedlines.is())
1635  {
1636  XEnumerationAccess* pMarks = mxXRedlines.get();
1637  static_cast<SwXRedlines*>(pMarks)->Invalidate();
1638  mxXRedlines.clear();
1639  }
1640  if(mxPropertyHelper.is())
1641  {
1642  mxPropertyHelper->Invalidate();
1643  mxPropertyHelper.clear();
1644  }
1645 }
1646 
1647 css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
1648  OUString const & rServiceName,
1649  css::uno::Sequence<css::uno::Any> const * arguments)
1650 {
1651  SolarMutexGuard aGuard;
1652  if (!IsValid())
1653  throw DisposedException("", static_cast< XTextDocument* >(this));
1654 
1656  if (nType != SwServiceType::Invalid)
1657  {
1659  }
1660  if (rServiceName == "com.sun.star.drawing.DashTable")
1661  {
1663  }
1664  if (rServiceName == "com.sun.star.drawing.GradientTable")
1665  {
1667  }
1668  if (rServiceName == "com.sun.star.drawing.HatchTable")
1669  {
1671  }
1672  if (rServiceName == "com.sun.star.drawing.BitmapTable")
1673  {
1675  }
1676  if (rServiceName == "com.sun.star.drawing.TransparencyGradientTable")
1677  {
1679  }
1680  if (rServiceName == "com.sun.star.drawing.MarkerTable")
1681  {
1683  }
1684  if (rServiceName == "com.sun.star.drawing.Defaults")
1685  {
1687  }
1688  if (rServiceName == "com.sun.star.document.Settings")
1689  {
1690  return Reference<XInterface>(*new SwXDocumentSettings(this));
1691  }
1692  if (rServiceName == "com.sun.star.document.ImportEmbeddedObjectResolver")
1693  {
1694  return static_cast<cppu::OWeakObject *>(
1696  *pDocShell, SvXMLEmbeddedObjectHelperMode::Read));
1697  }
1698  if (rServiceName == "com.sun.star.text.DocumentSettings")
1699  {
1700  return Reference<XInterface>(*new SwXDocumentSettings(this));
1701  }
1702  if (rServiceName == "com.sun.star.chart2.data.DataProvider")
1703  {
1704  return Reference<XInterface>(
1705  dynamic_cast<chart2::data::XDataProvider *>(
1707  GetChartDataProvider()));
1708  }
1709  if (!rServiceName.startsWith("com.sun.star.")
1710  || rServiceName.endsWith(".OLE2Shape"))
1711  {
1712  // We do not want to insert OLE2 Shapes (e.g.,
1713  // "com.sun.star.drawing.OLE2Shape", ...) like this (by creating them
1714  // with the documents factory and adding the shapes to the draw page);
1715  // for inserting OLE objects the proper way is to use
1716  // "com.sun.star.text.TextEmbeddedObject":
1717  throw ServiceNotRegisteredException();
1718  }
1719  // The XML import is allowed to create instances of
1720  // "com.sun.star.drawing.OLE2Shape"; thus, a temporary service name is
1721  // introduced to make this possible:
1722  OUString aTmpServiceName(rServiceName);
1723  if (rServiceName == "com.sun.star.drawing.temporaryForXMLImportOLE2Shape")
1724  {
1725  aTmpServiceName = "com.sun.star.drawing.OLE2Shape";
1726  }
1727  Reference<XInterface> xTmp(
1728  arguments == nullptr
1729  ? SvxFmMSFactory::createInstance(aTmpServiceName)
1731  aTmpServiceName, *arguments));
1732  if (rServiceName == "com.sun.star.drawing.GroupShape"
1733  || rServiceName == "com.sun.star.drawing.Shape3DSceneObject")
1734  {
1735  return *new SwXGroupShape(xTmp, pDocShell->GetDoc());
1736  }
1737  if (rServiceName.startsWith("com.sun.star.drawing."))
1738  {
1739  return *new SwXShape(xTmp, pDocShell->GetDoc());
1740  }
1741  return xTmp;
1742 }
1743 
1745 {
1746  return create(rServiceName, nullptr);
1747 }
1748 
1750  const OUString& ServiceSpecifier,
1751  const Sequence< Any >& Arguments)
1752 {
1753  return create(ServiceSpecifier, &Arguments);
1754 }
1755 
1757 {
1758  static Sequence< OUString > aServices;
1759  if ( !aServices.hasElements() )
1760  {
1762  auto i = comphelper::findValue(aRet, "com.sun.star.drawing.OLE2Shape");
1763  if (i != -1)
1764  {
1765  auto nLength = aRet.getLength();
1766  aRet[i] = aRet[nLength - 1];
1767  aRet.realloc( nLength - 1 );
1768  }
1770  aServices = comphelper::concatSequences(aRet, aOwn);
1771  }
1772 
1773  return aServices;
1774 }
1775 
1777 {
1778  return "SwXTextDocument";
1779  /* // Matching the .component information:
1780  return dynamic_cast<SwGlobalDocShell*>( pDocShell ) != nullptr
1781  ? OUString("com.sun.star.comp.Writer.GlobalDocument")
1782  : dynamic_cast<SwWebDocShell*>( pDocShell ) != nullptr
1783  ? OUString("com.sun.star.comp.Writer.WebDocument")
1784  : OUString("com.sun.star.comp.Writer.TextDocument");
1785  */
1786 }
1787 
1788 sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName)
1789 {
1790  return cppu::supportsService(this, rServiceName);
1791 }
1792 
1794 {
1795  bool bWebDoc = (dynamic_cast<SwWebDocShell*>( pDocShell) != nullptr );
1796  bool bGlobalDoc = (dynamic_cast<SwGlobalDocShell*>( pDocShell) != nullptr );
1797  bool bTextDoc = (!bWebDoc && !bGlobalDoc);
1798 
1799  Sequence< OUString > aRet (3);
1800  OUString* pArray = aRet.getArray();
1801 
1802  pArray[0] = "com.sun.star.document.OfficeDocument";
1803  pArray[1] = "com.sun.star.text.GenericTextDocument";
1804 
1805  if (bTextDoc)
1806  pArray[2] = "com.sun.star.text.TextDocument";
1807  else if (bWebDoc)
1808  pArray[2] = "com.sun.star.text.WebDocument";
1809  else if (bGlobalDoc)
1810  pArray[2] = "com.sun.star.text.GlobalDocument";
1811 
1812  return aRet;
1813 }
1814 
1815 Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes()
1816 {
1817  SolarMutexGuard aGuard;
1818  if(!IsValid())
1819  throw DisposedException("", static_cast< XTextDocument* >(this));
1820 
1821  if(!mxXDocumentIndexes.is())
1822  {
1824  }
1825  return mxXDocumentIndexes;
1826 }
1827 
1828 Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo()
1829 {
1830  static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
1831  return xRet;
1832 }
1833 
1834 void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& aValue)
1835 {
1836  SolarMutexGuard aGuard;
1837  if(!IsValid())
1838  throw DisposedException("", static_cast< XTextDocument* >(this));
1839 
1840  const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
1841 
1842  if(!pEntry)
1843  throw UnknownPropertyException(rPropertyName);
1844  if(pEntry->nFlags & PropertyAttribute::READONLY)
1845  throw PropertyVetoException();
1846  switch(pEntry->nWID)
1847  {
1848  case WID_DOC_CHAR_COUNT :
1849  case WID_DOC_PARA_COUNT :
1850  case WID_DOC_WORD_COUNT :
1851  throw RuntimeException(
1852  "bad WID",
1853  static_cast< cppu::OWeakObject * >(
1854  static_cast< SwXTextDocumentBaseClass * >(this)));
1855  case WID_DOC_WORD_SEPARATOR :
1856  {
1857  OUString sDelim;
1858  aValue >>= sDelim;
1859  SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim);
1860  }
1861  break;
1863  case WID_DOC_CHANGES_SHOW:
1864  {
1865  bool bSet = *o3tl::doAccess<bool>(aValue);
1867  if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
1868  {
1870  if( !bSet )
1872  }
1873  else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
1874  {
1875  eMode = bSet ? eMode|RedlineFlags::On : eMode&~RedlineFlags::On;
1876  }
1878  }
1879  break;
1881  {
1882  Sequence <sal_Int8> aNew;
1883  if(aValue >>= aNew)
1884  {
1885  SwDoc* pDoc = pDocShell->GetDoc();
1887  if(aNew.hasElements())
1888  {
1890  eMode |= RedlineFlags::On;
1891  pDoc->getIDocumentRedlineAccess().SetRedlineFlags( eMode );
1892  }
1893  }
1894  }
1895  break;
1896  case WID_DOC_AUTO_MARK_URL :
1897  {
1898  OUString sURL;
1899  aValue >>= sURL;
1901  }
1902  break;
1903  case WID_DOC_HIDE_TIPS :
1904  SW_MOD()->GetModuleConfig()->SetHideFieldTips(*o3tl::doAccess<bool>(aValue));
1905  break;
1907  {
1909  eRedMode = eRedMode & (~RedlineFlags::ShowMask);
1910  sal_Int16 nSet = 0;
1911  aValue >>= nSet;
1912  switch(nSet)
1913  {
1914  case RedlineDisplayType::NONE: break;
1915  case RedlineDisplayType::INSERTED: eRedMode |= RedlineFlags::ShowInsert; break;
1916  case RedlineDisplayType::REMOVED: eRedMode |= RedlineFlags::ShowDelete; break;
1917  case RedlineDisplayType::
1918  INSERTED_AND_REMOVED: eRedMode |= RedlineFlags::ShowInsert|RedlineFlags::ShowDelete;
1919  break;
1920  default: throw IllegalArgumentException();
1921  }
1923  }
1924  break;
1926  {
1927  sal_Int16 nYear = 0;
1928  aValue >>= nYear;
1929  SfxRequest aRequest ( SID_ATTR_YEAR2000, SfxCallMode::SLOT, pDocShell->GetDoc()->GetAttrPool());
1930  aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
1931  pDocShell->Execute ( aRequest );
1932  }
1933  break;
1935  {
1936  SwDrawModel * pDrawDoc;
1937  bool bAuto = *o3tl::doAccess<bool>(aValue);
1938 
1939  if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) )
1940  pDrawDoc->SetAutoControlFocus( bAuto );
1941  else if (bAuto)
1942  {
1943  // if setting to true, and we don't have an
1944  // SdrModel, then we are changing the default and
1945  // must thus create an SdrModel, if we don't have an
1946  // SdrModel and we are leaving the default at false,
1947  // we don't need to make an SdrModel and can do nothing
1948  // #i52858# - method name changed
1950  pDrawDoc->SetAutoControlFocus ( bAuto );
1951  }
1952  }
1953  break;
1955  {
1956  SwDrawModel * pDrawDoc;
1957  bool bMode = *o3tl::doAccess<bool>(aValue);
1958 
1959  if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) )
1960  pDrawDoc->SetOpenInDesignMode( bMode );
1961  else if (!bMode)
1962  {
1963  // if setting to false, and we don't have an
1964  // SdrModel, then we are changing the default and
1965  // must thus create an SdrModel, if we don't have an
1966  // SdrModel and we are leaving the default at true,
1967  // we don't need to make an SdrModel and can do
1968  // nothing
1969  // #i52858# - method name changed
1971  pDrawDoc->SetOpenInDesignMode ( bMode );
1972  }
1973  }
1974  break;
1975  // #i42634# New property to set the bInReading
1976  // flag at the document, used during binary import
1977  case WID_DOC_LOCK_UPDATES :
1978  {
1979  SwDoc* pDoc = pDocShell->GetDoc();
1980  bool bBool (false);
1981  if( aValue >>= bBool )
1982  pDoc->SetInReading( bBool );
1983  }
1984  break;
1985  case WID_DOC_BUILDID:
1986  aValue >>= maBuildId;
1987  break;
1988 
1990  {
1991  bool bDefaultPageMode( false );
1992  aValue >>= bDefaultPageMode;
1993  pDocShell->GetDoc()->SetDefaultPageMode( bDefaultPageMode );
1994  }
1995  break;
1997  setGrabBagItem(aValue);
1998  break;
1999 
2000  default:
2001  {
2002  const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
2003  std::unique_ptr<SfxPoolItem> pNewItem(rItem.Clone());
2004  pNewItem->PutValue(aValue, pEntry->nMemberId);
2005  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 = 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 <<= 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(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 = pDocShell->GetDoc();
2065  aAny <<= pDoc->getIDocumentRedlineAccess().GetRedlinePassword();
2066  }
2067  break;
2068  case WID_DOC_AUTO_MARK_URL :
2069  aAny <<= 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 > (pDocShell->GetDoc()->GetNumberFormatter ()->GetYear2000());
2098  }
2099  break;
2101  {
2102  SwDrawModel * pDrawDoc;
2103  bool bAuto;
2104  if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) )
2105  bAuto = pDrawDoc->GetAutoControlFocus();
2106  else
2107  bAuto = false;
2108  aAny <<= bAuto;
2109  }
2110  break;
2112  {
2113  SwDrawModel * pDrawDoc;
2114  bool bMode;
2115  if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) )
2116  bMode = pDrawDoc->GetOpenInDesignMode();
2117  else
2118  bMode = true;
2119  aAny <<= bMode;
2120  }
2121  break;
2123  aAny <<= pDocShell->GetBasicContainer();
2124  break;
2126  aAny <<= 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 <<= 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 = 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 = 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 = 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 = 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 = 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 = 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 sal_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 sal_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 == pDocShell->GetModel())
2394  pDoc = 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  pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );
2591 
2592 
2593  // #122919# Force field update before PDF export, but after layout init (tdf#121962)
2594  bool bStateChanged = false;
2595  // check configuration: shall update of printing information in DocInfo set the document to "modified"?
2597  {
2598  pRenderDocShell->EnableSetModified( false );
2599  bStateChanged = true;
2600  }
2601  pViewShell->SwViewShell::UpdateFields(true);
2602  if( bStateChanged )
2603  pRenderDocShell->EnableSetModified();
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 PageSisze 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 = 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( 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, 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  const bool bHasPDFExtOutDevData = lcl_SeqHasProperty( rxOptions, "HasPDFExtOutDevData" );
2936  const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ) || bHasPDFExtOutDevData;
2937  bool bIsSwSrcView = false;
2938  SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2939 
2940  OSL_ENSURE( m_pRenderData, "data should have been created already in getRendererCount..." );
2941  OSL_ENSURE( m_pPrintUIOptions, "data should have been created already in getRendererCount..." );
2942  if (!bIsSwSrcView && !m_pRenderData)
2943  m_pRenderData.reset(new SwRenderData);
2944  if (!m_pPrintUIOptions)
2946  m_pPrintUIOptions->processProperties( rxOptions );
2947  const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect" );
2948  const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage" );
2949 
2950  SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2951  OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2952  if (pDoc && pView)
2953  {
2954  sal_Int32 nMaxRenderer = 0;
2955  if (!bIsSwSrcView)
2956  {
2957  OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
2958  nMaxRenderer = bPrintProspect?
2959  m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
2960  m_pRenderData->GetPagesToPrint().size() - 1;
2961  }
2962  // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
2963  // we obmit checking of the upper bound in this case.
2964  if (bIsSwSrcView || nRenderer <= nMaxRenderer)
2965  {
2966  if (bIsSwSrcView)
2967  {
2968  SwSrcView& rSwSrcView = dynamic_cast<SwSrcView&>(*pView);
2970  rSwSrcView.PrintSource(pOutDev, nRenderer + 1, false);
2971  }
2972  else
2973  {
2974  // the view shell should be SwView for documents PDF export
2975  // or SwPagePreview for PDF export of the page preview
2976  SwViewShell* pVwSh = nullptr;
2977  // TODO/mba: we really need a generic way to get the SwViewShell!
2978  const SwView* pSwView = dynamic_cast<const SwView*>(pView);
2979  if (pSwView)
2980  pVwSh = pSwView->GetWrtShellPtr();
2981  else
2982  pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell();
2983 
2984  // get output device to use
2986 
2987  if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
2988  {
2989  const OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange" );
2990  const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage" );
2991  bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
2992 
2993  OSL_ENSURE((pSwView && m_pRenderData->IsViewOptionAdjust())
2994  || (!pSwView && !m_pRenderData->IsViewOptionAdjust()),
2995  "SwView / SwViewOptionAdjust_Impl availability mismatch" );
2996 
2997  // since printing now also use the API for PDF export this option
2998  // should be set for printing as well ...
2999  pVwSh->SetPDFExportOption( true );
3000 
3001  // #i12836# enhanced pdf export
3002 
3003  // First, we have to export hyperlinks, notes, and outline to pdf.
3004  // During this process, additional information required for tagging
3005  // the pdf file are collected, which are evaulated during painting.
3006 
3007  SwWrtShell* pWrtShell = pSwView ? pSwView->GetWrtShellPtr() : nullptr;
3008 
3009  SwPrintData const& rSwPrtOptions =
3010  *m_pRenderData->GetSwPrtOptions();
3011 
3012  if (bIsPDFExport && (bFirstPage || bHasPDFExtOutDevData) && pWrtShell)
3013  {
3014  SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, false, rSwPrtOptions );
3015  }
3016 
3017  if (bPrintProspect)
3018  pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer );
3019  else // normal printing and PDF export
3020  pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer, bIsPDFExport );
3021 
3022  // #i35176#
3023 
3024  // After printing the last page, we take care for the links coming
3025  // from the EditEngine. The links are generated during the painting
3026  // process, but the destinations are still missing.
3027 
3028  if (bIsPDFExport && bLastPage && pWrtShell)
3029  {
3030  SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, true, rSwPrtOptions );
3031  }
3032 
3033  pVwSh->SetPDFExportOption( false );
3034 
3035  // last page to be rendered? (not necessarily the last page of the document)
3036  // -> do clean-up of data
3037  if (bLastPage)
3038  {
3039  // #i96167# haggai: delete ViewOptionsAdjust here because it makes use
3040  // of the shell, which might get destroyed in lcl_DisposeView!
3041  if (m_pRenderData->IsViewOptionAdjust())
3042  m_pRenderData->ViewOptionAdjustStop();
3043 
3044  if (m_pRenderData->HasPostItData())
3045  m_pRenderData->DeletePostItData();
3046  if (m_pHiddenViewFrame)
3047  {
3049  m_pHiddenViewFrame = nullptr;
3050 
3051  // prevent crash described in #i108805
3052  SwDocShell *pRenderDocShell = pDoc->GetDocShell();
3053  SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet();
3054  pSet->Put( SfxBoolItem( SID_HIDDEN, false ) );
3055 
3056  }
3057  }
3058  }
3059  }
3060  }
3061  }
3062  if( bLastPage )
3063  {
3064  m_pRenderData.reset();
3065  m_pPrintUIOptions.reset();
3066  }
3067 }
3068 
3069 // xforms::XFormsSupplier
3071 {
3072  SolarMutexGuard aGuard;
3073  if ( !pDocShell )
3074  throw DisposedException( OUString(), static_cast< XTextDocument* >( this ) );
3075  SwDoc* pDoc = pDocShell->GetDoc();
3076  return pDoc->getXForms();
3077 }
3078 
3079 uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
3080 {
3081  SolarMutexGuard aGuard;
3082  if (!IsValid())
3083  {
3084  throw DisposedException("SwXTextDocument not valid",
3085  static_cast<XTextDocument*>(this));
3086  }
3087 
3089  *pDocShell->GetDoc(), nTextMarkupType, bAutomatic);
3090 }
3091 
3092 uno::Reference< util::XCloneable > SwXTextDocument::createClone( )
3093 {
3094  SolarMutexGuard aGuard;
3095  if(!IsValid())
3096  throw DisposedException("", static_cast< XTextDocument* >(this));
3097 
3098  // create a new document - hidden - copy the storage and return it
3099  // SfxObjectShellRef is used here, since the model should control object lifetime after creation
3100  // and thus SfxObjectShellLock is not allowed here
3101  // the model holds reference to the shell, so the shell will not destructed at the end of method
3102  SfxObjectShellRef pShell = pDocShell->GetDoc()->CreateCopy(false, false);
3103  uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
3104  uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( );
3105  uno::Sequence< beans::PropertyValue > aTempMediaDescriptor;
3106  storeToStorage( xNewStorage, aTempMediaDescriptor );
3107  uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY );
3108  xStorageDoc->loadFromStorage( xNewStorage, aTempMediaDescriptor );
3109  return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
3110 }
3111 
3112 void SwXTextDocument::addPasteEventListener(const uno::Reference<text::XPasteListener>& xListener)
3113 {
3114  SolarMutexGuard aGuard;
3115 
3116  if (IsValid() && xListener.is())
3118 }
3119 
3121  const uno::Reference<text::XPasteListener>& xListener)
3122 {
3123  SolarMutexGuard aGuard;
3124 
3125  if (IsValid() && xListener.is())
3127 }
3128 
3130  int nOutputWidth, int nOutputHeight,
3131  int nTilePosX, int nTilePosY,
3132  long nTileWidth, long nTileHeight )
3133 {
3134  SwViewShell* pViewShell = pDocShell->GetWrtShell();
3135  pViewShell->PaintTile(rDevice, nOutputWidth, nOutputHeight,
3136  nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3137 
3138  LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
3139  nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3140 }
3141 
3143 {
3144  SwViewShell* pViewShell = pDocShell->GetWrtShell();
3145  Size aDocSize = pViewShell->GetDocSize();
3146 
3147  return Size(aDocSize.Width() + 2 * DOCUMENTBORDER,
3148  aDocSize.Height() + 2 * DOCUMENTBORDER);
3149 }
3150 
3152 {
3153  SolarMutexGuard aGuard;
3154 
3155  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3156  if (!pWrtShell)
3157  return;
3158 
3159  pWrtShell->GotoPage(nPart + 1, true);
3160 }
3161 
3163 {
3164  SolarMutexGuard aGuard;
3165 
3166  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3167  if (!pWrtShell)
3168  return 0;
3169 
3170  return pWrtShell->GetPageCnt();
3171 }
3172 
3174 {
3175  SolarMutexGuard aGuard;
3176 
3177  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3178  if (!pWrtShell)
3179  return OUString();
3180 
3181  return pWrtShell->getPageRectangles();
3182 }
3183 
3184 void SwXTextDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
3185 {
3186  SolarMutexGuard aGuard;
3187 
3188  pDocShell->GetView()->GetEditWin().SetClipboard(xClipboard);
3189 }
3190 
3192 {
3193  SolarMutexGuard aGuard;
3194 
3195  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3196  if (!pWrtShell)
3197  return false;
3198 
3200  if (SdrView* pSdrView = pWrtShell->GetDrawView())
3201  {
3202  if (pSdrView->GetTextEditObject())
3203  // Editing shape text
3204  return EditEngine::HasValidData(aDataHelper.GetTransferable());
3205  }
3206 
3207  return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper);
3208 }
3209 
3211 {
3212  if (SwView* pView = pDocShell->GetView())
3213  {
3214  // set the PgUp/PgDown offset
3215  pView->ForcePageUpDownOffset(2 * rRectangle.GetHeight() / 3);
3216  }
3217 
3218  if (SwViewShell* pViewShell = pDocShell->GetWrtShell())
3219  {
3220  pViewShell->setLOKVisibleArea(rRectangle);
3221  }
3222 }
3223 
3224 void SwXTextDocument::setClientZoom(int nTilePixelWidth_, int /*nTilePixelHeight_*/,
3225  int nTileTwipWidth_, int /*nTileTwipHeight_*/)
3226 {
3227  // Here we set the zoom value as it has been set by the user in the client.
3228  // This value is used in postMouseEvent and setGraphicSelection methods
3229  // for in place chart editing. We assume that x and y scale is roughly
3230  // the same.
3231  // Indeed we could set mnTilePixelWidth, mnTilePixelHeight, mnTileTwipWidth,
3232  // mnTileTwipHeight data members of this class but they are not very useful
3233  // since we need to be able to retrieve the zoom value for each view shell.
3234  SfxInPlaceClient* pIPClient = pDocShell->GetView()->GetIPClient();
3235  if (pIPClient)
3236  {
3237  SwViewShell* pWrtViewShell = pDocShell->GetWrtShell();
3238  double fScale = nTilePixelWidth_ * TWIPS_PER_PIXEL / (nTileTwipWidth_ * 1.0);
3239  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3240  if (aOption.GetZoom() != fScale * 100)
3241  {
3242  aOption.SetZoom(fScale * 100);
3243  pWrtViewShell->ApplyViewOptions(aOption);
3244 
3245  // Changing the zoom value doesn't always trigger the updating of
3246  // the client ole object area, so we call it directly.
3247  pIPClient->VisAreaChanged();
3248  }
3249  }
3250 }
3251 
3253 {
3254  SolarMutexGuard aGuard;
3255 
3256  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3257  if (!pWrtShell)
3258  return PointerStyle::Arrow;
3259 
3260  return pWrtShell->GetView().GetEditWin().GetPointer();
3261 }
3262 
3264 {
3265  boost::property_tree::ptree aTrackedChanges;
3266 
3267  // Disable since usability is very low beyond some small number of changes.
3268  static bool bDisableRedlineComments = getenv("DISABLE_REDLINE") != nullptr;
3269  if (!bDisableRedlineComments)
3270  {
3271  const SwRedlineTable& rRedlineTable
3273  for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
3274  {
3275  boost::property_tree::ptree aTrackedChange;
3276  aTrackedChange.put("index", rRedlineTable[i]->GetId());
3277  aTrackedChange.put("author", rRedlineTable[i]->GetAuthorString(1).toUtf8().getStr());
3278  aTrackedChange.put("type", SwRedlineTypeToOUString(
3279  rRedlineTable[i]->GetRedlineData().GetType())
3280  .toUtf8()
3281  .getStr());
3282  aTrackedChange.put("comment",
3283  rRedlineTable[i]->GetRedlineData().GetComment().toUtf8().getStr());
3284  aTrackedChange.put("description", rRedlineTable[i]->GetDescr().toUtf8().getStr());
3285  OUString sDateTime = utl::toISO8601(
3286  rRedlineTable[i]->GetRedlineData().GetTimeStamp().GetUNODateTime());
3287  aTrackedChange.put("dateTime", sDateTime.toUtf8().getStr());
3288 
3289  SwContentNode* pContentNd = rRedlineTable[i]->GetContentNode();
3290  SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
3291  if (pView && pContentNd)
3292  {
3293  SwShellCursor aCursor(pView->GetWrtShell(), *(rRedlineTable[i]->Start()));
3294  aCursor.SetMark();
3295  aCursor.GetMark()->nNode = *pContentNd;
3296  aCursor.GetMark()->nContent.Assign(pContentNd,
3297  rRedlineTable[i]->End()->nContent.GetIndex());
3298 
3299  aCursor.FillRects();
3300 
3301  SwRects* pRects(&aCursor);
3302  std::vector<OString> aRects;
3303  for (const SwRect& rNextRect : *pRects)
3304  aRects.push_back(rNextRect.SVRect().toString());
3305 
3306  const OString sRects = comphelper::string::join("; ", aRects);
3307  aTrackedChange.put("textRange", sRects.getStr());
3308  }
3309 
3310  aTrackedChanges.push_back(std::make_pair("", aTrackedChange));
3311  }
3312  }
3313 
3314  boost::property_tree::ptree aTree;
3315  aTree.add_child("redlines", aTrackedChanges);
3316  std::stringstream aStream;
3317  boost::property_tree::write_json(aStream, aTree);
3318 
3319  return OUString::fromUtf8(aStream.str().c_str());
3320 }
3321 
3323 {
3324  return SW_MOD()->GetRedlineAuthorInfo();
3325 }
3326 
3328 {
3329  SwView* pView = pDocShell->GetView();
3330  return OUString::fromUtf8(dynamic_cast<SwCommentRuler&>(pView->GetHRuler()).CreateJsonNotification().c_str());
3331 }
3332 
3334 {
3335  SolarMutexGuard aGuard;
3336  boost::property_tree::ptree aAnnotations;
3337  for (auto const& sidebarItem : *pDocShell->GetView()->GetPostItMgr())
3338  {
3339  sw::annotation::SwAnnotationWin* pWin = sidebarItem->pPostIt.get();
3340 
3341  const SwPostItField* pField = pWin->GetPostItField();
3342  const SwRect& aRect = pWin->GetAnchorRect();
3343  tools::Rectangle aSVRect(aRect.Pos().getX(),
3344  aRect.Pos().getY(),
3345  aRect.Pos().getX() + aRect.SSize().Width(),
3346  aRect.Pos().getY() + aRect.SSize().Height());
3347 
3348  if (!sidebarItem->maLayoutInfo.mPositionFromCommentAnchor)
3349  {
3350  // Comments on frames: anchor position is the corner position, not the whole frame.
3351  aSVRect.SetSize(Size(0, 0));
3352  }
3353 
3354  std::vector<OString> aRects;
3355  for (const basegfx::B2DRange& aRange : pWin->GetAnnotationTextRanges())
3356  {
3357  const SwRect rect(aRange.getMinX(), aRange.getMinY(), aRange.getWidth(), aRange.getHeight());
3358  aRects.push_back(rect.SVRect().toString());
3359  }
3360  const OString sRects = comphelper::string::join("; ", aRects);
3361 
3362  boost::property_tree::ptree aAnnotation;
3363  aAnnotation.put("id", pField->GetPostItId());
3364  aAnnotation.put("parent", pWin->CalcParent());
3365  aAnnotation.put("author", pField->GetPar1().toUtf8().getStr());
3366  aAnnotation.put("text", pField->GetPar2().toUtf8().getStr());
3367  aAnnotation.put("resolved", pField->GetResolved() ? "true" : "false");
3368  aAnnotation.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime()));
3369  aAnnotation.put("anchorPos", aSVRect.toString());
3370  aAnnotation.put("textRange", sRects.getStr());
3371 
3372  aAnnotations.push_back(std::make_pair("", aAnnotation));
3373  }
3374 
3375  boost::property_tree::ptree aTree;
3376  aTree.add_child("comments", aAnnotations);
3377  std::stringstream aStream;
3378  boost::property_tree::write_json(aStream, aTree);
3379 
3380  return OUString::fromUtf8(aStream.str().c_str());
3381 }
3382 
3384 {
3385  SolarMutexGuard aGuard;
3386 
3387  SwView* pView = pDocShell->GetView();
3388  if (!pView)
3389  return 0;
3390 
3391  return pView->getPart();
3392 }
3393 
3394 OUString SwXTextDocument::getPartName(int nPart)
3395 {
3396  SolarMutexGuard aGuard;
3397 
3398  return SwResId(STR_PAGE) + OUString::number(nPart + 1);
3399 }
3400 
3401 OUString SwXTextDocument::getPartHash(int nPart)
3402 {
3403  SolarMutexGuard aGuard;
3404  OUString sPart(SwResId(STR_PAGE) + OUString::number(nPart + 1));
3405 
3406  return OUString::number(sPart.hashCode());
3407 }
3408 
3410 {
3411  SolarMutexGuard aGuard;
3412  VclPtr<vcl::Window> pWindow;
3413  SwView* pView = pDocShell->GetView();
3414  if (pView)
3415  pWindow = &(pView->GetEditWin());
3416 
3417  LokChartHelper aChartHelper(pView);
3418  VclPtr<vcl::Window> pChartWindow = aChartHelper.GetWindow();
3419  if (pChartWindow)
3420  pWindow = pChartWindow;
3421 
3422  return pWindow;
3423 }
3424 
3425 void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
3426 {
3427  SolarMutexGuard aGuard;
3428 
3429  SwViewShell* pViewShell = pDocShell->GetWrtShell();
3430 
3431  SwView* pView = pDocShell->GetView();
3432  if (!pView)
3433  return;
3434 
3435  pView->SetViewLayout(1/*nColumns*/, false/*bBookMode*/, true);
3436 
3437  // Tiled rendering defaults.
3438  SwViewOption aViewOption(*pViewShell->GetViewOptions());
3439  aViewOption.SetHardBlank(false);
3440  for (const beans::PropertyValue& rValue : rArguments)
3441  {
3442  if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has<bool>())
3443  aViewOption.SetHideWhitespaceMode(rValue.Value.get<bool>());
3444  else if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>())
3445  SwViewOption::SetAppearanceFlag(ViewOptFlags::Shadow , rValue.Value.get<bool>());
3446  else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
3447  {
3448  // Store the author name in the view.
3449  pView->SetRedlineAuthor(rValue.Value.get<OUString>());
3450  // Let the actual author name pick up the value from the current
3451  // view, which would normally happen only during the next view
3452  // switch.
3453  pDocShell->SetView(pView);
3454  }
3455  }
3456 
3457  // Set the initial zoom value to 1; usually it is set in setClientZoom and
3458  // SwViewShell::PaintTile; zoom value is used for chart in place
3459  // editing, see postMouseEvent and setGraphicSelection methods.
3460  aViewOption.SetZoom(1 * 100);
3461 
3462  aViewOption.SetPostIts(comphelper::LibreOfficeKit::isTiledAnnotations());
3463  pViewShell->ApplyViewOptions(aViewOption);
3464 
3465  // position the pages again after setting view options. Eg: if postit
3466  // rendering is false, then there would be no sidebar, so width of the
3467  // document needs to be adjusted
3468  pViewShell->GetLayout()->CheckViewLayout( pViewShell->GetViewOptions(), nullptr );
3469 
3470  // Disable map mode, so that it's possible to send mouse event coordinates
3471  // directly in twips.
3472  SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
3473  rEditWin.EnableMapMode(false);
3474 
3475  // when the "This document may contain formatting or content that cannot
3476  // be saved..." dialog appears, it is auto-cancelled with tiled rendering,
3477  // causing 'Save' being disabled; so let's always save to the original
3478  // format
3480 
3481  // disable word auto-completion suggestions, the tooltips are not visible,
3482  // and the editeng-like auto-completion is annoying
3484 
3485  // don't change the whitespace at the beginning of paragraphs, this is
3486  // annoying when taking minutes without further formatting
3488 }
3489 
3490 void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
3491 {
3492  SolarMutexGuard aGuard;
3493  SfxLokHelper::postKeyEventAsync(getDocWindow(), nType, nCharCode, nKeyCode);
3494 }
3495 
3496 void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
3497 {
3498  SolarMutexGuard aGuard;
3499 
3500  SwViewShell* pWrtViewShell = pDocShell->GetWrtShell();
3501  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3502  double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0);
3503 
3504  // check if the user hit a chart which is being edited by this view
3505  SfxViewShell* pViewShell = pDocShell->GetView();
3506  LokChartHelper aChartHelper(pViewShell);
3507  if (aChartHelper.postMouseEvent(nType, nX, nY,
3508  nCount, nButtons, nModifier,
3509  fScale, fScale))
3510  return;
3511 
3512  // check if the user hit a chart which is being edited by someone else
3513  // and, if so, skip current mouse event
3514  if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
3515  {
3516  if (LokChartHelper::HitAny(Point(nX, nY)))
3517  return;
3518  }
3519 
3520  SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
3521  SfxLokHelper::postMouseEventAsync(&rEditWin, nType,
3522  Point(nX, nY), nCount,
3523  MouseEventModifiers::SIMPLECLICK,
3524  nButtons, nModifier);
3525 }
3526 
3527 void SwXTextDocument::setTextSelection(int nType, int nX, int nY)
3528 {
3529  SolarMutexGuard aGuard;
3530 
3531  SfxViewShell* pViewShell = pDocShell->GetView();
3532  LokChartHelper aChartHelper(pViewShell);
3533  if (aChartHelper.setTextSelection(nType, nX, nY))
3534  return;
3535 
3536  SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
3537  switch (nType)
3538  {
3539  case LOK_SETTEXTSELECTION_START:
3540  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/false, /*bClearMark=*/false);
3541  break;
3542  case LOK_SETTEXTSELECTION_END:
3543  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/true, /*bClearMark=*/false);
3544  break;
3545  case LOK_SETTEXTSELECTION_RESET:
3546  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/true, /*bClearMark=*/true);
3547  break;
3548  default:
3549  assert(false);
3550  break;
3551  }
3552 }
3553 
3554 uno::Reference<datatransfer::XTransferable> SwXTextDocument::getSelection()
3555 {
3556  SolarMutexGuard aGuard;
3557 
3558  uno::Reference<datatransfer::XTransferable> xTransferable;
3559 
3560  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3561  if (SdrView* pSdrView = pWrtShell->GetDrawView())
3562  {
3563  if (pSdrView->GetTextEditObject())
3564  {
3565  // Editing shape text
3566  EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
3567  xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
3568  }
3569  }
3570 
3571  if (SwPostItMgr* pPostItMgr = pDocShell->GetView()->GetPostItMgr())
3572  {
3573  if (sw::annotation::SwAnnotationWin* pWin = pPostItMgr->GetActiveSidebarWin())
3574  {
3575  // Editing postit text.
3576  EditView& rEditView = pWin->GetOutlinerView()->GetEditView();
3577  xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
3578  }
3579  }
3580 
3581  if (!xTransferable.is())
3582  xTransferable = new SwTransferable(*pWrtShell);
3583 
3584  return xTransferable;
3585 }
3586 
3587 void SwXTextDocument::setGraphicSelection(int nType, int nX, int nY)
3588 {
3589  SolarMutexGuard aGuard;
3590 
3591  SwViewShell* pWrtViewShell = pDocShell->GetWrtShell();
3592  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3593  double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0);
3594 
3595  SfxViewShell* pViewShell = pDocShell->GetView();
3596  LokChartHelper aChartHelper(pViewShell);
3597  if (aChartHelper.setGraphicSelection(nType, nX, nY, fScale, fScale))
3598  return;
3599 
3600  SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
3601  switch (nType)
3602  {
3603  case LOK_SETGRAPHICSELECTION_START:
3604  rEditWin.SetGraphicTwipPosition(/*bStart=*/true, Point(nX, nY));
3605  break;
3606  case LOK_SETGRAPHICSELECTION_END:
3607  rEditWin.SetGraphicTwipPosition(/*bStart=*/false, Point(nX, nY));
3608  break;
3609  default:
3610  assert(false);
3611  break;
3612  }
3613 }
3614 
3616 {
3617  SolarMutexGuard aGuard;
3618 
3619  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3620  pWrtShell->ResetSelect(nullptr, false);
3621 }
3622 
3623 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 )
3624 {
3626  aData.nSize = sizeof(SystemGraphicsData);
3627  #if defined(_WIN32)
3628  sal_Int64 nWindowHandle;
3629  Parent >>= nWindowHandle;
3630  aData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
3631  ScopedVclPtrInstance<VirtualDevice> xDevice(aData, Size(1, 1), DeviceFormat::DEFAULT);
3632  paintTile(*xDevice, nOutputWidth, nOutputHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3633  #else
3634  // TODO: support other platforms
3635  (void)Parent;
3636  (void)nOutputWidth;
3637  (void)nOutputHeight;
3638  (void)nTilePosX;
3639  (void)nTilePosY;
3640  (void)nTileWidth;
3641  (void)nTileHeight;
3642  #endif
3643 }
3644 
3648 uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
3649  ::sal_Int16 nScriptTypes,
3650  ::sal_Int16 nMaxCount )
3651 {
3652  SolarMutexGuard aGuard;
3653 
3654  // possible canonical values for nScriptTypes
3655  // any bit wise combination is allowed
3656  const sal_Int16 nLatin = 0x001;
3657  const sal_Int16 nAsian = 0x002;
3658  const sal_Int16 nComplex = 0x004;
3659 
3660  // script types for which to get the languages
3661  const bool bLatin = 0 != (nScriptTypes & nLatin);
3662  const bool bAsian = 0 != (nScriptTypes & nAsian);
3663  const bool bComplex = 0 != (nScriptTypes & nComplex);
3664 
3665  if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex))
3666  throw IllegalArgumentException("nScriptTypes ranges from 1 to 7!", Reference< XInterface >(), 1);
3667  if (!pDocShell)
3668  throw DisposedException();
3669  SwDoc* pDoc = pDocShell->GetDoc();
3670 
3671  // avoid duplicate values
3672  std::set< LanguageType > aAllLangs;
3673 
3674  //USER STYLES
3675 
3676  const SwCharFormats *pFormats = pDoc->GetCharFormats();
3677  for(size_t i = 0; i < pFormats->size(); ++i)
3678  {
3679  const SwAttrSet &rAttrSet = (*pFormats)[i]->GetAttrSet();
3681  if (bLatin)
3682  {
3683  nLang = rAttrSet.GetLanguage( false ).GetLanguage();
3684  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3685  aAllLangs.insert( nLang );
3686  }
3687  if (bAsian)
3688  {
3689  nLang = rAttrSet.GetCJKLanguage( false ).GetLanguage();
3690  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3691  aAllLangs.insert( nLang );
3692  }
3693  if (bComplex)
3694  {
3695  nLang = rAttrSet.GetCTLLanguage( false ).GetLanguage();
3696  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3697  aAllLangs.insert( nLang );
3698  }
3699  }
3700 
3701  const SwTextFormatColls *pColls = pDoc->GetTextFormatColls();
3702  for (size_t i = 0; i < pColls->size(); ++i)
3703  {
3704  const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
3706  if (bLatin)
3707  {
3708  nLang = rAttrSet.GetLanguage( false ).GetLanguage();
3709  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3710  aAllLangs.insert( nLang );
3711  }
3712  if (bAsian)
3713  {
3714  nLang = rAttrSet.GetCJKLanguage( false ).GetLanguage();
3715  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3716  aAllLangs.insert( nLang );
3717  }
3718  if (bComplex)
3719  {
3720  nLang = rAttrSet.GetCTLLanguage( false ).GetLanguage();
3721  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3722  aAllLangs.insert( nLang );
3723  }
3724  }
3725 
3726  //AUTO STYLES
3727  const IStyleAccess::SwAutoStyleFamily aFam[2] =
3728  {
3731  };
3732  for (IStyleAccess::SwAutoStyleFamily i : aFam)
3733  {
3734  std::vector< std::shared_ptr<SfxItemSet> > rStyles;
3735  pDoc->GetIStyleAccess().getAllStyles(rStyles, i);
3736  while (!rStyles.empty())
3737  {
3738  std::shared_ptr<SfxItemSet> pStyle = rStyles.back();
3739  rStyles.pop_back();
3740  const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
3741 
3743  if (bLatin)
3744  {
3745  assert(pSet);
3746  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, false )).GetLanguage();
3747  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3748  aAllLangs.insert( nLang );
3749  }
3750  if (bAsian)
3751  {
3752  assert(pSet);
3753  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, false )).GetLanguage();
3754  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3755  aAllLangs.insert( nLang );
3756  }
3757  if (bComplex)
3758  {
3759  assert(pSet);
3760  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, false )).GetLanguage();
3761  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3762  aAllLangs.insert( nLang );
3763  }
3764  }
3765  }
3766 
3767  //TODO/mba: it's a strange concept that a view is needed to retrieve core data
3768  SwWrtShell *pWrtSh = pDocShell->GetWrtShell();
3769  SdrView *pSdrView = pWrtSh->GetDrawView();
3770 
3771  if( pSdrView )
3772  {
3773  SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
3774  if(pOutliner)
3775  {
3776  EditEngine& rEditEng = const_cast<EditEngine&>(pOutliner->GetEditEngine());
3777  sal_Int32 nParCount = pOutliner->GetParagraphCount();
3778  for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
3779  {
3780  //every paragraph
3781  std::vector<sal_Int32> aPortions;
3782  rEditEng.GetPortions( nPar, aPortions );
3783 
3784  for ( size_t nPos = aPortions.size(); nPos; )
3785  {
3786  //every position
3787  --nPos;
3788  sal_Int32 nEnd = aPortions[ nPos ];
3789  sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
3790  ESelection aSelection( nPar, nStart, nPar, nEnd );
3791  SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );
3792 
3794  if (bLatin)
3795  {
3796  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, false )).GetLanguage();
3797  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3798  aAllLangs.insert( nLang );
3799  }
3800  if (bAsian)
3801  {
3802  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, false )).GetLanguage();
3803  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3804  aAllLangs.insert( nLang );
3805  }
3806  if (bComplex)
3807  {
3808  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, false )).GetLanguage();
3809  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3810  aAllLangs.insert( nLang );
3811  }
3812  }
3813  }
3814  }
3815  }
3816  // less than nMaxCount languages
3817  if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() ))
3818  nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() );
3819 
3820  // build return value
3821  uno::Sequence< lang::Locale > aLanguages( nMaxCount );
3822  lang::Locale* pLanguage = aLanguages.getArray();
3823  if (nMaxCount > 0)
3824  {
3825  sal_Int32 nCount = 0;
3826  for (const auto& rLang : aAllLangs)
3827  {
3828  if (nCount >= nMaxCount)
3829  break;
3830  if (LANGUAGE_NONE != rLang)
3831  {
3832  pLanguage[nCount] = LanguageTag::convertToLocale( rLang );
3833  pLanguage[nCount].Language = SvtLanguageTable::GetLanguageString( rLang );
3834  nCount += 1;
3835  }
3836  }
3837  }
3838 
3839  return aLanguages;
3840 }
3841 
3843  pxDoc(&rxDoc)
3844 {
3845  sTables = SwResId(STR_CONTENT_TYPE_TABLE);
3846  sFrames = SwResId(STR_CONTENT_TYPE_FRAME);
3847  sGraphics = SwResId(STR_CONTENT_TYPE_GRAPHIC);
3848  sOLEs = SwResId(STR_CONTENT_TYPE_OLE);
3849  sSections = SwResId(STR_CONTENT_TYPE_REGION);
3850  sOutlines = SwResId(STR_CONTENT_TYPE_OUTLINE);
3851  sBookmarks = SwResId(STR_CONTENT_TYPE_BOOKMARK);
3852 }
3853 
3855 {
3856 }
3857 
3859 {
3860  Any aRet;
3861  if(!pxDoc)
3862  throw RuntimeException("No document available");
3863  OUString sSuffix("|");
3864  if(rName == sTables)
3865  {
3866  sSuffix += "table";
3867 
3869  pxDoc->getTextTables(), rName, sSuffix );
3870  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3871  }
3872  else if(rName == sFrames)
3873  {
3874  sSuffix += "frame";
3876  pxDoc->getTextFrames(), rName, sSuffix );
3877  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3878  }
3879  else if(rName == sSections)
3880  {
3881  sSuffix += "region";
3883  pxDoc->getTextSections(), rName, sSuffix );
3884  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3885  }
3886  else if(rName == sGraphics)
3887  {
3888  sSuffix += "graphic";
3890  pxDoc->getGraphicObjects(), rName, sSuffix );
3891  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3892  }
3893  else if(rName == sOLEs)
3894  {
3895  sSuffix += "ole";
3897  pxDoc->getEmbeddedObjects(), rName, sSuffix );
3898  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3899  }
3900  else if(rName == sOutlines)
3901  {
3902  sSuffix += "outline";
3904  *pxDoc, rName, sSuffix );
3905  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3906  }
3907  else if(rName == sBookmarks)
3908  {
3909  sSuffix.clear();
3911  pxDoc->getBookmarks(), rName, sSuffix );
3912  aRet <<= Reference< XPropertySet >(xBkms, UNO_QUERY);
3913  }
3914  else
3915  throw NoSuchElementException();
3916  return aRet;
3917 }
3918 
3920 {
3921  return { sTables,
3922  sFrames,
3923  sGraphics,
3924  sOLEs,
3925  sSections,
3926  sOutlines,
3927  sBookmarks };
3928 }
3929 
3931 {
3932  if( rName == sTables ||
3933  rName == sFrames ||
3934  rName == sGraphics||
3935  rName == sOLEs ||
3936  rName == sSections ||
3937  rName == sOutlines ||
3938  rName == sBookmarks )
3939  return true;
3940  return false;
3941 }
3942 
3944 {
3946 
3947 }
3948 
3950 {
3951  return nullptr != pxDoc;
3952 }
3953 
3955 {
3956  return "SwXLinkTargetSupplier";
3957 }
3958 
3960 {
3961  return cppu::supportsService(this, rServiceName);
3962 }
3963 
3965 {
3966  Sequence< OUString > aRet { "com.sun.star.document.LinkTargets" };
3967  return aRet;
3968 }
3969 
3971  Reference< XNameAccess > const & xAccess, const OUString& rLinkDisplayName, const OUString& sSuffix ) :
3972  xRealAccess(xAccess),
3973  pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3974  sLinkSuffix(sSuffix),
3975  sLinkDisplayName(rLinkDisplayName),
3976  pxDoc(nullptr)
3977 {
3978 }
3979 
3981  const OUString& rLinkDisplayName, const OUString& sSuffix) :
3982  pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3983  sLinkSuffix(sSuffix),
3984  sLinkDisplayName(rLinkDisplayName),
3985  pxDoc(&rxDoc)
3986 {
3987 }
3988 
3990 {
3991 }
3992 
3994 {
3995  Any aRet;
3996  bool bFound = false;
3997  //cut link extension and call the real NameAccess
3998  OUString sParam = rName;
3999  OUString sSuffix(sLinkSuffix);
4000  if(sParam.getLength() > sSuffix.getLength() )
4001  {
4002  OUString sCmp = sParam.copy(sParam.getLength() - sSuffix.getLength(),
4003  sSuffix.getLength());
4004  if(sCmp == sSuffix)
4005  {
4006  if(pxDoc)
4007  {
4008  sParam = sParam.copy(0, sParam.getLength() - sSuffix.getLength());
4009  if(!pxDoc->GetDocShell())
4010  throw RuntimeException("No document shell available");
4011  SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
4012  const size_t nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
4013 
4014  for (size_t i = 0; i < nOutlineCount && !bFound; ++i)
4015  {
4016  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4017  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4018  if(sParam == lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
4019  {
4020  Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
4021  aRet <<= xOutline;
4022  bFound = true;
4023  }
4024  }
4025  }
4026  else
4027  {
4028  aRet = xRealAccess->getByName(sParam.copy(0, sParam.getLength() - sSuffix.getLength()));
4030  if(!(aRet >>= xInt))
4031  throw RuntimeException("Could not retrieve property");
4032  Reference< XPropertySet > xProp(xInt, UNO_QUERY);
4033  aRet <<= xProp;
4034  bFound = true;
4035  }
4036  }
4037  }
4038  if(!bFound)
4039  throw NoSuchElementException();
4040  return aRet;
4041 }
4042 
4044 {
4045  Sequence< OUString > aRet;
4046  if(pxDoc)
4047  {
4048  if(!pxDoc->GetDocShell())
4049  throw RuntimeException("No document shell available");
4050 
4051  SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
4052  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4053  const size_t nOutlineCount = rOutlineNodes.size();
4054  aRet.realloc(nOutlineCount);
4055  OUString* pResArr = aRet.getArray();
4056  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4057  for (size_t i = 0; i < nOutlineCount; ++i)
4058  {
4059  OUString sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule) + "|outline";
4060  pResArr[i] = sEntry;
4061  }
4062  }
4063  else
4064  {
4065  Sequence< OUString > aOrg = xRealAccess->getElementNames();
4066  aRet.realloc(aOrg.getLength());
4067  std::transform(aOrg.begin(), aOrg.end(), aRet.begin(),
4068  [this](const OUString& rOrg) -> OUString { return rOrg + sLinkSuffix; });
4069  }
4070  return aRet;
4071 }
4072 
4074 {
4075  bool bRet = false;
4076  OUString sParam(rName);
4077  if(sParam.getLength() > sLinkSuffix.getLength() )
4078  {
4079  OUString sCmp = sParam.copy(sParam.getLength() - sLinkSuffix.getLength(),
4080  sLinkSuffix.getLength());
4081  if(sCmp == sLinkSuffix)
4082  {
4083  sParam = sParam.copy(0, sParam.getLength() - sLinkSuffix.getLength());
4084  if(pxDoc)
4085  {
4086  if(!pxDoc->GetDocShell())
4087  throw RuntimeException("No document shell available");
4088  SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
4089  const size_t nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
4090 
4091  for (size_t i = 0; i < nOutlineCount && !bRet; ++i)
4092  {
4093  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4094  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4095  if(sParam ==
4096  lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
4097  {
4098  bRet = true;
4099  }
4100  }
4101  }
4102  else
4103  {
4104  bRet = xRealAccess->hasByName(sParam);
4105  }
4106  }
4107  }
4108  return bRet;
4109 }
4110 
4112 {
4114 }
4115 
4117 {
4118  bool bRet = false;
4119  if(pxDoc)
4120  {
4121  OSL_FAIL("not implemented");
4122  }
4123  else
4124  {
4125  bRet = xRealAccess->hasElements();
4126  }
4127  return bRet;
4128 }
4129 
4130 Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo()
4131 {
4132  static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
4133  return xRet;
4134 }
4135 
4137  const OUString& rPropName, const Any& )
4138 {
4139  throw UnknownPropertyException(rPropName);
4140 }
4141 
4142 static Any lcl_GetDisplayBitmap(const OUString& _sLinkSuffix)
4143 {
4144  Any aRet;
4145  OUString sLinkSuffix = _sLinkSuffix;
4146  if(!sLinkSuffix.isEmpty())
4147  sLinkSuffix = sLinkSuffix.copy(1);
4148  OUString sImgId;
4149 
4150  if(sLinkSuffix == "outline")
4151  sImgId = RID_BMP_NAVI_OUTLINE;
4152  else if(sLinkSuffix == "table")
4153  sImgId = RID_BMP_NAVI_TABLE;
4154  else if(sLinkSuffix == "frame")
4155  sImgId = RID_BMP_NAVI_FRAME;
4156  else if(sLinkSuffix == "graphic")
4157  sImgId = RID_BMP_NAVI_GRAPHIC;
4158  else if(sLinkSuffix == "ole")
4159  sImgId = RID_BMP_NAVI_OLE;
4160  else if(sLinkSuffix.isEmpty())
4161  sImgId = RID_BMP_NAVI_BOOKMARK;
4162  else if(sLinkSuffix == "region")
4163  sImgId = RID_BMP_NAVI_REGION;
4164 
4165  if (!sImgId.isEmpty())
4166  {
4167  aRet <<= VCLUnoHelper::CreateBitmap(BitmapEx(sImgId));
4168  }
4169  return aRet;
4170 }
4171 
4172 Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName)
4173 {
4174  Any aRet;
4175  if( rPropertyName == UNO_LINK_DISPLAY_NAME )
4176  {
4177  aRet <<= sLinkDisplayName;
4178  }
4179  else if( rPropertyName == UNO_LINK_DISPLAY_BITMAP )
4180  {
4182  }
4183  else
4184  throw UnknownPropertyException(rPropertyName);
4185  return aRet;
4186 }
4187 
4189  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4190 {}
4191 
4193  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4194 {}
4195 
4197  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4198 {}
4199 
4201  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4202 {}
4203 
4205 {
4206  return this;
4207 }
4208 
4210 {
4211  return "SwXLinkNameAccessWrapper";
4212 }
4213 
4215 {
4216  return cppu::supportsService(this, rServiceName);
4217 }
4218 
4220 {
4221  Sequence< OUString > aRet { "com.sun.star.document.LinkTargets" };
4222  return aRet;
4223 }
4224 
4225 SwXOutlineTarget::SwXOutlineTarget(const OUString& rOutlineText) :
4226  pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
4227  sOutlineText(rOutlineText)
4228 {
4229 }
4230 
4232 {
4233 }
4234 
4235 Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo()
4236 {
4237  static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
4238  return xRet;
4239 }
4240 
4242  const OUString& rPropertyName, const Any& /*aValue*/)
4243 {
4244  throw UnknownPropertyException(rPropertyName);
4245 }
4246 
4247 Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
4248 {
4249  if(rPropertyName != UNO_LINK_DISPLAY_NAME)
4250  throw UnknownPropertyException(rPropertyName);
4251 
4252  return Any(sOutlineText);
4253 }
4254 
4256  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4257 {
4258 }
4259 
4261  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4262 {
4263 }
4264 
4266  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4267 {
4268 }
4269 
4271  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4272 {
4273 }
4274 
4276 {
4277  return "SwXOutlineTarget";
4278 }
4279 
4280 sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName)
4281 {
4282  return cppu::supportsService(this, ServiceName);
4283 }
4284 
4286 {
4287  Sequence<OUString> aRet { "com.sun.star.document.LinkTarget" };
4288 
4289  return aRet;
4290 }
4291 
4293 SvxUnoForbiddenCharsTable ( rDoc.getIDocumentSettingAccess().getForbiddenCharacterTable() )
4294 ,m_pDoc(&rDoc)
4295 {
4296 }
4297 
4299 {
4300 }
4301 
4303 {
4304  Reference<XInterface> xRet;
4305  if(m_pDoc)
4306  {
4307  switch(nWhich)
4308  {
4309  // #i52858#
4310  // assure that Draw model is created, if it doesn't exist.
4312  if(!xDashTable.is())
4314  xRet = xDashTable;
4315  break;
4317  if(!xGradientTable.is())
4319  xRet = xGradientTable;
4320  break;
4322  if(!xHatchTable.is())
4324  xRet = xHatchTable;
4325  break;
4327  if(!xBitmapTable.is())
4329  xRet = xBitmapTable;
4330  break;
4332  if(!xTransGradientTable.is())
4334  xRet = xTransGradientTable;
4335  break;
4337  if(!xMarkerTable.is())
4339  xRet = xMarkerTable;
4340  break;
4342  if(!xDrawDefaults.is())
4343  xDrawDefaults = static_cast<cppu::OWeakObject*>(new SwSvxUnoDrawPool(m_pDoc));
4344  xRet = xDrawDefaults;
4345  break;
4346 #if OSL_DEBUG_LEVEL > 0
4347  default: OSL_FAIL("which table?");
4348 #endif
4349  }
4350  }
4351  return xRet;
4352 }
4353 
4355 {
4356  xDashTable = nullptr;
4357  xGradientTable = nullptr;
4358  xHatchTable = nullptr;
4359  xBitmapTable = nullptr;
4360  xTransGradientTable = nullptr;
4361  xMarkerTable = nullptr;
4362  xDrawDefaults = nullptr;
4363  m_pDoc = nullptr;
4365 }
4366 
4368 {
4369  if(m_pDoc)
4371 }
4372 
4374  SwViewShell& rSh, const SwViewOption &rViewOptions)
4375  : m_pShell(&rSh)
4376  , m_aOldViewOptions( rViewOptions )
4377 {
4378 }
4379 
4381 {
4382  if (m_pShell)
4383  {
4385  }
4386 }
4387 
4388 void
4389 SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const pPrtOptions, bool setShowPlaceHoldersInPDF)
4390 {
4391  // to avoid unnecessary reformatting the view options related to the content
4392  // below should only change if necessary, that is if respective content is present
4393  const bool bContainsHiddenChars = m_pShell->GetDoc()->ContainsHiddenChars();
4395  const bool bContainsHiddenFields = pFieldType && pFieldType->HasWriterListeners();
4397  const bool bContainsHiddenParagraphs = pFieldType && pFieldType->HasWriterListeners();
4399  const bool bContainsPlaceHolders = pFieldType && pFieldType->HasWriterListeners();
4400  const bool bContainsFields = m_pShell->IsAnyFieldInDoc();
4401 
4402  SwViewOption aRenderViewOptions( m_aOldViewOptions );
4403 
4404  // disable anything in the view that should not be printed (or exported to PDF) by default
4405  // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids"
4406  // in section "Display of ...")
4407  aRenderViewOptions.SetParagraph( false ); // paragraph end
4408  aRenderViewOptions.SetSoftHyph( false ); // aka custom hyphens
4409  aRenderViewOptions.SetBlank( false ); // spaces
4410  aRenderViewOptions.SetHardBlank( false ); // non-breaking spaces
4411  aRenderViewOptions.SetTab( false ); // tabs
4412  aRenderViewOptions.SetLineBreak( false ); // breaks (type 1)
4413  aRenderViewOptions.SetPageBreak( false ); // breaks (type 2)
4414  aRenderViewOptions.SetColumnBreak( false ); // breaks (type 3)
4415  bool bVal = pPrtOptions && pPrtOptions->m_bPrintHiddenText;
4416  if (bContainsHiddenChars)
4417  aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text
4418  if (bContainsHiddenFields)
4419  aRenderViewOptions.SetShowHiddenField( bVal );
4420  if (bContainsHiddenParagraphs)
4421  aRenderViewOptions.SetShowHiddenPara( bVal );
4422 
4423  if (bContainsPlaceHolders)
4424  {
4425  // should always be printed in PDF export!
4426  bVal = !pPrtOptions ? setShowPlaceHoldersInPDF : pPrtOptions->m_bPrintTextPlaceholder;
4427  aRenderViewOptions.SetShowPlaceHolderFields( bVal );
4428  }
4429 
4430  if (bContainsFields)
4431  aRenderViewOptions.SetFieldName( false );
4432 
4433  // we need to set this flag in order to get to see the visible effect of
4434  // some of the above settings (needed for correct rendering)
4435  aRenderViewOptions.SetViewMetaChars( true );
4436 
4437  if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary
4438  {
4439  aRenderViewOptions.SetPrinting( pPrtOptions != nullptr );
4440  m_pShell->ApplyViewOptions( aRenderViewOptions );
4441  }
4442 }
4443 
4444 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual VclPtr< vcl::Window > getDocWindow() override
Definition: unotxdoc.cxx:3409
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:3993
OUString const & getRuntimeUID() const
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:234
long Width() const
css::uno::Reference< css::uno::XInterface > xDrawDefaults
Definition: unotxdoc.hxx:591
void SetLineBreak(bool b)
Definition: viewopt.hxx:238
static void UpdatePagesForPrintingWithPostItData(SwRenderData &rData, const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount)
Definition: doc.cxx:771
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:603
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)
static void postMouseEventAsync(const VclPtr< vcl::Window > &xWindow, int nType, const Point &rPos, int nCount, MouseEventModifiers aModifiers, int nButtons, int nModifier)
IDocumentStatistics const & getIDocumentStatistics() const
Definition: doc.cxx:372
bool hasValidSignatures() const
SwViewShell * GetViewShell() const
Definition: pview.hxx:235
virtual ~SwXOutlineTarget() override
Definition: unotxdoc.cxx:4231
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotxdoc.cxx:4247
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
static SvxAutoCorrCfg & Get()
virtual void ApplyViewOptions(const SwViewOption &rOpt)
Definition: viewsh.cxx:2117
long GetHeight() const
const SfxItemPropertySet * pPropSet
Definition: unotxdoc.hxx:557
static bool HasValidData(const css::uno::Reference< css::datatransfer::XTransferable > &rTransferable)
const OUString & GetTOIAutoMarkURL() const
Definition: doc.hxx:947
void SetSoftHyph(bool b)
Definition: viewopt.hxx:249
virtual OUString SAL_CALL getImplementationName() override
Definition: unotxdoc.cxx:3954
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:93
css::uno::Reference< css::uno::XInterface > xHatchTable
Definition: unotxdoc.hxx:587
static bool HitAny(const Point &aPos)
#define EE_CHAR_LANGUAGE_CJK
bool HasReplaceAttributes() const
Definition: unosrch.cxx:636
bool IsValid() const
Definition: unotxdoc.hxx:453
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:3930
void SetAutoControlFocus(bool _bAutoControlFocus)
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:184
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotxdoc.cxx:4200
#define WID_DOC_WORD_COUNT
Definition: unomap.hxx:231
void SetZoom(sal_uInt16 n)
Definition: viewopt.hxx:467
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:61
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:79
OUString getPageRectangles()
Implementation of lok::Document::getPartPageRectangles() for Writer.
Definition: crsrsh.cxx:1285
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:579
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getFootnotes() override
Definition: unotxdoc.cxx:669
OUString toISO8601(const css::util::DateTime &rDateTime)
SwDocShell * GetDocShell()
Definition: doc.hxx:1342
#define EE_CHAR_LANGUAGE
const SwRect & GetAnchorRect() const
static SwXTextRanges * Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1483
virtual ~SwXLinkNameAccessWrapper() override
Definition: unotxdoc.cxx:3989
SwXBodyText * pBodyText
Definition: unotxdoc.hxx:153
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks() override
Definition: unotxdoc.cxx:4204
virtual void CalcLayout()
Definition: viewsh.cxx:984
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:817
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1401
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getFootnoteSettings() override
Definition: unotxdoc.cxx:682
bool HasSearchAttributes() const
Definition: unosrch.cxx:631
virtual void initializeForTiledRendering(const css::uno::Sequence< css::beans::PropertyValue > &rArguments) override
Definition: unotxdoc.cxx:3425
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:237
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:230
css::uno::Reference< css::drawing::XDrawPage > mxXDrawPage
Definition: unotxdoc.hxx:150
long Height() const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
OUString getTrackedChangeAuthors() override
Definition: unotxdoc.cxx:3322
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
View of a document.
Definition: pview.hxx:161
static bool lcl_GetBoolProperty(const uno::Sequence< beans::PropertyValue > &rOptions, const sal_Char *pPropName)
Definition: unotxdoc.cxx:2336
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:795
void SetRedlineAuthor(const OUString &rAuthor)
Definition: viewprt.cxx:293
SwXOutlineTarget(const OUString &rOutlineText)
Definition: unotxdoc.cxx:4225
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:3615
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unotxdoc.cxx:505
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:1314
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:622
virtual void SAL_CALL release() override
Definition: unotxdoc.cxx:361
SVX_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoGradientTable_createInstance(SdrModel *pModel)
const SwPosition * GetMark() const
Definition: pam.hxx:209
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unotxdoc.cxx:3919
virtual void SAL_CALL connectController(const css::uno::Reference< css::frame::XController > &xController) override
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:402
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:656
css::uno::Reference< css::uno::XInterface > create(OUString const &rServiceName, css::uno::Sequence< css::uno::Any > const *arguments)
Definition: unotxdoc.cxx:1647
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:3587
const SvxLanguageItem & GetLanguage(bool=true) const
Definition: charatr.hxx:92
virtual css::uno::Any SAL_CALL getByName(const OUString &Name) override
Definition: unotxdoc.cxx:3858
#define RES_FRMATR_END
Definition: hintids.hxx:238
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:572
void SetLandscape(bool b)
Definition: pvprtdat.hxx:64
Definition: doc.hxx:185
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotxdoc.cxx:3949
const SvxLanguageItem & GetCJKLanguage(bool=true) const
Definition: charatr.hxx:94
static void PaintAllChartsOnTile(VirtualDevice &rDevice, int nOutputWidth, int nOutputHeight, int nTilePosX, int nTilePosY, long nTileWidth, long nTileHeight)
const OUString sLinkSuffix
Definition: unotxdoc.hxx:512
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:259
OUString m_sSearchText
Definition: unosrch.hxx:46
SwViewShell * m_pShell
Definition: unotxdoc.hxx:610
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getNumberingRules() override
Definition: unotxdoc.cxx:657
void Height(long nNew)
Definition: swrect.hxx:189
comphelper::OInterfaceContainerHelper2 & GetPasteListeners()
Definition: fecopy.cxx:1180
sal_Int16 nId
css::uno::Reference< css::container::XIndexReplace > mxXChapterNumbering
Definition: unotxdoc.hxx:172
SwXDocumentPropertyHelper * GetPropertyHelper()
Definition: unotxdoc.cxx:461
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:1805
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:4389
virtual void SAL_CALL acquire() override
::sw::DocumentRedlineManager const & GetDocumentRedlineManager() const
Definition: doc.cxx:344
void PaintTile(VirtualDevice &rDevice, int contextWidth, int contextHeight, int tilePosX, int tilePosY, long tileWidth, long tileHeight)
Paint tile.
Definition: viewsh.cxx:1898
virtual void SAL_CALL printPages(const css::uno::Sequence< css::beans::PropertyValue > &xOptions) override
Definition: unotxdoc.cxx:1139
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const OUString &ServiceSpecifier, const css::uno::Sequence< css::uno::Any > &Arguments) override
const SfxItemPropertySet * pPropSet
Definition: unotxdoc.hxx:511
void SetRow(sal_uInt8 n)
Definition: pvprtdat.hxx:58
bool setTextSelection(int nType, int nX, int nY)
SwEditWin & GetEditWin()
Definition: view.hxx:403
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotxdoc.cxx:4265
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: unotxdoc.cxx:2226
SwDrawPagesObj(const css::uno::Reference< css::drawing::XDrawPageSupplier > &rxDoc)
Definition: unotxdoc.cxx:1376
std::shared_ptr< SvxForbiddenCharactersTable > mxForbiddenChars
void Pos(const Point &rNew)
Definition: swrect.hxx:167
#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)
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies() override
Definition: unotxdoc.cxx:1326
sal_uInt8 GetCol() const
Definition: pvprtdat.hxx:60
void RecheckBrowseMode()
Definition: view0.cxx:175
css::uno::Reference< css::uno::XInterface > xMarkerTable
Definition: unotxdoc.hxx:590
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:34
#define RES_TXTATR_CHARFMT
Definition: hintids.hxx:143
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
virtual OUString SAL_CALL getImplementationName() override
Definition: unotxdoc.cxx:4275
void SetHardBlank(bool b)
Definition: viewopt.hxx:226
virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getRedlines() override
Definition: unotxdoc.cxx:2196
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotxdoc.cxx:1412
virtual void SAL_CALL disconnectController(const css::uno::Reference< css::frame::XController > &xController) override
Definition: unotxdoc.cxx:599
void SetShowHiddenChar(bool b)
Definition: viewopt.hxx:286
bool HasWriterListeners() const
Definition: calbck.hxx:208
virtual ~SwXDocumentPropertyHelper() override
Definition: unotxdoc.cxx:4298
void SetOpenInDesignMode(bool _bOpenDesignMode)
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
css::uno::Reference< css::uno::XInterface > xGradientTable
Definition: unotxdoc.hxx:586
void SetPrintGraphic(bool b)
Definition: printdata.hxx:150
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unotxdoc.cxx:1756
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4094
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
void SetColumnBreak(bool b)
Definition: viewopt.hxx:244
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getReferenceMarks() override
Definition: unotxdoc.cxx:1218
static void lcl_DisposeView(SfxViewFrame *pToClose, SwDocShell const *pDocShell)
Definition: unotxdoc.cxx:262
#define WID_DOC_CHANGES_PASSWORD
Definition: unomap.hxx:239
SwXDrawPage * pDrawPage
Definition: unotxdoc.hxx:149
SwXTextCursor * CreateTextCursor(const bool bIgnoreTables=false)
Definition: unotext.cxx:2298
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:1815
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:633
void SetClipboard(css::uno::Reference< css::datatransfer::clipboard::XClipboard > const &xClipboard)
#define UNO_LINK_DISPLAY_BITMAP
Definition: unoprnms.hxx:462
SVX_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoHatchTable_createInstance(SdrModel *pModel)
static bool IsShowChanges(const RedlineFlags eM)
virtual css::uno::Reference< css::beans::XPropertySet > SAL_CALL getEndnoteSettings() override
Definition: unotxdoc.cxx:706
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
show all inserts
static LanguageType nLang
Definition: srtdlg.cxx:60
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPagePrintSettings() override
Definition: unotxdoc.cxx:992
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:154
const SwPostItField * GetPostItField() const
void CheckViewLayout(const SwViewOption *pViewOpt, const SwRect *pVisArea)
Definition: pagechg.cxx:2065
size_type size() const
Definition: docary.hxx:368
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:718
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:356
static SwTextFormatColl * lcl_GetParaStyle(const OUString &rCollName, SwDoc *pDoc)
Definition: unotxdoc.cxx:249
SVX_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoMarkerTable_createInstance(SdrModel *pModel)
virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL getDrawPage() override
Definition: unotxdoc.cxx:1351
virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController() override
#define RES_CHRATR_END
Definition: hintids.hxx:115
void Reactivate(SwDocShell *pNewDocShell)
Definition: unotxdoc.cxx:1454
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotxdoc.cxx:1828
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotxdoc.cxx:371
void CallAutomationDocumentEventSinks(const OUString &Method, css::uno::Sequence< css::uno::Any > &Arguments)
Definition: docsh.cxx:1438
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
sal_Int32 PrintSource(OutputDevice *pOutDev, sal_Int32 nPage, bool bCalcNumPagesOnly)
Definition: srcview.cxx:676
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
SwIndex nContent
Definition: pam.hxx:38
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unotxdoc.cxx:4192
void SetParagraph(bool b)
Definition: viewopt.hxx:232
const SwRect & getFrameArea() const
Definition: frame.hxx:175
void CalcPagesForPrint(sal_uInt16 nMax)
Definition: vprint.cxx:295
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
bool getBrowseMode() const
Definition: viewopt.hxx:433
css::uno::Reference< css::container::XNameAccess > mxXReferenceMarks
Definition: unotxdoc.hxx:161
OUString m_sReplaceText
Definition: unosrch.hxx:47
SwXTextDocument(SwDocShell *pShell)
Definition: unotxdoc.cxx:394
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:425
static void CalculatePagePairsForProspectPrinting(const SwRootFrame &rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount)
Definition: doc.cxx:910
SwCreateDrawTable
Definition: unotxdoc.hxx:579
char sal_Char
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unotxdoc.cxx:4136
std::deque< std::unique_ptr< UnoActionContext, o3tl::default_delete< UnoActionContext > > > maActionArr
Definition: unotxdoc.hxx:142
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:650
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotxdoc.cxx:3959
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, co