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  Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
824  if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
825  return nullptr;
826 
827  auto pUnoCursor(CreateCursorForSearch(xCursor));
828  const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
829  xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
830 
831  bool bParentInExtra = false;
832  if(xLastResult.is())
833  {
834  Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
835  OTextCursorHelper* pPosCursor = nullptr;
836  if(xCursorTunnel.is())
837  {
838  pPosCursor = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
840  }
841  SwPaM* pCursor = pPosCursor ? pPosCursor->GetPaM() : nullptr;
842  if(pCursor)
843  {
844  *pUnoCursor->GetPoint() = *pCursor->End();
845  pUnoCursor->DeleteMark();
846  }
847  else
848  {
849  SwXTextRange* pRange = nullptr;
850  if(xCursorTunnel.is())
851  {
852  pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
854  }
855  if(!pRange)
856  return nullptr;
857  pRange->GetPositions(*pUnoCursor);
858  if(pUnoCursor->HasMark())
859  {
860  if(*pUnoCursor->GetPoint() < *pUnoCursor->GetMark())
861  pUnoCursor->Exchange();
862  pUnoCursor->DeleteMark();
863  }
864  }
865  const SwNode& rRangeNode = pUnoCursor->GetNode();
866  bParentInExtra = rRangeNode.FindFlyStartNode() ||
867  rRangeNode.FindFootnoteStartNode() ||
868  rRangeNode.FindHeaderStartNode() ||
869  rRangeNode.FindFooterStartNode() ;
870  }
871 
872  i18nutil::SearchOptions2 aSearchOpt;
873  pSearch->FillSearchOptions( aSearchOpt );
874 
884  if(bParentInExtra)
885  eRanges = FindRanges::InOther;
886  if(bAll) //always - everywhere?
887  eRanges = FindRanges::InSelAll;
890 
891  nResult = 0;
892  for (int nSearchProc = 0; nSearchProc < 2; ++nSearchProc)
893  {
894  //try attribute search first
895  if(pSearch->HasSearchAttributes())
896  {
897  SfxItemSet aSearch(
899  svl::Items<
904  pSearch->FillSearchItemSet(aSearch);
905  bool bCancel;
906  nResult = static_cast<sal_Int32>(pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
907  eStart, eEnd, bCancel,
908  eRanges,
909  !pSearch->m_sSearchText.isEmpty() ? &aSearchOpt : nullptr ));
910  }
911  else if(pSearch->m_bStyles)
912  {
913  SwTextFormatColl *pSearchColl = lcl_GetParaStyle(pSearch->m_sSearchText, pUnoCursor->GetDoc());
914  //pSearch->sReplaceText
915  SwTextFormatColl *pReplaceColl = nullptr;
916  bool bCancel;
917  nResult = static_cast<sal_Int32>(pUnoCursor->FindFormat(*pSearchColl,
918  eStart, eEnd, bCancel,
919  eRanges, pReplaceColl ));
920  }
921  else
922  {
923  //todo/mba: assuming that notes should be omitted
924  bool bCancel;
925  nResult = static_cast<sal_Int32>(pUnoCursor->Find_Text(aSearchOpt, false/*bSearchInNotes*/,
926  eStart, eEnd, bCancel,
927  eRanges ));
928  }
929  if(nResult || (eRanges&(FindRanges::InSelAll|FindRanges::InOther)))
930  break;
931  //second step - find in other
932  eRanges = FindRanges::InOther;
933  }
934  return pUnoCursor;
935 }
936 
937 Reference< XIndexAccess >
938  SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc)
939 {
940  SolarMutexGuard aGuard;
942  sal_Int32 nResult = 0;
943  Reference< XTextCursor > xCursor;
944  auto pResultCursor(FindAny(xDesc, xCursor, true, nResult, xTmp));
945  if(!pResultCursor)
946  throw RuntimeException("No result cursor");
947  Reference< XIndexAccess > xRet = SwXTextRanges::Create( nResult ? &(*pResultCursor) : nullptr );
948  return xRet;
949 }
950 
951 Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc)
952 {
953  SolarMutexGuard aGuard;
955  sal_Int32 nResult = 0;
956  Reference< XTextCursor > xCursor;
957  auto pResultCursor(FindAny(xDesc, xCursor, false, nResult, xTmp));
958  if(!pResultCursor)
959  throw RuntimeException("No result cursor");
961  if(nResult)
962  {
963  const uno::Reference< text::XText > xParent =
965  *pResultCursor->GetPoint());
966  xRet = *new SwXTextCursor(xParent, *pResultCursor);
967  }
968  return xRet;
969 }
970 
972  const Reference< util::XSearchDescriptor > & xDesc)
973 {
974  SolarMutexGuard aGuard;
975  sal_Int32 nResult = 0;
976  Reference< XTextCursor > xCursor;
977  if(!xStartAt.is())
978  throw RuntimeException("xStartAt missing");
979  auto pResultCursor(FindAny(xDesc, xCursor, false, nResult, xStartAt));
980  if(!pResultCursor)
981  throw RuntimeException("No result cursor");
983  if(nResult)
984  {
985  const uno::Reference< text::XText > xParent =
987  *pResultCursor->GetPoint());
988 
989  xRet = *new SwXTextCursor(xParent, *pResultCursor);
990  }
991  return xRet;
992 }
993 
995 {
996  SolarMutexGuard aGuard;
998  if(!IsValid())
999  throw DisposedException("", static_cast< XTextDocument* >(this));
1000 
1001  beans::PropertyValue* pArray = aSeq.getArray();
1004  if(pData)
1005  aData = *pData;
1006  Any aVal;
1007  aVal <<= static_cast<sal_Int16>(aData.GetRow());
1008  pArray[0] = beans::PropertyValue("PageRows", -1, aVal, PropertyState_DIRECT_VALUE);
1009  aVal <<= static_cast<sal_Int16>(aData.GetCol());
1010  pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE);
1011  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetLeftSpace()));
1012  pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1013  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetRightSpace()));
1014  pArray[3] = beans::PropertyValue("RightMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1015  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetTopSpace()));
1016  pArray[4] = beans::PropertyValue("TopMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1017  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetBottomSpace()));
1018  pArray[5] = beans::PropertyValue("BottomMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1019  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetHorzSpace()));
1020  pArray[6] = beans::PropertyValue("HoriMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1021  aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetVertSpace()));
1022  pArray[7] = beans::PropertyValue("VertMargin", -1, aVal, PropertyState_DIRECT_VALUE);
1023  aVal <<= aData.GetLandscape();
1024  pArray[8] = beans::PropertyValue("IsLandscape", -1, aVal, PropertyState_DIRECT_VALUE);
1025 
1026  return aSeq;
1027 }
1028 
1029 static sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, bool& bException)
1030 {
1031  bException = false;
1032  TypeClass eType = rValue.getValueType().getTypeClass();
1033 
1034  sal_uInt32 nRet = 0;
1035  if( eType == TypeClass_UNSIGNED_LONG )
1036  rValue >>= nRet;
1037  else
1038  {
1039  sal_Int32 nVal=0;
1040  bException = !(rValue >>= nVal);
1041  if( !bException )
1042  nRet = static_cast<sal_uInt32>(nVal);
1043  }
1044 
1045  return nRet;
1046 }
1047 
1048 static OUString lcl_CreateOutlineString( size_t nIndex,
1049  const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
1050 {
1051  OUStringBuffer sEntry;
1052  const SwTextNode * pTextNd = rOutlineNodes[ nIndex ]->GetTextNode();
1053  SwNumberTree::tNumberVector aNumVector = pTextNd->GetNumberVector();
1054  if( pOutlRule && pTextNd->GetNumRule())
1055  for( int nLevel = 0;
1056  nLevel <= pTextNd->GetActualListLevel();
1057  nLevel++ )
1058  {
1059  long nVal = aNumVector[nLevel];
1060  nVal ++;
1061  nVal -= pOutlRule->Get(nLevel).GetStart();
1062  sEntry.append(OUString::number( nVal ));
1063  sEntry.append(".");
1064  }
1065  sEntry.append( rOutlineNodes[ nIndex ]->
1066  GetTextNode()->GetExpandText(nullptr) );
1067  return sEntry.makeStringAndClear();
1068 }
1069 
1071 {
1072  SolarMutexGuard aGuard;
1073  if(!IsValid())
1074  throw DisposedException("", static_cast< XTextDocument* >(this));
1075 
1077  //if only a few properties are coming, then use the current settings
1079  if(pData)
1080  aData = *pData;
1081  for(const beans::PropertyValue& rProperty : aSettings)
1082  {
1083  OUString sName = rProperty.Name;
1084  const Any& rVal = rProperty.Value;
1085  bool bException;
1086  sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
1087  if( sName == "PageRows" )
1088  {
1089  if(!nVal || nVal > 0xff)
1090  throw RuntimeException("Invalid value");
1091  aData.SetRow(static_cast<sal_uInt8>(nVal));
1092  }
1093  else if(sName == "PageColumns")
1094  {
1095  if(!nVal || nVal > 0xff)
1096  throw RuntimeException("Invalid value");
1097  aData.SetCol(static_cast<sal_uInt8>(nVal));
1098  }
1099  else if(sName == "LeftMargin")
1100  {
1101  aData.SetLeftSpace(convertMm100ToTwip(nVal));
1102  }
1103  else if(sName == "RightMargin")
1104  {
1105  aData.SetRightSpace(convertMm100ToTwip(nVal));
1106  }
1107  else if(sName == "TopMargin")
1108  {
1109  aData.SetTopSpace(convertMm100ToTwip(nVal));
1110  }
1111  else if(sName == "BottomMargin")
1112  {
1113  aData.SetBottomSpace(convertMm100ToTwip(nVal));
1114  }
1115  else if(sName == "HoriMargin")
1116  {
1117  aData.SetHorzSpace(convertMm100ToTwip(nVal));
1118  }
1119  else if(sName == "VertMargin")
1120  {
1121  aData.SetVertSpace(convertMm100ToTwip(nVal));
1122  }
1123  else if(sName == "IsLandscape")
1124  {
1125  auto b = o3tl::tryAccess<bool>(rVal);
1126  bException = !b;
1127  if (b)
1128  {
1129  aData.SetLandscape(*b);
1130  }
1131  }
1132  else
1133  bException = true;
1134  if(bException)
1135  throw RuntimeException();
1136  }
1137  pDocShell->GetDoc()->SetPreviewPrtData(&aData);
1138 
1139 }
1140 
1142 {
1143  SolarMutexGuard aGuard;
1144  if(!IsValid())
1145  throw DisposedException("", static_cast< XTextDocument* >(this));
1146 
1148  SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SfxCallMode::SYNCHRON,
1149  pDocShell->GetDoc()->GetAttrPool());
1151 
1152  for ( const beans::PropertyValue &rProp : xOptions )
1153  {
1154  // get Property-Value from options
1155  Any aValue( rProp.Value );
1156 
1157  // FileName-Property?
1158  if ( rProp.Name == UNO_NAME_FILE_NAME )
1159  {
1160  OUString sFileURL;
1161  if ( rProp.Value >>= sFileURL )
1162  {
1163  // Convert the File URL into a system dependent path, as the SalPrinter expects
1164  OUString sSystemPath;
1165  FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
1166  aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
1167  }
1168  else if ( rProp.Value.getValueType() != cppu::UnoType<void>::get() )
1169  throw IllegalArgumentException();
1170  }
1171 
1172  // CopyCount-Property
1173  else if ( rProp.Name == UNO_NAME_COPY_COUNT )
1174  {
1175  sal_Int32 nCopies = 0;
1176  aValue >>= nCopies;
1177  aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, static_cast<sal_Int16>(nCopies) ) );
1178  }
1179 
1180  // Collate-Property
1181  else if ( rProp.Name == UNO_NAME_COLLATE )
1182  {
1183  auto b = o3tl::tryAccess<bool>(rProp.Value);
1184  if ( !b )
1185  throw IllegalArgumentException();
1186  aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *b ) );
1187 
1188  }
1189 
1190  // Sort-Property
1191  else if ( rProp.Name == UNO_NAME_SORT )
1192  {
1193  auto b = o3tl::tryAccess<bool>(rProp.Value);
1194  if ( !b )
1195  throw IllegalArgumentException();
1196 
1197  aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *b ) );
1198  }
1199 
1200  // Pages-Property
1201  else if ( rProp.Name == UNO_NAME_PAGES )
1202  {
1203  OUString sTmp;
1204  if ( !(rProp.Value >>= sTmp) )
1205  throw IllegalArgumentException();
1206 
1207  aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
1208 
1209  }
1210  }
1211 
1212  // #i117783#
1214  pFrame->GetViewShell()->ExecuteSlot(aReq);
1215  // Frame close
1216  pFrame->DoClose();
1217 
1218 }
1219 
1221 {
1222  SolarMutexGuard aGuard;
1223  if(!IsValid())
1224  throw DisposedException("", static_cast< XTextDocument* >(this));
1225  if(!mxXReferenceMarks.is())
1226  {
1228  }
1229  return mxXReferenceMarks;
1230 }
1231 
1232 Reference< XEnumerationAccess > SwXTextDocument::getTextFields()
1233 {
1234  SolarMutexGuard aGuard;
1235  if(!IsValid())
1236  throw DisposedException("", static_cast< XTextDocument* >(this));
1237  if(!mxXTextFieldTypes.is())
1238  {
1240  }
1241  return mxXTextFieldTypes;
1242 }
1243 
1245 {
1246  SolarMutexGuard aGuard;
1247  if(!IsValid())
1248  throw DisposedException("", static_cast< XTextDocument* >(this));
1249  if(!mxXTextFieldMasters.is())
1250  {
1252  }
1253  return mxXTextFieldMasters;
1254 }
1255 
1257 {
1258  SolarMutexGuard aGuard;
1259  if(!IsValid())
1260  throw DisposedException("", static_cast< XTextDocument* >(this));
1261  if(!mxXEmbeddedObjects.is())
1262  {
1264  }
1265  return mxXEmbeddedObjects;
1266 }
1267 
1269 {
1270  SolarMutexGuard aGuard;
1271  if(!IsValid())
1272  throw DisposedException("", static_cast< XTextDocument* >(this));
1273  if(!mxXBookmarks.is())
1274  {
1276  }
1277  return mxXBookmarks;
1278 }
1279 
1281 {
1282  SolarMutexGuard aGuard;
1283  if(!IsValid())
1284  throw DisposedException("", static_cast< XTextDocument* >(this));
1285  if(!mxXTextSections.is())
1286  {
1288  }
1289  return mxXTextSections;
1290 }
1291 
1293 {
1294  SolarMutexGuard aGuard;
1295  if(!IsValid())
1296  throw DisposedException("", static_cast< XTextDocument* >(this));
1297  if(!mxXTextTables.is())
1298  {
1300  }
1301  return mxXTextTables;
1302 }
1303 
1305 {
1306  SolarMutexGuard aGuard;
1307  if(!IsValid())
1308  throw DisposedException("", static_cast< XTextDocument* >(this));
1309  if(!mxXGraphicObjects.is())
1310  {
1312  }
1313  return mxXGraphicObjects;
1314 }
1315 
1317 {
1318  SolarMutexGuard aGuard;
1319  if(!IsValid())
1320  throw DisposedException("", static_cast< XTextDocument* >(this));
1321  if(!mxXTextFrames.is())
1322  {
1324  }
1325  return mxXTextFrames;
1326 }
1327 
1329 {
1330  SolarMutexGuard aGuard;
1331  if(!IsValid())
1332  throw DisposedException("", static_cast< XTextDocument* >(this));
1333  if(!mxXStyleFamilies.is())
1334  {
1336  }
1337  return mxXStyleFamilies;
1338 }
1339 
1340 uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
1341 {
1342  SolarMutexGuard aGuard;
1343  if(!IsValid())
1344  throw DisposedException("", static_cast< XTextDocument* >(this));
1345  if(!mxXAutoStyles.is())
1346  {
1348  }
1349  return mxXAutoStyles;
1350 
1351 }
1352 
1354 {
1355  SolarMutexGuard aGuard;
1356  if(!IsValid())
1357  throw DisposedException("", static_cast< XTextDocument* >(this));
1358  if(!mxXDrawPage.is())
1359  {
1362  // Create a Reference to trigger the complete initialization of the
1363  // object. Otherwise in some corner cases it would get initialized
1364  // at ::InitNewDoc -> which would get called during
1365  // close() or dispose() -> n#681746
1366  uno::Reference<lang::XComponent> xComp( mxXDrawPage, uno::UNO_QUERY );
1367  }
1368  return mxXDrawPage;
1369 }
1370 
1371 class SwDrawPagesObj : public cppu::WeakImplHelper<
1372  css::drawing::XDrawPages,
1373  css::lang::XServiceInfo>
1374 {
1375 private:
1376  css::uno::Reference< css::drawing::XDrawPageSupplier > m_xDoc;
1377 public:
1378  SwDrawPagesObj(const css::uno::Reference< css::drawing::XDrawPageSupplier >& rxDoc) : m_xDoc(rxDoc) {}
1379 
1380  // XDrawPages
1381  virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL
1382  insertNewByIndex(sal_Int32 /*nIndex*/) override { throw css::lang::NoSupportException(); }
1383 
1384  virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XDrawPage >& /*xPage*/) override
1385  {
1386  throw css::lang::NoSupportException();
1387  }
1388 
1389  // XIndexAccess
1390  virtual sal_Int32 SAL_CALL getCount() override { return 1; }
1391 
1392  virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
1393  {
1394  if (Index != 0)
1395  throw css::lang::IndexOutOfBoundsException("Writer documents have only one DrawPage!");
1396  return css::uno::Any(m_xDoc->getDrawPage());
1397  }
1398 
1399  // XElementAccess
1400  virtual css::uno::Type SAL_CALL getElementType() override
1401  {
1402  SolarMutexGuard aGuard;
1404  }
1405 
1406  virtual sal_Bool SAL_CALL hasElements() override { return true; }
1407 
1408  // XServiceInfo
1409  virtual OUString SAL_CALL getImplementationName() override
1410  {
1411  return "SwDrawPagesObj";
1412  }
1413 
1414  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override
1415  {
1416  return cppu::supportsService(this, ServiceName);
1417  }
1418 
1419  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1420  {
1421  return { "com.sun.star.drawing.DrawPages" };
1422  }
1423 };
1424 
1425 // XDrawPagesSupplier
1426 
1427 uno::Reference<drawing::XDrawPages> SAL_CALL SwXTextDocument::getDrawPages()
1428 {
1429  SolarMutexGuard aGuard;
1430  return new SwDrawPagesObj(this);
1431 }
1432 
1434 {
1435  bObjectValid = false;
1436  if(xNumFormatAgg.is())
1437  {
1438  const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
1439  Any aNumTunnel = xNumFormatAgg->queryAggregation(rTunnelType);
1440  SvNumberFormatsSupplierObj* pNumFormat = nullptr;
1441  Reference< XUnoTunnel > xNumTunnel;
1442  if(aNumTunnel >>= xNumTunnel)
1443  {
1444  pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1445  xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1446  pNumFormat->SetNumberFormatter(nullptr);
1447  }
1448  OSL_ENSURE(pNumFormat, "No number formatter available");
1449  }
1450  InitNewDoc();
1451  pDocShell = nullptr;
1452  lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
1453  m_pImpl->m_RefreshListeners.disposeAndClear(ev);
1454 }
1455 
1457 {
1458  if(pDocShell && pDocShell != pNewDocShell)
1459  Invalidate();
1460  pDocShell = pNewDocShell;
1461  bObjectValid = true;
1462 }
1463 
1465 {
1466  // first invalidate all collections, then delete references and Set to zero
1467  if(mxXTextTables.is())
1468  {
1469  XNameAccess* pTables = mxXTextTables.get();
1470  static_cast<SwXTextTables*>(pTables)->Invalidate();
1471  mxXTextTables.clear();
1472  }
1473 
1474  if(mxXTextFrames.is())
1475  {
1476  XNameAccess* pFrames = mxXTextFrames.get();
1477  static_cast<SwXTextFrames*>(pFrames)->Invalidate();
1478  mxXTextFrames.clear();
1479  }
1480 
1481  if(mxXGraphicObjects.is())
1482  {
1483  XNameAccess* pFrames = mxXGraphicObjects.get();
1484  static_cast<SwXTextGraphicObjects*>(pFrames)->Invalidate();
1485  mxXGraphicObjects.clear();
1486  }
1487 
1488  if(mxXEmbeddedObjects.is())
1489  {
1490  XNameAccess* pOLE = mxXEmbeddedObjects.get();
1491  static_cast<SwXTextEmbeddedObjects*>(pOLE)->Invalidate();
1492  mxXEmbeddedObjects.clear();
1493  }
1494 
1495  if(xBodyText.is())
1496  {
1497  xBodyText = nullptr;
1498  pBodyText = nullptr;
1499  }
1500 
1501  if(xNumFormatAgg.is())
1502  {
1503  const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
1504  Any aNumTunnel = xNumFormatAgg->queryAggregation(rTunnelType);
1505  SvNumberFormatsSupplierObj* pNumFormat = nullptr;
1506  Reference< XUnoTunnel > xNumTunnel;
1507  if(aNumTunnel >>= xNumTunnel)
1508  {
1509  pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
1510  xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
1511 
1512  }
1513  OSL_ENSURE(pNumFormat, "No number formatter available");
1514  if (pNumFormat)
1515  pNumFormat->SetNumberFormatter(nullptr);
1516  }
1517 
1518  if(mxXTextFieldTypes.is())
1519  {
1520  XEnumerationAccess* pT = mxXTextFieldTypes.get();
1521  static_cast<SwXTextFieldTypes*>(pT)->Invalidate();
1522  mxXTextFieldTypes.clear();
1523  }
1524 
1525  if(mxXTextFieldMasters.is())
1526  {
1527  XNameAccess* pT = mxXTextFieldMasters.get();
1528  static_cast<SwXTextFieldMasters*>(pT)->Invalidate();
1529  mxXTextFieldMasters.clear();
1530  }
1531 
1532  if(mxXTextSections.is())
1533  {
1534  XNameAccess* pSect = mxXTextSections.get();
1535  static_cast<SwXTextSections*>(pSect)->Invalidate();
1536  mxXTextSections.clear();
1537  }
1538 
1539  if(mxXDrawPage.is())
1540  {
1541  // #i91798#, #i91895#
1542  // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
1543  uno::Reference<lang::XComponent> xComp( mxXDrawPage, uno::UNO_QUERY );
1544  xComp->dispose();
1546  mxXDrawPage.clear();
1547  }
1548 
1549  if ( mxXNumberingRules.is() )
1550  {
1551  XIndexAccess* pNum = mxXNumberingRules.get();
1552  static_cast<SwXNumberingRulesCollection*>(pNum)->Invalidate();
1553  mxXNumberingRules.clear();
1554  }
1555 
1556  if(mxXFootnotes.is())
1557  {
1558  XIndexAccess* pFootnote = mxXFootnotes.get();
1559  static_cast<SwXFootnotes*>(pFootnote)->Invalidate();
1560  mxXFootnotes.clear();
1561  }
1562 
1563  if(mxXEndnotes.is())
1564  {
1565  XIndexAccess* pFootnote = mxXEndnotes.get();
1566  static_cast<SwXFootnotes*>(pFootnote)->Invalidate();
1567  mxXEndnotes.clear();
1568  }
1569 
1570  if(mxXDocumentIndexes.is())
1571  {
1572  XIndexAccess* pIdxs = mxXDocumentIndexes.get();
1573  static_cast<SwXDocumentIndexes*>(pIdxs)->Invalidate();
1574  mxXDocumentIndexes.clear();
1575  }
1576 
1577  if(mxXStyleFamilies.is())
1578  {
1579  XNameAccess* pStyles = mxXStyleFamilies.get();
1580  static_cast<SwXStyleFamilies*>(pStyles)->Invalidate();
1581  mxXStyleFamilies.clear();
1582  }
1583  if(mxXAutoStyles.is())
1584  {
1585  XNameAccess* pStyles = mxXAutoStyles.get();
1586  static_cast<SwXAutoStyles*>(pStyles)->Invalidate();
1587  mxXAutoStyles.clear();
1588  }
1589 
1590  if(mxXBookmarks.is())
1591  {
1592  XNameAccess* pBm = mxXBookmarks.get();
1593  static_cast<SwXBookmarks*>(pBm)->Invalidate();
1594  mxXBookmarks.clear();
1595  }
1596 
1597  if(mxXChapterNumbering.is())
1598  {
1599  XIndexReplace* pCh = mxXChapterNumbering.get();
1600  static_cast<SwXChapterNumbering*>(pCh)->Invalidate();
1601  mxXChapterNumbering.clear();
1602  }
1603 
1604  if(mxXFootnoteSettings.is())
1605  {
1606  XPropertySet* pFntSet = mxXFootnoteSettings.get();
1607  static_cast<SwXFootnoteProperties*>(pFntSet)->Invalidate();
1608  mxXFootnoteSettings.clear();
1609  }
1610 
1611  if(mxXEndnoteSettings.is())
1612  {
1613  XPropertySet* pEndSet = mxXEndnoteSettings.get();
1614  static_cast<SwXEndnoteProperties*>(pEndSet)->Invalidate();
1615  mxXEndnoteSettings.clear();
1616  }
1617 
1619  {
1621  static_cast<SwXLineNumberingProperties*>(pLine)->Invalidate();
1623  }
1624  if(mxXReferenceMarks.is())
1625  {
1626  XNameAccess* pMarks = mxXReferenceMarks.get();
1627  static_cast<SwXReferenceMarks*>(pMarks)->Invalidate();
1628  mxXReferenceMarks.clear();
1629  }
1630  if(mxLinkTargetSupplier.is())
1631  {
1632  XNameAccess* pAccess = mxLinkTargetSupplier.get();
1633  static_cast<SwXLinkTargetSupplier*>(pAccess)->Invalidate();
1634  mxLinkTargetSupplier.clear();
1635  }
1636  if(mxXRedlines.is())
1637  {
1638  XEnumerationAccess* pMarks = mxXRedlines.get();
1639  static_cast<SwXRedlines*>(pMarks)->Invalidate();
1640  mxXRedlines.clear();
1641  }
1642  if(mxPropertyHelper.is())
1643  {
1644  mxPropertyHelper->Invalidate();
1645  mxPropertyHelper.clear();
1646  }
1647 }
1648 
1649 css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
1650  OUString const & rServiceName,
1651  css::uno::Sequence<css::uno::Any> const * arguments)
1652 {
1653  SolarMutexGuard aGuard;
1654  if (!IsValid())
1655  throw DisposedException("", static_cast< XTextDocument* >(this));
1656 
1658  if (nType != SwServiceType::Invalid)
1659  {
1661  }
1662  if (rServiceName == "com.sun.star.drawing.DashTable")
1663  {
1665  }
1666  if (rServiceName == "com.sun.star.drawing.GradientTable")
1667  {
1669  }
1670  if (rServiceName == "com.sun.star.drawing.HatchTable")
1671  {
1673  }
1674  if (rServiceName == "com.sun.star.drawing.BitmapTable")
1675  {
1677  }
1678  if (rServiceName == "com.sun.star.drawing.TransparencyGradientTable")
1679  {
1681  }
1682  if (rServiceName == "com.sun.star.drawing.MarkerTable")
1683  {
1685  }
1686  if (rServiceName == "com.sun.star.drawing.Defaults")
1687  {
1689  }
1690  if (rServiceName == "com.sun.star.document.Settings")
1691  {
1692  return Reference<XInterface>(*new SwXDocumentSettings(this));
1693  }
1694  if (rServiceName == "com.sun.star.document.ImportEmbeddedObjectResolver")
1695  {
1696  return static_cast<cppu::OWeakObject *>(
1698  *pDocShell, SvXMLEmbeddedObjectHelperMode::Read));
1699  }
1700  if (rServiceName == "com.sun.star.text.DocumentSettings")
1701  {
1702  return Reference<XInterface>(*new SwXDocumentSettings(this));
1703  }
1704  if (rServiceName == "com.sun.star.chart2.data.DataProvider")
1705  {
1706  return Reference<XInterface>(
1707  dynamic_cast<chart2::data::XDataProvider *>(
1709  GetChartDataProvider()));
1710  }
1711  if (!rServiceName.startsWith("com.sun.star.")
1712  || rServiceName.endsWith(".OLE2Shape"))
1713  {
1714  // We do not want to insert OLE2 Shapes (e.g.,
1715  // "com.sun.star.drawing.OLE2Shape", ...) like this (by creating them
1716  // with the documents factory and adding the shapes to the draw page);
1717  // for inserting OLE objects the proper way is to use
1718  // "com.sun.star.text.TextEmbeddedObject":
1719  throw ServiceNotRegisteredException();
1720  }
1721  // The XML import is allowed to create instances of
1722  // "com.sun.star.drawing.OLE2Shape"; thus, a temporary service name is
1723  // introduced to make this possible:
1724  OUString aTmpServiceName(rServiceName);
1725  if (rServiceName == "com.sun.star.drawing.temporaryForXMLImportOLE2Shape")
1726  {
1727  aTmpServiceName = "com.sun.star.drawing.OLE2Shape";
1728  }
1729  Reference<XInterface> xTmp(
1730  arguments == nullptr
1731  ? SvxFmMSFactory::createInstance(aTmpServiceName)
1733  aTmpServiceName, *arguments));
1734  if (rServiceName == "com.sun.star.drawing.GroupShape"
1735  || rServiceName == "com.sun.star.drawing.Shape3DSceneObject")
1736  {
1737  return *new SwXGroupShape(xTmp, pDocShell->GetDoc());
1738  }
1739  if (rServiceName.startsWith("com.sun.star.drawing."))
1740  {
1741  return *new SwXShape(xTmp, pDocShell->GetDoc());
1742  }
1743  return xTmp;
1744 }
1745 
1747 {
1748  return create(rServiceName, nullptr);
1749 }
1750 
1752  const OUString& ServiceSpecifier,
1753  const Sequence< Any >& Arguments)
1754 {
1755  return create(ServiceSpecifier, &Arguments);
1756 }
1757 
1759 {
1760  static Sequence< OUString > aServices;
1761  if ( !aServices.hasElements() )
1762  {
1764  auto i = comphelper::findValue(aRet, "com.sun.star.drawing.OLE2Shape");
1765  if (i != -1)
1766  {
1767  auto nLength = aRet.getLength();
1768  aRet[i] = aRet[nLength - 1];
1769  aRet.realloc( nLength - 1 );
1770  }
1772  aServices = comphelper::concatSequences(aRet, aOwn);
1773  }
1774 
1775  return aServices;
1776 }
1777 
1779 {
1780  return "SwXTextDocument";
1781  /* // Matching the .component information:
1782  return dynamic_cast<SwGlobalDocShell*>( pDocShell ) != nullptr
1783  ? OUString("com.sun.star.comp.Writer.GlobalDocument")
1784  : dynamic_cast<SwWebDocShell*>( pDocShell ) != nullptr
1785  ? OUString("com.sun.star.comp.Writer.WebDocument")
1786  : OUString("com.sun.star.comp.Writer.TextDocument");
1787  */
1788 }
1789 
1790 sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName)
1791 {
1792  return cppu::supportsService(this, rServiceName);
1793 }
1794 
1796 {
1797  bool bWebDoc = (dynamic_cast<SwWebDocShell*>( pDocShell) != nullptr );
1798  bool bGlobalDoc = (dynamic_cast<SwGlobalDocShell*>( pDocShell) != nullptr );
1799  bool bTextDoc = (!bWebDoc && !bGlobalDoc);
1800 
1801  Sequence< OUString > aRet (3);
1802  OUString* pArray = aRet.getArray();
1803 
1804  pArray[0] = "com.sun.star.document.OfficeDocument";
1805  pArray[1] = "com.sun.star.text.GenericTextDocument";
1806 
1807  if (bTextDoc)
1808  pArray[2] = "com.sun.star.text.TextDocument";
1809  else if (bWebDoc)
1810  pArray[2] = "com.sun.star.text.WebDocument";
1811  else if (bGlobalDoc)
1812  pArray[2] = "com.sun.star.text.GlobalDocument";
1813 
1814  return aRet;
1815 }
1816 
1817 Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes()
1818 {
1819  SolarMutexGuard aGuard;
1820  if(!IsValid())
1821  throw DisposedException("", static_cast< XTextDocument* >(this));
1822 
1823  if(!mxXDocumentIndexes.is())
1824  {
1826  }
1827  return mxXDocumentIndexes;
1828 }
1829 
1830 Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo()
1831 {
1832  static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
1833  return xRet;
1834 }
1835 
1836 void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& aValue)
1837 {
1838  SolarMutexGuard aGuard;
1839  if(!IsValid())
1840  throw DisposedException("", static_cast< XTextDocument* >(this));
1841 
1842  const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
1843 
1844  if(!pEntry)
1845  throw UnknownPropertyException();
1846  if(pEntry->nFlags & PropertyAttribute::READONLY)
1847  throw PropertyVetoException();
1848  switch(pEntry->nWID)
1849  {
1850  case WID_DOC_CHAR_COUNT :
1851  case WID_DOC_PARA_COUNT :
1852  case WID_DOC_WORD_COUNT :
1853  throw RuntimeException(
1854  "bad WID",
1855  static_cast< cppu::OWeakObject * >(
1856  static_cast< SwXTextDocumentBaseClass * >(this)));
1857  case WID_DOC_WORD_SEPARATOR :
1858  {
1859  OUString sDelim;
1860  aValue >>= sDelim;
1861  SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim);
1862  }
1863  break;
1865  case WID_DOC_CHANGES_SHOW:
1866  {
1867  bool bSet = *o3tl::doAccess<bool>(aValue);
1869  if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
1870  {
1872  if( !bSet )
1874  }
1875  else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
1876  {
1877  eMode = bSet ? eMode|RedlineFlags::On : eMode&~RedlineFlags::On;
1878  }
1880  }
1881  break;
1883  {
1884  Sequence <sal_Int8> aNew;
1885  if(aValue >>= aNew)
1886  {
1887  SwDoc* pDoc = pDocShell->GetDoc();
1889  if(aNew.hasElements())
1890  {
1892  eMode |= RedlineFlags::On;
1893  pDoc->getIDocumentRedlineAccess().SetRedlineFlags( eMode );
1894  }
1895  }
1896  }
1897  break;
1898  case WID_DOC_AUTO_MARK_URL :
1899  {
1900  OUString sURL;
1901  aValue >>= sURL;
1903  }
1904  break;
1905  case WID_DOC_HIDE_TIPS :
1906  SW_MOD()->GetModuleConfig()->SetHideFieldTips(*o3tl::doAccess<bool>(aValue));
1907  break;
1909  {
1911  eRedMode = eRedMode & (~RedlineFlags::ShowMask);
1912  sal_Int16 nSet = 0;
1913  aValue >>= nSet;
1914  switch(nSet)
1915  {
1916  case RedlineDisplayType::NONE: break;
1917  case RedlineDisplayType::INSERTED: eRedMode |= RedlineFlags::ShowInsert; break;
1918  case RedlineDisplayType::REMOVED: eRedMode |= RedlineFlags::ShowDelete; break;
1919  case RedlineDisplayType::
1920  INSERTED_AND_REMOVED: eRedMode |= RedlineFlags::ShowInsert|RedlineFlags::ShowDelete;
1921  break;
1922  default: throw IllegalArgumentException();
1923  }
1925  }
1926  break;
1928  {
1929  sal_Int16 nYear = 0;
1930  aValue >>= nYear;
1931  SfxRequest aRequest ( SID_ATTR_YEAR2000, SfxCallMode::SLOT, pDocShell->GetDoc()->GetAttrPool());
1932  aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
1933  pDocShell->Execute ( aRequest );
1934  }
1935  break;
1937  {
1938  SwDrawModel * pDrawDoc;
1939  bool bAuto = *o3tl::doAccess<bool>(aValue);
1940 
1941  if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) )
1942  pDrawDoc->SetAutoControlFocus( bAuto );
1943  else if (bAuto)
1944  {
1945  // if setting to true, and we don't have an
1946  // SdrModel, then we are changing the default and
1947  // must thus create an SdrModel, if we don't have an
1948  // SdrModel and we are leaving the default at false,
1949  // we don't need to make an SdrModel and can do nothing
1950  // #i52858# - method name changed
1952  pDrawDoc->SetAutoControlFocus ( bAuto );
1953  }
1954  }
1955  break;
1957  {
1958  SwDrawModel * pDrawDoc;
1959  bool bMode = *o3tl::doAccess<bool>(aValue);
1960 
1961  if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) )
1962  pDrawDoc->SetOpenInDesignMode( bMode );
1963  else if (!bMode)
1964  {
1965  // if setting to false, and we don't have an
1966  // SdrModel, then we are changing the default and
1967  // must thus create an SdrModel, if we don't have an
1968  // SdrModel and we are leaving the default at true,
1969  // we don't need to make an SdrModel and can do
1970  // nothing
1971  // #i52858# - method name changed
1973  pDrawDoc->SetOpenInDesignMode ( bMode );
1974  }
1975  }
1976  break;
1977  // #i42634# New property to set the bInReading
1978  // flag at the document, used during binary import
1979  case WID_DOC_LOCK_UPDATES :
1980  {
1981  SwDoc* pDoc = pDocShell->GetDoc();
1982  bool bBool (false);
1983  if( aValue >>= bBool )
1984  pDoc->SetInReading( bBool );
1985  }
1986  break;
1987  case WID_DOC_BUILDID:
1988  aValue >>= maBuildId;
1989  break;
1990 
1992  {
1993  bool bDefaultPageMode( false );
1994  aValue >>= bDefaultPageMode;
1995  pDocShell->GetDoc()->SetDefaultPageMode( bDefaultPageMode );
1996  }
1997  break;
1999  setGrabBagItem(aValue);
2000  break;
2001 
2002  default:
2003  {
2004  const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
2005  std::unique_ptr<SfxPoolItem> pNewItem(rItem.Clone());
2006  pNewItem->PutValue(aValue, pEntry->nMemberId);
2007  pDocShell->GetDoc()->SetDefault(*pNewItem);
2008  }
2009  }
2010 }
2011 
2012 Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
2013 {
2014  SolarMutexGuard aGuard;
2015  if(!IsValid())
2016  throw DisposedException("", static_cast< XTextDocument* >(this));
2017 
2018  const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
2019 
2020  if(!pEntry)
2021  throw UnknownPropertyException();
2022  Any aAny;
2023  switch(pEntry->nWID)
2024  {
2025  case WID_DOC_ISTEMPLATEID :
2026  aAny <<= pDocShell->IsTemplate();
2027  break;
2028  case WID_DOC_CHAR_COUNT :
2029  case WID_DOC_PARA_COUNT :
2030  case WID_DOC_WORD_COUNT :
2031  {
2032  const SwDocStat& rStat(pDocShell->GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( false, true ));
2033  sal_Int32 nValue;
2034  switch(pEntry->nWID)
2035  {
2036  case WID_DOC_CHAR_COUNT :nValue = rStat.nChar;break;
2037  case WID_DOC_PARA_COUNT :nValue = rStat.nPara;break;
2038  case WID_DOC_WORD_COUNT :nValue = rStat.nWord;break;
2039  }
2040  aAny <<= nValue;
2041  }
2042  break;
2043  case WID_DOC_WORD_SEPARATOR :
2044  {
2045  aAny <<= SW_MOD()->GetDocStatWordDelim();
2046  }
2047  break;
2049  case WID_DOC_CHANGES_SHOW:
2050  {
2052  bool bSet = false;
2053  if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
2054  {
2056  }
2057  else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
2058  {
2059  bSet = bool(eMode & RedlineFlags::On);
2060  }
2061  aAny <<= bSet;
2062  }
2063  break;
2065  {
2066  SwDoc* pDoc = pDocShell->GetDoc();
2067  aAny <<= pDoc->getIDocumentRedlineAccess().GetRedlinePassword();
2068  }
2069  break;
2070  case WID_DOC_AUTO_MARK_URL :
2071  aAny <<= pDocShell->GetDoc()->GetTOIAutoMarkURL();
2072  break;
2073  case WID_DOC_HIDE_TIPS :
2074  aAny <<= SW_MOD()->GetModuleConfig()->IsHideFieldTips();
2075  break;
2077  {
2079  eRedMode = eRedMode & RedlineFlags::ShowMask;
2080  sal_Int16 nRet = RedlineDisplayType::NONE;
2081  if(RedlineFlags::ShowInsert == eRedMode)
2083  else if(RedlineFlags::ShowDelete == eRedMode)
2084  nRet = RedlineDisplayType::REMOVED;
2085  else if(RedlineFlags::ShowMask == eRedMode)
2086  nRet = RedlineDisplayType::INSERTED_AND_REMOVED;
2087  aAny <<= nRet;
2088  }
2089  break;
2091  {
2093  Reference<XForbiddenCharacters> xRet(static_cast<cppu::OWeakObject*>(mxPropertyHelper.get()), UNO_QUERY);
2094  aAny <<= xRet;
2095  }
2096  break;
2098  {
2099  aAny <<= static_cast < sal_Int16 > (pDocShell->GetDoc()->GetNumberFormatter ()->GetYear2000());
2100  }
2101  break;
2103  {
2104  SwDrawModel * pDrawDoc;
2105  bool bAuto;
2106  if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) )
2107  bAuto = pDrawDoc->GetAutoControlFocus();
2108  else
2109  bAuto = false;
2110  aAny <<= bAuto;
2111  }
2112  break;
2114  {
2115  SwDrawModel * pDrawDoc;
2116  bool bMode;
2117  if ( nullptr != ( pDrawDoc = pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel() ) )
2118  bMode = pDrawDoc->GetOpenInDesignMode();
2119  else
2120  bMode = true;
2121  aAny <<= bMode;
2122  }
2123  break;
2125  aAny <<= pDocShell->GetBasicContainer();
2126  break;
2128  aAny <<= pDocShell->GetDialogContainer();
2129  break;
2130  case WID_DOC_VBA_DOCOBJ:
2131  {
2132  /* #i111553# This property provides the name of the constant that
2133  will be used to store this model in the global Basic manager.
2134  That constant will be equivalent to 'ThisComponent' but for
2135  each application, so e.g. a 'ThisExcelDoc' and a 'ThisWordDoc'
2136  constant can co-exist, as required by VBA. */
2137  aAny <<= OUString( "ThisWordDoc" );
2138  }
2139  break;
2140  case WID_DOC_RUNTIME_UID:
2141  aAny <<= getRuntimeUID();
2142  break;
2143  case WID_DOC_LOCK_UPDATES :
2144  aAny <<= pDocShell->GetDoc()->IsInReading();
2145  break;
2146  case WID_DOC_BUILDID:
2147  aAny <<= maBuildId;
2148  break;
2150  aAny <<= hasValidSignatures();
2151  break;
2153  getGrabBagItem(aAny);
2154  break;
2155 
2156  default:
2157  {
2158  const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
2159  rItem.QueryValue(aAny, pEntry->nMemberId);
2160  }
2161  }
2162  return aAny;
2163 }
2164 
2165 void SwXTextDocument::addPropertyChangeListener(const OUString& /*PropertyName*/,
2166  const Reference< XPropertyChangeListener > & /*aListener*/)
2167 {
2168  OSL_FAIL("not implemented");
2169 }
2170 
2171 void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/,
2172  const Reference< XPropertyChangeListener > & /*aListener*/)
2173 {
2174  OSL_FAIL("not implemented");
2175 }
2176 
2177 void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/,
2178  const Reference< XVetoableChangeListener > & /*aListener*/)
2179 {
2180  OSL_FAIL("not implemented");
2181 }
2182 
2183 void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/,
2184  const Reference< XVetoableChangeListener > & /*aListener*/)
2185 {
2186  OSL_FAIL("not implemented");
2187 }
2188 
2190 {
2191  if(!mxLinkTargetSupplier.is())
2192  {
2194  }
2195  return mxLinkTargetSupplier;
2196 }
2197 
2198 Reference< XEnumerationAccess > SwXTextDocument::getRedlines( )
2199 {
2200  if(!mxXRedlines.is())
2201  {
2203  }
2204  return mxXRedlines;
2205 }
2206 
2208 {
2209  // why does SwBaseShell not just call refresh? maybe because it's rSh is
2210  // (sometimes) a different shell than GetWrtShell()?
2211  lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
2212  m_pImpl->m_RefreshListeners.notifyEach(
2213  & util::XRefreshListener::refreshed, ev);
2214 }
2215 
2217 {
2218  SolarMutexGuard aGuard;
2219  if(!IsValid())
2220  throw DisposedException("", static_cast< XTextDocument* >(this));
2221 
2222  SwViewShell *pViewShell = pDocShell->GetWrtShell();
2224  if(pViewShell)
2225  pViewShell->CalcLayout();
2226 }
2227 
2229  const Reference<util::XRefreshListener> & xListener)
2230 {
2231  // no need to lock here as m_pImpl is const and container threadsafe
2232  m_pImpl->m_RefreshListeners.addInterface(xListener);
2233 }
2234 
2236  const Reference<util::XRefreshListener> & xListener)
2237 {
2238  // no need to lock here as m_pImpl is const and container threadsafe
2239  m_pImpl->m_RefreshListeners.removeInterface(xListener);
2240 }
2241 
2243 {
2244  SolarMutexGuard aGuard;
2245  if(!IsValid())
2246  throw DisposedException("", static_cast< XTextDocument* >(this));
2247 
2248  SwDoc* pDoc = pDocShell->GetDoc();
2250  if( !rLnkMan.GetLinks().empty() )
2251  {
2252  UnoActionContext aAction(pDoc);
2253  rLnkMan.UpdateAllLinks( false, true, nullptr );
2254  }
2255 }
2256 
2257 //XPropertyState
2258 PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName )
2259 {
2260  SolarMutexGuard aGuard;
2261  if(!IsValid())
2262  throw DisposedException("", static_cast< XTextDocument* >(this));
2263 
2264  const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
2265  if(!pEntry)
2266  throw UnknownPropertyException();
2267  return PropertyState_DIRECT_VALUE;
2268 }
2269 
2270 Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames )
2271 {
2272  const sal_Int32 nCount = rPropertyNames.getLength();
2273  Sequence < PropertyState > aRet ( nCount );
2274 
2275  std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.begin(),
2276  [this](const OUString& rName) -> PropertyState { return getPropertyState(rName); });
2277 
2278  return aRet;
2279 }
2280 
2281 void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName )
2282 {
2283  SolarMutexGuard aGuard;
2284  if(!IsValid())
2285  throw DisposedException("", static_cast< XTextDocument* >(this));
2286 
2287  const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
2288  if(!pEntry)
2289  throw UnknownPropertyException();
2290  switch(pEntry->nWID)
2291  {
2292  case 0:default:break;
2293  }
2294 }
2295 
2296 Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName )
2297 {
2298  SolarMutexGuard aGuard;
2299  if(!IsValid())
2300  throw DisposedException("", static_cast< XTextDocument* >(this));
2301 
2302  const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName);
2303  if(!pEntry)
2304  throw UnknownPropertyException();
2305  Any aAny;
2306  switch(pEntry->nWID)
2307  {
2308  case 0:default:break;
2309  }
2310  return aAny;
2311 }
2312 
2314 {
2316 
2317  uno::Any aAny( rPrintUIOptions.getValue( "RenderDevice" ));
2318  uno::Reference< awt::XDevice > xRenderDevice;
2319  aAny >>= xRenderDevice;
2320  if (xRenderDevice.is())
2321  {
2322  VCLXDevice* pDevice = comphelper::getUnoTunnelImplementation<VCLXDevice>( xRenderDevice );
2323  pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
2324  }
2325 
2326  return pOut;
2327 }
2328 
2330  const uno::Sequence< beans::PropertyValue >& rOptions,
2331  const sal_Char *pPropName )
2332 {
2333  return std::any_of(rOptions.begin(), rOptions.end(),
2334  [&pPropName](const beans::PropertyValue& rProp) {
2335  return rProp.Name.equalsAscii( pPropName ); });
2336 }
2337 
2339  const uno::Sequence< beans::PropertyValue >& rOptions,
2340  const sal_Char *pPropName )
2341 {
2342  bool bRes = false;
2343  auto pOption = std::find_if(rOptions.begin(), rOptions.end(),
2344  [&pPropName](const beans::PropertyValue& rProp) {
2345  return rProp.Name.equalsAscii( pPropName ); });
2346  if (pOption != rOptions.end())
2347  pOption->Value >>= bRes;
2348  return bRes;
2349 }
2350 
2352  bool &rbIsSwSrcView,
2353  const uno::Sequence< beans::PropertyValue >& rOptions,
2354  bool bIsPDFExport )
2355 {
2356  // get view shell to use
2357  SfxViewShell *pView = nullptr;
2358  if (bIsPDFExport)
2359  pView = GuessViewShell( rbIsSwSrcView );
2360  else
2361  {
2362  uno::Any aTmp;
2363  auto pOption = std::find_if(rOptions.begin(), rOptions.end(),
2364  [](const beans::PropertyValue& rProp) { return rProp.Name == "View"; });
2365  if (pOption != rOptions.end())
2366  aTmp = pOption->Value;
2367 
2368  uno::Reference< frame::XController > xController;
2369  if (aTmp >>= xController)
2370  {
2371  OSL_ENSURE( xController.is(), "controller is empty!" );
2372  pView = GuessViewShell( rbIsSwSrcView, xController );
2373  }
2374  }
2375  return pView;
2376 }
2377 
2378 /*
2379  * GetRenderDoc:
2380  * returns the document to be rendered, usually this will be the 'regular'
2381  * document but in case of PDF export of (multi-)selection it will
2382  * be a temporary document that gets created if not already done.
2383  * The rpView variable will be set (if not already done) to the used
2384  * SfxViewShell.
2385 */
2387  SfxViewShell *&rpView,
2388  const uno::Any& rSelection,
2389  bool bIsPDFExport )
2390 {
2391  SwDoc *pDoc = nullptr;
2392 
2393  uno::Reference< frame::XModel > xModel;
2394  rSelection >>= xModel;
2395  if (xModel == pDocShell->GetModel())
2396  pDoc = pDocShell->GetDoc();
2397  else
2398  {
2399  OSL_ENSURE( !xModel.is(), "unexpected model found" );
2400 
2401  if (rSelection.hasValue()) // is anything selected ?
2402  {
2403  // this part should only be called when a temporary document needs to be created,
2404  // for example for PDF export or printing of (multi-)selection only.
2405 
2406  if (!rpView)
2407  {
2408  bool bIsSwSrcView = false;
2409  // aside from maybe PDF export the view should always have been provided!
2410  OSL_ENSURE( bIsPDFExport, "view is missing, guessing one..." );
2411 
2412  rpView = GuessViewShell( bIsSwSrcView );
2413  }
2414  OSL_ENSURE( rpView, "SwViewShell missing" );
2415  // the view shell should be SwView for documents PDF export.
2416  // for the page preview no selection should be possible
2417  // (the export dialog does not allow for this option)
2418  if (auto pSwView = dynamic_cast<SwView *>( rpView ))
2419  {
2420  if (!m_pRenderData)
2421  {
2422  OSL_FAIL("GetRenderDoc: no renderdata");
2423  return nullptr;
2424  }
2425  SfxObjectShellLock xDocSh(m_pRenderData->GetTempDocShell());
2426  if (!xDocSh.Is())
2427  {
2428  xDocSh = pSwView->CreateTmpSelectionDoc();
2429  m_pRenderData->SetTempDocShell(xDocSh);
2430  }
2431  if (xDocSh.Is())
2432  {
2433  pDoc = static_cast<SwDocShell*>(&xDocSh)->GetDoc();
2434  rpView = pDoc->GetDocShell()->GetView();
2435  }
2436  }
2437  else
2438  {
2439  OSL_FAIL("unexpected SwViewShell" );
2440  }
2441  }
2442  }
2443  return pDoc;
2444 }
2445 
2447  SwDoc &rDoc,
2448  const SwPrintUIOptions &rPrintUIOptions,
2449  bool bIsPDFEXport )
2450 {
2451  SwPrintData aDocPrintData( rDoc.getIDocumentDeviceAccess().getPrintData() );
2452 
2453  aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() );
2454  aDocPrintData.SetPrintTable( true ); // for now it was decided that tables should always be printed
2455  aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() );
2456  aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() );
2457  aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() );
2458  aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() );
2459  aDocPrintData.SetPrintReverse( false ); /*handled by print dialog now*/
2460  aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() );
2461  aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) );
2462  aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() );
2463  aDocPrintData.SetPrintProspect( rPrintUIOptions.IsPrintProspect() );
2464  aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() );
2465  aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() );
2466  aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() );
2467  // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself
2468  // arDocPrintData.SetFaxName( s ); n/a in File/Print dialog
2469  aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() );
2470  aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() );
2471 
2472  rDoc.getIDocumentDeviceAccess().setPrintData( aDocPrintData );
2473 }
2474 
2476  const uno::Any& rSelection,
2477  const uno::Sequence< beans::PropertyValue >& rxOptions )
2478 {
2479  SolarMutexGuard aGuard;
2480  if(!IsValid())
2481  {
2482  throw DisposedException( OUString(),
2483  static_cast< XTextDocument* >(this) );
2484  }
2485 
2486  const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
2487  bool bIsSwSrcView = false;
2488  SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2489 
2490  if (!bIsSwSrcView && !m_pRenderData)
2491  m_pRenderData.reset(new SwRenderData);
2492  if (!m_pPrintUIOptions)
2494  bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions );
2495 
2496  SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2497  OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2498  if (!pDoc || !pView)
2499  return 0;
2500 
2501  // save current UI options from the print dialog for the next call to that dialog
2503 
2504  sal_Int32 nRet = 0;
2505  if (bIsSwSrcView)
2506  {
2507  SwSrcView& rSwSrcView = dynamic_cast<SwSrcView&>(*pView);
2509  nRet = rSwSrcView.PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ );
2510  }
2511  else
2512  {
2513  SwDocShell *pRenderDocShell = pDoc->GetDocShell();
2514 
2515  // TODO/mba: we really need a generic way to get the SwViewShell!
2516  SwViewShell* pViewShell = nullptr;
2517  SwView* pSwView = dynamic_cast<SwView*>( pView );
2518  if ( pSwView )
2519  {
2520  pViewShell = pSwView->GetWrtShellPtr();
2521  }
2522  else
2523  {
2524  if ( bIsPDFExport && bFormat )
2525  {
2526  //create a hidden view to be able to export as PDF also in print preview
2527  //pView and pSwView are not changed intentionally!
2529  pViewShell = static_cast<SwView*>(m_pHiddenViewFrame->GetViewShell())->GetWrtShellPtr();
2530  }
2531  else
2532  pViewShell = static_cast<SwPagePreview*>(pView)->GetViewShell();
2533  }
2534 
2535  if (!pViewShell || !pViewShell->GetLayout())
2536  return 0;
2537 
2538  if (bFormat)
2539  {
2540  // #i38289
2541  if( pViewShell->GetViewOptions()->getBrowseMode() ||
2542  pViewShell->GetViewOptions()->IsWhitespaceHidden() )
2543  {
2544  SwViewOption aOpt( *pViewShell->GetViewOptions() );
2545  aOpt.setBrowseMode( false );
2546  aOpt.SetHideWhitespaceMode( false );
2547  pViewShell->ApplyViewOptions( aOpt );
2548  if (pSwView)
2549  {
2550  pSwView->RecheckBrowseMode();
2551  }
2552  }
2553 
2554  // reformatting the document for printing will show the changes in the view
2555  // which is likely to produce many unwanted and not nice to view actions.
2556  // We don't want that! Thus we disable updating of the view.
2557  pViewShell->StartAction();
2558 
2559  if (pSwView)
2560  {
2561  if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) )
2562  m_pRenderData->ViewOptionAdjustStop();
2563  if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust())
2564  {
2565  m_pRenderData->ViewOptionAdjustStart(
2566  *pViewShell, *pViewShell->GetViewOptions() );
2567  }
2568  }
2569 
2570  m_pRenderData->MakeSwPrtOptions( pRenderDocShell,
2571  m_pPrintUIOptions.get(), bIsPDFExport );
2572 
2573  if (pSwView)
2574  {
2575  // PDF export should not make use of the SwPrtOptions
2576  const SwPrintData *pPrtOptions = bIsPDFExport
2577  ? nullptr : m_pRenderData->GetSwPrtOptions();
2578  bool setShowPlaceHoldersInPDF = false;
2579  if(bIsPDFExport)
2580  setShowPlaceHoldersInPDF = lcl_GetBoolProperty( rxOptions, "ExportPlaceholders" );
2581  m_pRenderData->ViewOptionAdjust( pPrtOptions, setShowPlaceHoldersInPDF );
2582  }
2583 
2584  // since printing now also use the API for PDF export this option
2585  // should be set for printing as well ...
2586  pViewShell->SetPDFExportOption( true );
2587 
2588  // there is some redundancy between those two function calls, but right now
2589  // there is no time to sort this out.
2590  //TODO: check what exactly needs to be done and make just one function for that
2591  pViewShell->CalcLayout();
2592  pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );
2593 
2594 
2595  // #122919# Force field update before PDF export, but after layout init (tdf#121962)
2596  bool bStateChanged = false;
2597  // check configuration: shall update of printing information in DocInfo set the document to "modified"?
2599  {
2600  pRenderDocShell->EnableSetModified( false );
2601  bStateChanged = true;
2602  }
2603  pViewShell->SwViewShell::UpdateFields(true);
2604  if( bStateChanged )
2605  pRenderDocShell->EnableSetModified();
2606 
2607  pViewShell->SetPDFExportOption( false );
2608 
2609  // enable view again
2610  pViewShell->EndAction();
2611  }
2612 
2613  const sal_Int32 nPageCount = pViewShell->GetPageCount();
2614 
2615  // get number of pages to be rendered
2616 
2617  const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect" );
2618  if (bPrintProspect)
2619  {
2621  nRet = m_pRenderData->GetPagePairsForProspectPrinting().size();
2622  }
2623  else
2624  {
2625  const SwPostItMode nPostItMode = static_cast<SwPostItMode>( m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 ) );
2626  if (nPostItMode != SwPostItMode::NONE)
2627  {
2629  m_pRenderData->CreatePostItData( pDoc, pViewShell->GetViewOptions(), pOutDev );
2630  }
2631 
2632  // get set of valid document pages (according to the current settings)
2633  // and their start frames
2634  SwDoc::CalculatePagesForPrinting( *pViewShell->GetLayout(), *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount );
2635 
2636  if (nPostItMode != SwPostItMode::NONE)
2637  {
2639  *m_pPrintUIOptions, nPageCount );
2640  }
2641 
2642  nRet = m_pRenderData->GetPagesToPrint().size();
2643  }
2644  }
2645  OSL_ENSURE( nRet >= 0, "negative number of pages???" );
2646 
2647  return nRet;
2648 }
2649 
2650 uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
2651  sal_Int32 nRenderer,
2652  const uno::Any& rSelection,
2653  const uno::Sequence< beans::PropertyValue >& rxOptions )
2654 {
2655  SolarMutexGuard aGuard;
2656  if(!IsValid())
2657  {
2658  throw DisposedException("", static_cast< XTextDocument* >(this));
2659  }
2660 
2661  const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
2662  bool bIsSwSrcView = false;
2663  SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2664 
2665  // m_pRenderData should NOT be created here!
2666  // That should only be done in getRendererCount. If this function is called before
2667  // getRendererCount was called then the caller will probably just retrieve the extra UI options
2668  // and is not interested in getting valid information about the other data that would
2669  // otherwise be provided here!
2670 // if( ! m_pRenderData )
2671 // m_pRenderData = new SwRenderData;
2672  if (!m_pPrintUIOptions)
2674  m_pPrintUIOptions->processProperties( rxOptions );
2675  const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect" );
2676  const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
2677  const bool bPrintPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup" );
2678 
2679  SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2680  OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2681  if (!pDoc || !pView)
2682  return uno::Sequence< beans::PropertyValue >();
2683 
2684  // due to #110067# (document page count changes sometimes during
2685  // PDF export/printing) we can not check for the upper bound properly.
2686  // Thus instead of throwing the exception we silently return.
2687  if (0 > nRenderer)
2688  throw IllegalArgumentException();
2689 
2690  // TODO/mba: we really need a generic way to get the SwViewShell!
2691  SwViewShell* pVwSh = nullptr;
2692  SwView* pSwView = dynamic_cast<SwView*>( pView );
2693  if ( pSwView )
2694  pVwSh = pSwView->GetWrtShellPtr();
2695  else
2696  pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell();
2697 
2698  sal_Int32 nMaxRenderer = 0;
2699  if (!bIsSwSrcView && m_pRenderData)
2700  {
2701  OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
2702  nMaxRenderer = bPrintProspect?
2703  m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
2704  m_pRenderData->GetPagesToPrint().size() - 1;
2705  }
2706  // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
2707  // we obmit checking of the upper bound in this case.
2708  if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer)
2709  return uno::Sequence< beans::PropertyValue >();
2710 
2711  uno::Sequence< beans::PropertyValue > aRenderer;
2712  if (m_pRenderData)
2713  {
2714  // #i114210#
2715  // determine the correct page number from the renderer index
2716  // #i114875
2717  // consider brochure print
2718  const sal_Int32 nPage = bPrintProspect
2719  ? nRenderer + 1
2720  : m_pRenderData->GetPagesToPrint()[ nRenderer ];
2721 
2722  // get paper tray to use ...
2723  sal_Int32 nPrinterPaperTray = -1;
2724  if (! bPrintPaperFromSetup)
2725  {
2726  // ... from individual page style (see the page tab in Format/Page dialog)
2727  const std::map< sal_Int32, sal_Int32 > &rPaperTrays = m_pRenderData->GetPrinterPaperTrays();
2728  std::map< sal_Int32, sal_Int32 >::const_iterator aIt( rPaperTrays.find( nPage ) );
2729  if (aIt != rPaperTrays.end())
2730  nPrinterPaperTray = aIt->second;
2731  }
2732 
2733  awt::Size aPageSize;
2734  awt::Point aPagePos;
2735  awt::Size aPreferredPageSize;
2736  Size aTmpSize;
2737  if (bIsSwSrcView || bPrintProspect)
2738  {
2739  // for printing of HTML source code and prospect printing we should use
2740  // the printers paper size since
2741  // a) HTML source view has no page size
2742  // b) prospect printing has a different page size from the documents page
2743  // since two document pages will get rendered on one printer page
2744 
2745  // since PageIncludesNonprintableArea will be set to true we can return the
2746  // printers paper size here.
2747  // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this
2748  // case we won't get an OutputDevice here, but then the caller also has no need
2749  // for the correct PageSisze right now...
2750  VclPtr< Printer > pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions ).get());
2751  if (pPrinter)
2752  {
2753  // HTML source view and prospect adapt to the printer's paper size
2754  aTmpSize = pPrinter->GetPaperSize();
2755  aTmpSize = OutputDevice::LogicToLogic( aTmpSize,
2756  pPrinter->GetMapMode(), MapMode( MapUnit::Map100thMM ));
2757  aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() );
2758  #if 0
2759  // #i115048# it seems users didn't like getting double the formatted page size
2760  // revert to "old" behavior scaling to the current paper size of the printer
2761  if (bPrintProspect)
2762  {
2763  // we just state what output size we would need
2764  // which may cause vcl to set that page size on the printer
2765  // (if available and not overridden by the user)
2766  aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
2767  aPreferredPageSize = awt::Size ( convertTwipToMm100( 2 * aTmpSize.Width() ),
2768  convertTwipToMm100( aTmpSize.Height() ));
2769  }
2770  #else
2771  if( bPrintProspect )
2772  {
2773  // just switch to an appropriate portrait/landscape format
2774  // FIXME: brochure printing with landscape pages puts the
2775  // pages next to each other, so landscape is currently always
2776  // the better choice
2777  if( aPageSize.Width < aPageSize.Height )
2778  {
2779  aPreferredPageSize.Width = aPageSize.Height;
2780  aPreferredPageSize.Height = aPageSize.Width;
2781  }
2782  }
2783  #endif
2784  }
2785  }
2786  else
2787  {
2788  aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
2789  aPageSize = awt::Size ( convertTwipToMm100( aTmpSize.Width() ),
2790  convertTwipToMm100( aTmpSize.Height() ));
2791  Point aPoint = pVwSh->GetPagePos(nPage);
2792  aPagePos = awt::Point(convertTwipToMm100(aPoint.X()), convertTwipToMm100(aPoint.Y()));
2793  }
2794 
2795  sal_Int32 nLen = 3;
2796  aRenderer.realloc(3);
2797  aRenderer[0].Name = "PageSize";
2798  aRenderer[0].Value <<= aPageSize;
2799  aRenderer[1].Name = "PageIncludesNonprintableArea";
2800  aRenderer[1].Value <<= true;
2801  aRenderer[2].Name = "PagePos";
2802  aRenderer[2].Value <<= aPagePos;
2803  if (aPreferredPageSize.Width && aPreferredPageSize.Height)
2804  {
2805  ++nLen;
2806  aRenderer.realloc( nLen );
2807  aRenderer[ nLen - 1 ].Name = "PreferredPageSize";
2808  aRenderer[ nLen - 1 ].Value <<= aPreferredPageSize;
2809  }
2810  if (nPrinterPaperTray >= 0)
2811  {
2812  ++nLen;
2813  aRenderer.realloc( nLen );
2814  aRenderer[ nLen - 1 ].Name = "PrinterPaperTray";
2815  aRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray;
2816  }
2817  }
2818 
2819  // #i117783#
2821  {
2822  const SwPagePreviewPrtData* pPagePrintSettings =
2824  if ( pPagePrintSettings &&
2825  ( pPagePrintSettings->GetRow() > 1 ||
2826  pPagePrintSettings->GetCol() > 1 ) )
2827  {
2828  // extend render data by page print settings attributes
2829  sal_Int32 nLen = aRenderer.getLength();
2830  const sal_Int32 nRenderDataIdxStart = nLen;
2831  nLen += 9;
2832  aRenderer.realloc( nLen );
2833  // put page print settings attribute into render data
2834  const sal_Int32 nRow = pPagePrintSettings->GetRow();
2835  aRenderer[ nRenderDataIdxStart + 0 ].Name = "NUpRows";
2836  aRenderer[ nRenderDataIdxStart + 0 ].Value <<= std::max<sal_Int32>( nRow, 1);
2837  const sal_Int32 nCol = pPagePrintSettings->GetCol();
2838  aRenderer[ nRenderDataIdxStart + 1 ].Name = "NUpColumns";
2839  aRenderer[ nRenderDataIdxStart + 1 ].Value <<= std::max<sal_Int32>( nCol, 1);
2840  aRenderer[ nRenderDataIdxStart + 2 ].Name = "NUpPageMarginLeft";
2841  aRenderer[ nRenderDataIdxStart + 2 ].Value <<= pPagePrintSettings->GetLeftSpace();
2842  aRenderer[ nRenderDataIdxStart + 3 ].Name = "NUpPageMarginRight";
2843  aRenderer[ nRenderDataIdxStart + 3 ].Value <<= pPagePrintSettings->GetRightSpace();
2844  aRenderer[ nRenderDataIdxStart + 4 ].Name = "NUpPageMarginTop";
2845  aRenderer[ nRenderDataIdxStart + 4 ].Value <<= pPagePrintSettings->GetTopSpace();
2846  aRenderer[ nRenderDataIdxStart + 5 ].Name = "NUpPageMarginBottom";
2847  aRenderer[ nRenderDataIdxStart + 5 ].Value <<= pPagePrintSettings->GetBottomSpace();
2848  aRenderer[ nRenderDataIdxStart + 6 ].Name = "NUpHorizontalSpacing";
2849  aRenderer[ nRenderDataIdxStart + 6 ].Value <<= pPagePrintSettings->GetHorzSpace();
2850  aRenderer[ nRenderDataIdxStart + 7 ].Name = "NUpVerticalSpacing";
2851  aRenderer[ nRenderDataIdxStart + 7 ].Value <<= pPagePrintSettings->GetVertSpace();
2852  {
2853  Printer* pPrinter = pDocShell->GetDoc()->getIDocumentDeviceAccess().getPrinter( false );
2854  if ( pPrinter )
2855  {
2856  awt::Size aNewPageSize;
2857  const Size aPageSize = pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
2858  aNewPageSize = awt::Size( aPageSize.Width(), aPageSize.Height() );
2859  if ( ( pPagePrintSettings->GetLandscape() &&
2860  aPageSize.Width() < aPageSize.Height() ) ||
2861  ( !pPagePrintSettings->GetLandscape() &&
2862  aPageSize.Width() > aPageSize.Height() ) )
2863  {
2864  aNewPageSize = awt::Size( aPageSize.Height(), aPageSize.Width() );
2865  }
2866  aRenderer[ nRenderDataIdxStart + 8 ].Name = "NUpPaperSize";
2867  aRenderer[ nRenderDataIdxStart + 8 ].Value <<= aNewPageSize;
2868  }
2869  }
2870  }
2871 
2873  }
2874 
2875  m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
2876 
2877  return aRenderer;
2878 }
2879 
2881  /* out */ bool &rbIsSwSrcView,
2882  const uno::Reference< css::frame::XController >& rController )
2883 {
2884  // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell()
2885  // must not be used (see comment from MBA)
2886 
2887  SfxViewShell *pView = nullptr;
2888  SwView *pSwView = nullptr;
2889  SwPagePreview *pSwPagePreview = nullptr;
2890  SwSrcView *pSwSrcView = nullptr;
2891  SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, false );
2892 
2893  // look for the view shell with the same controller in use,
2894  // otherwise look for a suitable view, preferably a SwView,
2895  // if that one is not found use a SwPagePreview if found.
2896  while (pFrame)
2897  {
2898  pView = pFrame->GetViewShell();
2899  pSwView = dynamic_cast< SwView * >(pView);
2900  pSwSrcView = dynamic_cast< SwSrcView * >(pView);
2901  if (!pSwPagePreview)
2902  pSwPagePreview = dynamic_cast< SwPagePreview * >(pView);
2903  if (rController.is())
2904  {
2905  if (pView && pView->GetController() == rController)
2906  break;
2907  }
2908  else if (pSwView || pSwSrcView)
2909  break;
2910  pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, false );
2911  }
2912 
2913  OSL_ENSURE( pSwView || pSwPagePreview || pSwSrcView, "failed to get view shell" );
2914  if (pView)
2915  rbIsSwSrcView = pSwSrcView != nullptr;
2916  return pView;
2917 }
2918 
2920  sal_Int32 nRenderer,
2921  const uno::Any& rSelection,
2922  const uno::Sequence< beans::PropertyValue >& rxOptions )
2923 {
2924  SolarMutexGuard aGuard;
2925  if(!IsValid())
2926  {
2927  throw DisposedException( OUString(),
2928  static_cast< XTextDocument* >(this) );
2929  }
2930 
2931  // due to #110067# (document page count changes sometimes during
2932  // PDF export/printing) we can not check for the upper bound properly.
2933  // Thus instead of throwing the exception we silently return.
2934  if (0 > nRenderer)
2935  throw IllegalArgumentException();
2936 
2937  const bool bHasPDFExtOutDevData = lcl_SeqHasProperty( rxOptions, "HasPDFExtOutDevData" );
2938  const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" ) || bHasPDFExtOutDevData;
2939  bool bIsSwSrcView = false;
2940  SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
2941 
2942  OSL_ENSURE( m_pRenderData, "data should have been created already in getRendererCount..." );
2943  OSL_ENSURE( m_pPrintUIOptions, "data should have been created already in getRendererCount..." );
2944  if (!bIsSwSrcView && !m_pRenderData)
2945  m_pRenderData.reset(new SwRenderData);
2946  if (!m_pPrintUIOptions)
2948  m_pPrintUIOptions->processProperties( rxOptions );
2949  const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect" );
2950  const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage" );
2951 
2952  SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
2953  OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
2954  if (pDoc && pView)
2955  {
2956  sal_Int32 nMaxRenderer = 0;
2957  if (!bIsSwSrcView)
2958  {
2959  OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
2960  nMaxRenderer = bPrintProspect?
2961  m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
2962  m_pRenderData->GetPagesToPrint().size() - 1;
2963  }
2964  // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
2965  // we obmit checking of the upper bound in this case.
2966  if (bIsSwSrcView || nRenderer <= nMaxRenderer)
2967  {
2968  if (bIsSwSrcView)
2969  {
2970  SwSrcView& rSwSrcView = dynamic_cast<SwSrcView&>(*pView);
2972  rSwSrcView.PrintSource(pOutDev, nRenderer + 1, false);
2973  }
2974  else
2975  {
2976  // the view shell should be SwView for documents PDF export
2977  // or SwPagePreview for PDF export of the page preview
2978  SwViewShell* pVwSh = nullptr;
2979  // TODO/mba: we really need a generic way to get the SwViewShell!
2980  const SwView* pSwView = dynamic_cast<const SwView*>(pView);
2981  if (pSwView)
2982  pVwSh = pSwView->GetWrtShellPtr();
2983  else
2984  pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell();
2985 
2986  // get output device to use
2988 
2989  if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
2990  {
2991  const OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange" );
2992  const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage" );
2993  bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
2994 
2995  OSL_ENSURE((pSwView && m_pRenderData->IsViewOptionAdjust())
2996  || (!pSwView && !m_pRenderData->IsViewOptionAdjust()),
2997  "SwView / SwViewOptionAdjust_Impl availability mismatch" );
2998 
2999  // since printing now also use the API for PDF export this option
3000  // should be set for printing as well ...
3001  pVwSh->SetPDFExportOption( true );
3002 
3003  // #i12836# enhanced pdf export
3004 
3005  // First, we have to export hyperlinks, notes, and outline to pdf.
3006  // During this process, additional information required for tagging
3007  // the pdf file are collected, which are evaulated during painting.
3008 
3009  SwWrtShell* pWrtShell = pSwView ? pSwView->GetWrtShellPtr() : nullptr;
3010 
3011  SwPrintData const& rSwPrtOptions =
3012  *m_pRenderData->GetSwPrtOptions();
3013 
3014  if (bIsPDFExport && (bFirstPage || bHasPDFExtOutDevData) && pWrtShell)
3015  {
3016  SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, false, rSwPrtOptions );
3017  }
3018 
3019  if (bPrintProspect)
3020  pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer );
3021  else // normal printing and PDF export
3022  pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer, bIsPDFExport );
3023 
3024  // #i35176#
3025 
3026  // After printing the last page, we take care for the links coming
3027  // from the EditEngine. The links are generated during the painting
3028  // process, but the destinations are still missing.
3029 
3030  if (bIsPDFExport && bLastPage && pWrtShell)
3031  {
3032  SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, true, rSwPrtOptions );
3033  }
3034 
3035  pVwSh->SetPDFExportOption( false );
3036 
3037  // last page to be rendered? (not necessarily the last page of the document)
3038  // -> do clean-up of data
3039  if (bLastPage)
3040  {
3041  // #i96167# haggai: delete ViewOptionsAdjust here because it makes use
3042  // of the shell, which might get destroyed in lcl_DisposeView!
3043  if (m_pRenderData->IsViewOptionAdjust())
3044  m_pRenderData->ViewOptionAdjustStop();
3045 
3046  if (m_pRenderData->HasPostItData())
3047  m_pRenderData->DeletePostItData();
3048  if (m_pHiddenViewFrame)
3049  {
3051  m_pHiddenViewFrame = nullptr;
3052 
3053  // prevent crash described in #i108805
3054  SwDocShell *pRenderDocShell = pDoc->GetDocShell();
3055  SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet();
3056  pSet->Put( SfxBoolItem( SID_HIDDEN, false ) );
3057 
3058  }
3059  }
3060  }
3061  }
3062  }
3063  }
3064  if( bLastPage )
3065  {
3066  m_pRenderData.reset();
3067  m_pPrintUIOptions.reset();
3068  }
3069 }
3070 
3071 // xforms::XFormsSupplier
3073 {
3074  SolarMutexGuard aGuard;
3075  if ( !pDocShell )
3076  throw DisposedException( OUString(), static_cast< XTextDocument* >( this ) );
3077  SwDoc* pDoc = pDocShell->GetDoc();
3078  return pDoc->getXForms();
3079 }
3080 
3081 uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
3082 {
3083  SolarMutexGuard aGuard;
3084  if (!IsValid())
3085  {
3086  throw DisposedException("SwXTextDocument not valid",
3087  static_cast<XTextDocument*>(this));
3088  }
3089 
3091  *pDocShell->GetDoc(), nTextMarkupType, bAutomatic);
3092 }
3093 
3094 uno::Reference< util::XCloneable > SwXTextDocument::createClone( )
3095 {
3096  SolarMutexGuard aGuard;
3097  if(!IsValid())
3098  throw DisposedException("", static_cast< XTextDocument* >(this));
3099 
3100  // create a new document - hidden - copy the storage and return it
3101  // SfxObjectShellRef is used here, since the model should control object lifetime after creation
3102  // and thus SfxObjectShellLock is not allowed here
3103  // the model holds reference to the shell, so the shell will not destructed at the end of method
3104  SfxObjectShellRef pShell = pDocShell->GetDoc()->CreateCopy(false, false);
3105  uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
3106  uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( );
3107  uno::Sequence< beans::PropertyValue > aTempMediaDescriptor;
3108  storeToStorage( xNewStorage, aTempMediaDescriptor );
3109  uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY );
3110  xStorageDoc->loadFromStorage( xNewStorage, aTempMediaDescriptor );
3111  return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
3112 }
3113 
3114 void SwXTextDocument::addPasteEventListener(const uno::Reference<text::XPasteListener>& xListener)
3115 {
3116  SolarMutexGuard aGuard;
3117 
3118  if (IsValid() && xListener.is())
3120 }
3121 
3123  const uno::Reference<text::XPasteListener>& xListener)
3124 {
3125  SolarMutexGuard aGuard;
3126 
3127  if (IsValid() && xListener.is())
3129 }
3130 
3132  int nOutputWidth, int nOutputHeight,
3133  int nTilePosX, int nTilePosY,
3134  long nTileWidth, long nTileHeight )
3135 {
3136  SwViewShell* pViewShell = pDocShell->GetWrtShell();
3137  pViewShell->PaintTile(rDevice, nOutputWidth, nOutputHeight,
3138  nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3139 
3140  LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
3141  nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3142 }
3143 
3145 {
3146  SwViewShell* pViewShell = pDocShell->GetWrtShell();
3147  Size aDocSize = pViewShell->GetDocSize();
3148 
3149  return Size(aDocSize.Width() + 2 * DOCUMENTBORDER,
3150  aDocSize.Height() + 2 * DOCUMENTBORDER);
3151 }
3152 
3154 {
3155  SolarMutexGuard aGuard;
3156 
3157  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3158  if (!pWrtShell)
3159  return;
3160 
3161  pWrtShell->GotoPage(nPart + 1, true);
3162 }
3163 
3165 {
3166  SolarMutexGuard aGuard;
3167 
3168  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3169  if (!pWrtShell)
3170  return 0;
3171 
3172  return pWrtShell->GetPageCnt();
3173 }
3174 
3176 {
3177  SolarMutexGuard aGuard;
3178 
3179  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3180  if (!pWrtShell)
3181  return OUString();
3182 
3183  return pWrtShell->getPageRectangles();
3184 }
3185 
3186 void SwXTextDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard)
3187 {
3188  SolarMutexGuard aGuard;
3189 
3190  pDocShell->GetView()->GetEditWin().SetClipboard(xClipboard);
3191 }
3192 
3194 {
3195  SolarMutexGuard aGuard;
3196 
3197  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3198  if (!pWrtShell)
3199  return false;
3200 
3202  if (SdrView* pSdrView = pWrtShell->GetDrawView())
3203  {
3204  if (pSdrView->GetTextEditObject())
3205  // Editing shape text
3206  return EditEngine::HasValidData(aDataHelper.GetTransferable());
3207  }
3208 
3209  return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper);
3210 }
3211 
3213 {
3214  if (SwView* pView = pDocShell->GetView())
3215  {
3216  // set the PgUp/PgDown offset
3217  pView->ForcePageUpDownOffset(2 * rRectangle.GetHeight() / 3);
3218  }
3219 
3220  if (SwViewShell* pViewShell = pDocShell->GetWrtShell())
3221  {
3222  pViewShell->setLOKVisibleArea(rRectangle);
3223  }
3224 }
3225 
3226 void SwXTextDocument::setClientZoom(int nTilePixelWidth_, int /*nTilePixelHeight_*/,
3227  int nTileTwipWidth_, int /*nTileTwipHeight_*/)
3228 {
3229  // Here we set the zoom value as it has been set by the user in the client.
3230  // This value is used in postMouseEvent and setGraphicSelection methods
3231  // for in place chart editing. We assume that x and y scale is roughly
3232  // the same.
3233  // Indeed we could set mnTilePixelWidth, mnTilePixelHeight, mnTileTwipWidth,
3234  // mnTileTwipHeight data members of this class but they are not very useful
3235  // since we need to be able to retrieve the zoom value for each view shell.
3236  SfxInPlaceClient* pIPClient = pDocShell->GetView()->GetIPClient();
3237  if (pIPClient)
3238  {
3239  SwViewShell* pWrtViewShell = pDocShell->GetWrtShell();
3240  double fScale = nTilePixelWidth_ * TWIPS_PER_PIXEL / (nTileTwipWidth_ * 1.0);
3241  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3242  if (aOption.GetZoom() != fScale * 100)
3243  {
3244  aOption.SetZoom(fScale * 100);
3245  pWrtViewShell->ApplyViewOptions(aOption);
3246 
3247  // Changing the zoom value doesn't always trigger the updating of
3248  // the client ole object area, so we call it directly.
3249  pIPClient->VisAreaChanged();
3250  }
3251  }
3252 }
3253 
3255 {
3256  SolarMutexGuard aGuard;
3257 
3258  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3259  if (!pWrtShell)
3260  return PointerStyle::Arrow;
3261 
3262  return pWrtShell->GetView().GetEditWin().GetPointer();
3263 }
3264 
3266 {
3267  boost::property_tree::ptree aTrackedChanges;
3268 
3269  // Disable since usability is very low beyond some small number of changes.
3270  static bool bDisableRedlineComments = getenv("DISABLE_REDLINE") != nullptr;
3271  if (!bDisableRedlineComments)
3272  {
3273  const SwRedlineTable& rRedlineTable
3275  for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
3276  {
3277  boost::property_tree::ptree aTrackedChange;
3278  aTrackedChange.put("index", rRedlineTable[i]->GetId());
3279  aTrackedChange.put("author", rRedlineTable[i]->GetAuthorString(1).toUtf8().getStr());
3280  aTrackedChange.put("type", SwRedlineTypeToOUString(
3281  rRedlineTable[i]->GetRedlineData().GetType())
3282  .toUtf8()
3283  .getStr());
3284  aTrackedChange.put("comment",
3285  rRedlineTable[i]->GetRedlineData().GetComment().toUtf8().getStr());
3286  aTrackedChange.put("description", rRedlineTable[i]->GetDescr().toUtf8().getStr());
3287  OUString sDateTime = utl::toISO8601(
3288  rRedlineTable[i]->GetRedlineData().GetTimeStamp().GetUNODateTime());
3289  aTrackedChange.put("dateTime", sDateTime.toUtf8().getStr());
3290 
3291  SwContentNode* pContentNd = rRedlineTable[i]->GetContentNode();
3292  SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
3293  if (pView && pContentNd)
3294  {
3295  SwShellCursor aCursor(pView->GetWrtShell(), *(rRedlineTable[i]->Start()));
3296  aCursor.SetMark();
3297  aCursor.GetMark()->nNode = *pContentNd;
3298  aCursor.GetMark()->nContent.Assign(pContentNd,
3299  rRedlineTable[i]->End()->nContent.GetIndex());
3300 
3301  aCursor.FillRects();
3302 
3303  SwRects* pRects(&aCursor);
3304  std::vector<OString> aRects;
3305  for (const SwRect& rNextRect : *pRects)
3306  aRects.push_back(rNextRect.SVRect().toString());
3307 
3308  const OString sRects = comphelper::string::join("; ", aRects);
3309  aTrackedChange.put("textRange", sRects.getStr());
3310  }
3311 
3312  aTrackedChanges.push_back(std::make_pair("", aTrackedChange));
3313  }
3314  }
3315 
3316  boost::property_tree::ptree aTree;
3317  aTree.add_child("redlines", aTrackedChanges);
3318  std::stringstream aStream;
3319  boost::property_tree::write_json(aStream, aTree);
3320 
3321  return OUString::fromUtf8(aStream.str().c_str());
3322 }
3323 
3325 {
3326  return SW_MOD()->GetRedlineAuthorInfo();
3327 }
3328 
3330 {
3331  SwView* pView = pDocShell->GetView();
3332  return OUString::fromUtf8(dynamic_cast<SwCommentRuler&>(pView->GetHRuler()).CreateJsonNotification().c_str());
3333 }
3334 
3336 {
3337  SolarMutexGuard aGuard;
3338  boost::property_tree::ptree aAnnotations;
3339  for (auto const& sidebarItem : *pDocShell->GetView()->GetPostItMgr())
3340  {
3341  sw::annotation::SwAnnotationWin* pWin = sidebarItem->pPostIt.get();
3342 
3343  const SwPostItField* pField = pWin->GetPostItField();
3344  const SwRect& aRect = pWin->GetAnchorRect();
3345  tools::Rectangle aSVRect(aRect.Pos().getX(),
3346  aRect.Pos().getY(),
3347  aRect.Pos().getX() + aRect.SSize().Width(),
3348  aRect.Pos().getY() + aRect.SSize().Height());
3349 
3350  if (!sidebarItem->maLayoutInfo.mPositionFromCommentAnchor)
3351  {
3352  // Comments on frames: anchor position is the corner position, not the whole frame.
3353  aSVRect.SetSize(Size(0, 0));
3354  }
3355 
3356  std::vector<OString> aRects;
3357  for (const basegfx::B2DRange& aRange : pWin->GetAnnotationTextRanges())
3358  {
3359  const SwRect rect(aRange.getMinX(), aRange.getMinY(), aRange.getWidth(), aRange.getHeight());
3360  aRects.push_back(rect.SVRect().toString());
3361  }
3362  const OString sRects = comphelper::string::join("; ", aRects);
3363 
3364  boost::property_tree::ptree aAnnotation;
3365  aAnnotation.put("id", pField->GetPostItId());
3366  aAnnotation.put("parent", pWin->CalcParent());
3367  aAnnotation.put("author", pField->GetPar1().toUtf8().getStr());
3368  aAnnotation.put("text", pField->GetPar2().toUtf8().getStr());
3369  aAnnotation.put("resolved", pField->GetResolved() ? "true" : "false");
3370  aAnnotation.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime()));
3371  aAnnotation.put("anchorPos", aSVRect.toString());
3372  aAnnotation.put("textRange", sRects.getStr());
3373 
3374  aAnnotations.push_back(std::make_pair("", aAnnotation));
3375  }
3376 
3377  boost::property_tree::ptree aTree;
3378  aTree.add_child("comments", aAnnotations);
3379  std::stringstream aStream;
3380  boost::property_tree::write_json(aStream, aTree);
3381 
3382  return OUString::fromUtf8(aStream.str().c_str());
3383 }
3384 
3386 {
3387  SolarMutexGuard aGuard;
3388 
3389  SwView* pView = pDocShell->GetView();
3390  if (!pView)
3391  return 0;
3392 
3393  return pView->getPart();
3394 }
3395 
3396 OUString SwXTextDocument::getPartName(int nPart)
3397 {
3398  SolarMutexGuard aGuard;
3399 
3400  return SwResId(STR_PAGE) + OUString::number(nPart + 1);
3401 }
3402 
3403 OUString SwXTextDocument::getPartHash(int nPart)
3404 {
3405  SolarMutexGuard aGuard;
3406  OUString sPart(SwResId(STR_PAGE) + OUString::number(nPart + 1));
3407 
3408  return OUString::number(sPart.hashCode());
3409 }
3410 
3412 {
3413  SolarMutexGuard aGuard;
3414  VclPtr<vcl::Window> pWindow;
3415  SwView* pView = pDocShell->GetView();
3416  if (pView)
3417  pWindow = &(pView->GetEditWin());
3418 
3419  LokChartHelper aChartHelper(pView);
3420  VclPtr<vcl::Window> pChartWindow = aChartHelper.GetWindow();
3421  if (pChartWindow)
3422  pWindow = pChartWindow;
3423 
3424  return pWindow;
3425 }
3426 
3427 void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
3428 {
3429  SolarMutexGuard aGuard;
3430 
3431  SwViewShell* pViewShell = pDocShell->GetWrtShell();
3432 
3433  SwView* pView = pDocShell->GetView();
3434  if (!pView)
3435  return;
3436 
3437  pView->SetViewLayout(1/*nColumns*/, false/*bBookMode*/, true);
3438 
3439  // Tiled rendering defaults.
3440  SwViewOption aViewOption(*pViewShell->GetViewOptions());
3441  aViewOption.SetHardBlank(false);
3442  for (const beans::PropertyValue& rValue : rArguments)
3443  {
3444  if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has<bool>())
3445  aViewOption.SetHideWhitespaceMode(rValue.Value.get<bool>());
3446  else if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>())
3447  SwViewOption::SetAppearanceFlag(ViewOptFlags::Shadow , rValue.Value.get<bool>());
3448  else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
3449  {
3450  // Store the author name in the view.
3451  pView->SetRedlineAuthor(rValue.Value.get<OUString>());
3452  // Let the actual author name pick up the value from the current
3453  // view, which would normally happen only during the next view
3454  // switch.
3455  pDocShell->SetView(pView);
3456  }
3457  }
3458 
3459  // Set the initial zoom value to 1; usually it is set in setClientZoom and
3460  // SwViewShell::PaintTile; zoom value is used for chart in place
3461  // editing, see postMouseEvent and setGraphicSelection methods.
3462  aViewOption.SetZoom(1 * 100);
3463 
3464  aViewOption.SetPostIts(comphelper::LibreOfficeKit::isTiledAnnotations());
3465  pViewShell->ApplyViewOptions(aViewOption);
3466 
3467  // position the pages again after setting view options. Eg: if postit
3468  // rendering is false, then there would be no sidebar, so width of the
3469  // document needs to be adjusted
3470  pViewShell->GetLayout()->CheckViewLayout( pViewShell->GetViewOptions(), nullptr );
3471 
3472  // Disable map mode, so that it's possible to send mouse event coordinates
3473  // directly in twips.
3474  SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
3475  rEditWin.EnableMapMode(false);
3476 
3477  // when the "This document may contain formatting or content that cannot
3478  // be saved..." dialog appears, it is auto-cancelled with tiled rendering,
3479  // causing 'Save' being disabled; so let's always save to the original
3480  // format
3482 
3483  // disable word auto-completion suggestions, the tooltips are not visible,
3484  // and the editeng-like auto-completion is annoying
3486 
3487  // don't change the whitespace at the beginning of paragraphs, this is
3488  // annoying when taking minutes without further formatting
3490 }
3491 
3492 void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
3493 {
3494  SolarMutexGuard aGuard;
3495  SfxLokHelper::postKeyEventAsync(getDocWindow(), nType, nCharCode, nKeyCode);
3496 }
3497 
3498 void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
3499 {
3500  SolarMutexGuard aGuard;
3501 
3502  SwViewShell* pWrtViewShell = pDocShell->GetWrtShell();
3503  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3504  double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0);
3505 
3506  // check if the user hit a chart which is being edited by this view
3507  SfxViewShell* pViewShell = pDocShell->GetView();
3508  LokChartHelper aChartHelper(pViewShell);
3509  if (aChartHelper.postMouseEvent(nType, nX, nY,
3510  nCount, nButtons, nModifier,
3511  fScale, fScale))
3512  return;
3513 
3514  // check if the user hit a chart which is being edited by someone else
3515  // and, if so, skip current mouse event
3516  if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
3517  {
3518  if (LokChartHelper::HitAny(Point(nX, nY)))
3519  return;
3520  }
3521 
3522  SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
3523  SfxLokHelper::postMouseEventAsync(&rEditWin, nType,
3524  Point(nX, nY), nCount,
3525  MouseEventModifiers::SIMPLECLICK,
3526  nButtons, nModifier);
3527 }
3528 
3529 void SwXTextDocument::setTextSelection(int nType, int nX, int nY)
3530 {
3531  SolarMutexGuard aGuard;
3532 
3533  SfxViewShell* pViewShell = pDocShell->GetView();
3534  LokChartHelper aChartHelper(pViewShell);
3535  if (aChartHelper.setTextSelection(nType, nX, nY))
3536  return;
3537 
3538  SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
3539  switch (nType)
3540  {
3541  case LOK_SETTEXTSELECTION_START:
3542  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/false, /*bClearMark=*/false);
3543  break;
3544  case LOK_SETTEXTSELECTION_END:
3545  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/true, /*bClearMark=*/false);
3546  break;
3547  case LOK_SETTEXTSELECTION_RESET:
3548  rEditWin.SetCursorTwipPosition(Point(nX, nY), /*bPoint=*/true, /*bClearMark=*/true);
3549  break;
3550  default:
3551  assert(false);
3552  break;
3553  }
3554 }
3555 
3556 uno::Reference<datatransfer::XTransferable> SwXTextDocument::getSelection()
3557 {
3558  SolarMutexGuard aGuard;
3559 
3560  uno::Reference<datatransfer::XTransferable> xTransferable;
3561 
3562  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3563  if (SdrView* pSdrView = pWrtShell->GetDrawView())
3564  {
3565  if (pSdrView->GetTextEditObject())
3566  {
3567  // Editing shape text
3568  EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
3569  xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
3570  }
3571  }
3572 
3573  if (SwPostItMgr* pPostItMgr = pDocShell->GetView()->GetPostItMgr())
3574  {
3575  if (sw::annotation::SwAnnotationWin* pWin = pPostItMgr->GetActiveSidebarWin())
3576  {
3577  // Editing postit text.
3578  EditView& rEditView = pWin->GetOutlinerView()->GetEditView();
3579  xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
3580  }
3581  }
3582 
3583  if (!xTransferable.is())
3584  xTransferable = new SwTransferable(*pWrtShell);
3585 
3586  return xTransferable;
3587 }
3588 
3589 void SwXTextDocument::setGraphicSelection(int nType, int nX, int nY)
3590 {
3591  SolarMutexGuard aGuard;
3592 
3593  SwViewShell* pWrtViewShell = pDocShell->GetWrtShell();
3594  SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
3595  double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0);
3596 
3597  SfxViewShell* pViewShell = pDocShell->GetView();
3598  LokChartHelper aChartHelper(pViewShell);
3599  if (aChartHelper.setGraphicSelection(nType, nX, nY, fScale, fScale))
3600  return;
3601 
3602  SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
3603  switch (nType)
3604  {
3605  case LOK_SETGRAPHICSELECTION_START:
3606  rEditWin.SetGraphicTwipPosition(/*bStart=*/true, Point(nX, nY));
3607  break;
3608  case LOK_SETGRAPHICSELECTION_END:
3609  rEditWin.SetGraphicTwipPosition(/*bStart=*/false, Point(nX, nY));
3610  break;
3611  default:
3612  assert(false);
3613  break;
3614  }
3615 }
3616 
3618 {
3619  SolarMutexGuard aGuard;
3620 
3621  SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
3622  pWrtShell->ResetSelect(nullptr, false);
3623 }
3624 
3625 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 )
3626 {
3628  aData.nSize = sizeof(SystemGraphicsData);
3629  #if defined(_WIN32)
3630  sal_Int64 nWindowHandle;
3631  Parent >>= nWindowHandle;
3632  aData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
3633  ScopedVclPtrInstance<VirtualDevice> xDevice(&aData, Size(1, 1), DeviceFormat::DEFAULT);
3634  paintTile(*xDevice, nOutputWidth, nOutputHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
3635  #else
3636  // TODO: support other platforms
3637  (void)Parent;
3638  (void)nOutputWidth;
3639  (void)nOutputHeight;
3640  (void)nTilePosX;
3641  (void)nTilePosY;
3642  (void)nTileWidth;
3643  (void)nTileHeight;
3644  #endif
3645 }
3646 
3650 uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
3651  ::sal_Int16 nScriptTypes,
3652  ::sal_Int16 nMaxCount )
3653 {
3654  SolarMutexGuard aGuard;
3655 
3656  // possible canonical values for nScriptTypes
3657  // any bit wise combination is allowed
3658  const sal_Int16 nLatin = 0x001;
3659  const sal_Int16 nAsian = 0x002;
3660  const sal_Int16 nComplex = 0x004;
3661 
3662  // script types for which to get the languages
3663  const bool bLatin = 0 != (nScriptTypes & nLatin);
3664  const bool bAsian = 0 != (nScriptTypes & nAsian);
3665  const bool bComplex = 0 != (nScriptTypes & nComplex);
3666 
3667  if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex))
3668  throw IllegalArgumentException("nScriptTypes ranges from 1 to 7!", Reference< XInterface >(), 1);
3669  if (!pDocShell)
3670  throw DisposedException();
3671  SwDoc* pDoc = pDocShell->GetDoc();
3672 
3673  // avoid duplicate values
3674  std::set< LanguageType > aAllLangs;
3675 
3676  //USER STYLES
3677 
3678  const SwCharFormats *pFormats = pDoc->GetCharFormats();
3679  for(size_t i = 0; i < pFormats->size(); ++i)
3680  {
3681  const SwAttrSet &rAttrSet = (*pFormats)[i]->GetAttrSet();
3683  if (bLatin)
3684  {
3685  nLang = rAttrSet.GetLanguage( false ).GetLanguage();
3686  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3687  aAllLangs.insert( nLang );
3688  }
3689  if (bAsian)
3690  {
3691  nLang = rAttrSet.GetCJKLanguage( false ).GetLanguage();
3692  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3693  aAllLangs.insert( nLang );
3694  }
3695  if (bComplex)
3696  {
3697  nLang = rAttrSet.GetCTLLanguage( false ).GetLanguage();
3698  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3699  aAllLangs.insert( nLang );
3700  }
3701  }
3702 
3703  const SwTextFormatColls *pColls = pDoc->GetTextFormatColls();
3704  for (size_t i = 0; i < pColls->size(); ++i)
3705  {
3706  const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
3708  if (bLatin)
3709  {
3710  nLang = rAttrSet.GetLanguage( false ).GetLanguage();
3711  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3712  aAllLangs.insert( nLang );
3713  }
3714  if (bAsian)
3715  {
3716  nLang = rAttrSet.GetCJKLanguage( false ).GetLanguage();
3717  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3718  aAllLangs.insert( nLang );
3719  }
3720  if (bComplex)
3721  {
3722  nLang = rAttrSet.GetCTLLanguage( false ).GetLanguage();
3723  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3724  aAllLangs.insert( nLang );
3725  }
3726  }
3727 
3728  //AUTO STYLES
3729  const IStyleAccess::SwAutoStyleFamily aFam[2] =
3730  {
3733  };
3734  for (IStyleAccess::SwAutoStyleFamily i : aFam)
3735  {
3736  std::vector< std::shared_ptr<SfxItemSet> > rStyles;
3737  pDoc->GetIStyleAccess().getAllStyles(rStyles, i);
3738  while (!rStyles.empty())
3739  {
3740  std::shared_ptr<SfxItemSet> pStyle = rStyles.back();
3741  rStyles.pop_back();
3742  const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
3743 
3745  if (bLatin)
3746  {
3747  assert(pSet);
3748  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, false )).GetLanguage();
3749  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3750  aAllLangs.insert( nLang );
3751  }
3752  if (bAsian)
3753  {
3754  assert(pSet);
3755  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, false )).GetLanguage();
3756  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3757  aAllLangs.insert( nLang );
3758  }
3759  if (bComplex)
3760  {
3761  assert(pSet);
3762  nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, false )).GetLanguage();
3763  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3764  aAllLangs.insert( nLang );
3765  }
3766  }
3767  }
3768 
3769  //TODO/mba: it's a strange concept that a view is needed to retrieve core data
3770  SwWrtShell *pWrtSh = pDocShell->GetWrtShell();
3771  SdrView *pSdrView = pWrtSh->GetDrawView();
3772 
3773  if( pSdrView )
3774  {
3775  SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
3776  if(pOutliner)
3777  {
3778  EditEngine& rEditEng = const_cast<EditEngine&>(pOutliner->GetEditEngine());
3779  sal_Int32 nParCount = pOutliner->GetParagraphCount();
3780  for (sal_Int32 nPar=0; nPar<nParCount; nPar++)
3781  {
3782  //every paragraph
3783  std::vector<sal_Int32> aPortions;
3784  rEditEng.GetPortions( nPar, aPortions );
3785 
3786  for ( size_t nPos = aPortions.size(); nPos; )
3787  {
3788  //every position
3789  --nPos;
3790  sal_Int32 nEnd = aPortions[ nPos ];
3791  sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0;
3792  ESelection aSelection( nPar, nStart, nPar, nEnd );
3793  SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );
3794 
3796  if (bLatin)
3797  {
3798  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, false )).GetLanguage();
3799  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3800  aAllLangs.insert( nLang );
3801  }
3802  if (bAsian)
3803  {
3804  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, false )).GetLanguage();
3805  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3806  aAllLangs.insert( nLang );
3807  }
3808  if (bComplex)
3809  {
3810  nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, false )).GetLanguage();
3811  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
3812  aAllLangs.insert( nLang );
3813  }
3814  }
3815  }
3816  }
3817  }
3818  // less than nMaxCount languages
3819  if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() ))
3820  nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() );
3821 
3822  // build return value
3823  uno::Sequence< lang::Locale > aLanguages( nMaxCount );
3824  lang::Locale* pLanguage = aLanguages.getArray();
3825  if (nMaxCount > 0)
3826  {
3827  sal_Int32 nCount = 0;
3828  for (const auto& rLang : aAllLangs)
3829  {
3830  if (nCount >= nMaxCount)
3831  break;
3832  if (LANGUAGE_NONE != rLang)
3833  {
3834  pLanguage[nCount] = LanguageTag::convertToLocale( rLang );
3835  pLanguage[nCount].Language = SvtLanguageTable::GetLanguageString( rLang );
3836  nCount += 1;
3837  }
3838  }
3839  }
3840 
3841  return aLanguages;
3842 }
3843 
3845  pxDoc(&rxDoc)
3846 {
3847  sTables = SwResId(STR_CONTENT_TYPE_TABLE);
3848  sFrames = SwResId(STR_CONTENT_TYPE_FRAME);
3849  sGraphics = SwResId(STR_CONTENT_TYPE_GRAPHIC);
3850  sOLEs = SwResId(STR_CONTENT_TYPE_OLE);
3851  sSections = SwResId(STR_CONTENT_TYPE_REGION);
3852  sOutlines = SwResId(STR_CONTENT_TYPE_OUTLINE);
3853  sBookmarks = SwResId(STR_CONTENT_TYPE_BOOKMARK);
3854 }
3855 
3857 {
3858 }
3859 
3861 {
3862  Any aRet;
3863  if(!pxDoc)
3864  throw RuntimeException("No document available");
3865  OUString sSuffix("|");
3866  if(rName == sTables)
3867  {
3868  sSuffix += "table";
3869 
3871  pxDoc->getTextTables(), rName, sSuffix );
3872  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3873  }
3874  else if(rName == sFrames)
3875  {
3876  sSuffix += "frame";
3878  pxDoc->getTextFrames(), rName, sSuffix );
3879  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3880  }
3881  else if(rName == sSections)
3882  {
3883  sSuffix += "region";
3885  pxDoc->getTextSections(), rName, sSuffix );
3886  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3887  }
3888  else if(rName == sGraphics)
3889  {
3890  sSuffix += "graphic";
3892  pxDoc->getGraphicObjects(), rName, sSuffix );
3893  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3894  }
3895  else if(rName == sOLEs)
3896  {
3897  sSuffix += "ole";
3899  pxDoc->getEmbeddedObjects(), rName, sSuffix );
3900  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3901  }
3902  else if(rName == sOutlines)
3903  {
3904  sSuffix += "outline";
3906  *pxDoc, rName, sSuffix );
3907  aRet <<= Reference< XPropertySet >(xTables, UNO_QUERY);
3908  }
3909  else if(rName == sBookmarks)
3910  {
3911  sSuffix.clear();
3913  pxDoc->getBookmarks(), rName, sSuffix );
3914  aRet <<= Reference< XPropertySet >(xBkms, UNO_QUERY);
3915  }
3916  else
3917  throw NoSuchElementException();
3918  return aRet;
3919 }
3920 
3922 {
3923  return { sTables,
3924  sFrames,
3925  sGraphics,
3926  sOLEs,
3927  sSections,
3928  sOutlines,
3929  sBookmarks };
3930 }
3931 
3933 {
3934  if( rName == sTables ||
3935  rName == sFrames ||
3936  rName == sGraphics||
3937  rName == sOLEs ||
3938  rName == sSections ||
3939  rName == sOutlines ||
3940  rName == sBookmarks )
3941  return true;
3942  return false;
3943 }
3944 
3946 {
3948 
3949 }
3950 
3952 {
3953  return nullptr != pxDoc;
3954 }
3955 
3957 {
3958  return "SwXLinkTargetSupplier";
3959 }
3960 
3962 {
3963  return cppu::supportsService(this, rServiceName);
3964 }
3965 
3967 {
3968  Sequence< OUString > aRet { "com.sun.star.document.LinkTargets" };
3969  return aRet;
3970 }
3971 
3973  Reference< XNameAccess > const & xAccess, const OUString& rLinkDisplayName, const OUString& sSuffix ) :
3974  xRealAccess(xAccess),
3975  pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3976  sLinkSuffix(sSuffix),
3977  sLinkDisplayName(rLinkDisplayName),
3978  pxDoc(nullptr)
3979 {
3980 }
3981 
3983  const OUString& rLinkDisplayName, const OUString& sSuffix) :
3984  pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
3985  sLinkSuffix(sSuffix),
3986  sLinkDisplayName(rLinkDisplayName),
3987  pxDoc(&rxDoc)
3988 {
3989 }
3990 
3992 {
3993 }
3994 
3996 {
3997  Any aRet;
3998  bool bFound = false;
3999  //cut link extension and call the real NameAccess
4000  OUString sParam = rName;
4001  OUString sSuffix(sLinkSuffix);
4002  if(sParam.getLength() > sSuffix.getLength() )
4003  {
4004  OUString sCmp = sParam.copy(sParam.getLength() - sSuffix.getLength(),
4005  sSuffix.getLength());
4006  if(sCmp == sSuffix)
4007  {
4008  if(pxDoc)
4009  {
4010  sParam = sParam.copy(0, sParam.getLength() - sSuffix.getLength());
4011  if(!pxDoc->GetDocShell())
4012  throw RuntimeException("No document shell available");
4013  SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
4014  const size_t nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
4015 
4016  for (size_t i = 0; i < nOutlineCount && !bFound; ++i)
4017  {
4018  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4019  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4020  if(sParam == lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
4021  {
4022  Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
4023  aRet <<= xOutline;
4024  bFound = true;
4025  }
4026  }
4027  }
4028  else
4029  {
4030  aRet = xRealAccess->getByName(sParam.copy(0, sParam.getLength() - sSuffix.getLength()));
4032  if(!(aRet >>= xInt))
4033  throw RuntimeException("Could not retrieve property");
4034  Reference< XPropertySet > xProp(xInt, UNO_QUERY);
4035  aRet <<= xProp;
4036  bFound = true;
4037  }
4038  }
4039  }
4040  if(!bFound)
4041  throw NoSuchElementException();
4042  return aRet;
4043 }
4044 
4046 {
4047  Sequence< OUString > aRet;
4048  if(pxDoc)
4049  {
4050  if(!pxDoc->GetDocShell())
4051  throw RuntimeException("No document shell available");
4052 
4053  SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
4054  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4055  const size_t nOutlineCount = rOutlineNodes.size();
4056  aRet.realloc(nOutlineCount);
4057  OUString* pResArr = aRet.getArray();
4058  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4059  for (size_t i = 0; i < nOutlineCount; ++i)
4060  {
4061  OUString sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule);
4062  sEntry += "|outline";
4063  pResArr[i] = sEntry;
4064  }
4065  }
4066  else
4067  {
4068  Sequence< OUString > aOrg = xRealAccess->getElementNames();
4069  aRet.realloc(aOrg.getLength());
4070  std::transform(aOrg.begin(), aOrg.end(), aRet.begin(),
4071  [this](const OUString& rOrg) -> OUString { return rOrg + sLinkSuffix; });
4072  }
4073  return aRet;
4074 }
4075 
4077 {
4078  bool bRet = false;
4079  OUString sParam(rName);
4080  if(sParam.getLength() > sLinkSuffix.getLength() )
4081  {
4082  OUString sCmp = sParam.copy(sParam.getLength() - sLinkSuffix.getLength(),
4083  sLinkSuffix.getLength());
4084  if(sCmp == sLinkSuffix)
4085  {
4086  sParam = sParam.copy(0, sParam.getLength() - sLinkSuffix.getLength());
4087  if(pxDoc)
4088  {
4089  if(!pxDoc->GetDocShell())
4090  throw RuntimeException("No document shell available");
4091  SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
4092  const size_t nOutlineCount = pDoc->GetNodes().GetOutLineNds().size();
4093 
4094  for (size_t i = 0; i < nOutlineCount && !bRet; ++i)
4095  {
4096  const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
4097  const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
4098  if(sParam ==
4099  lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
4100  {
4101  bRet = true;
4102  }
4103  }
4104  }
4105  else
4106  {
4107  bRet = xRealAccess->hasByName(sParam);
4108  }
4109  }
4110  }
4111  return bRet;
4112 }
4113 
4115 {
4117 }
4118 
4120 {
4121  bool bRet = false;
4122  if(pxDoc)
4123  {
4124  OSL_FAIL("not implemented");
4125  }
4126  else
4127  {
4128  bRet = xRealAccess->hasElements();
4129  }
4130  return bRet;
4131 }
4132 
4133 Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo()
4134 {
4135  static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
4136  return xRet;
4137 }
4138 
4140  const OUString& , const Any& )
4141 {
4142  throw UnknownPropertyException();
4143 }
4144 
4145 static Any lcl_GetDisplayBitmap(const OUString& _sLinkSuffix)
4146 {
4147  Any aRet;
4148  OUString sLinkSuffix = _sLinkSuffix;
4149  if(!sLinkSuffix.isEmpty())
4150  sLinkSuffix = sLinkSuffix.copy(1);
4151  OUString sImgId;
4152 
4153  if(sLinkSuffix == "outline")
4154  sImgId = RID_BMP_NAVI_OUTLINE;
4155  else if(sLinkSuffix == "table")
4156  sImgId = RID_BMP_NAVI_TABLE;
4157  else if(sLinkSuffix == "frame")
4158  sImgId = RID_BMP_NAVI_FRAME;
4159  else if(sLinkSuffix == "graphic")
4160  sImgId = RID_BMP_NAVI_GRAPHIC;
4161  else if(sLinkSuffix == "ole")
4162  sImgId = RID_BMP_NAVI_OLE;
4163  else if(sLinkSuffix.isEmpty())
4164  sImgId = RID_BMP_NAVI_BOOKMARK;
4165  else if(sLinkSuffix == "region")
4166  sImgId = RID_BMP_NAVI_REGION;
4167 
4168  if (!sImgId.isEmpty())
4169  {
4170  aRet <<= VCLUnoHelper::CreateBitmap(BitmapEx(sImgId));
4171  }
4172  return aRet;
4173 }
4174 
4175 Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName)
4176 {
4177  Any aRet;
4178  if( rPropertyName == UNO_LINK_DISPLAY_NAME )
4179  {
4180  aRet <<= sLinkDisplayName;
4181  }
4182  else if( rPropertyName == UNO_LINK_DISPLAY_BITMAP )
4183  {
4185  }
4186  else
4187  throw UnknownPropertyException();
4188  return aRet;
4189 }
4190 
4192  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4193 {}
4194 
4196  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4197 {}
4198 
4200  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4201 {}
4202 
4204  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4205 {}
4206 
4208 {
4209  return this;
4210 }
4211 
4213 {
4214  return "SwXLinkNameAccessWrapper";
4215 }
4216 
4218 {
4219  return cppu::supportsService(this, rServiceName);
4220 }
4221 
4223 {
4224  Sequence< OUString > aRet { "com.sun.star.document.LinkTargets" };
4225  return aRet;
4226 }
4227 
4228 SwXOutlineTarget::SwXOutlineTarget(const OUString& rOutlineText) :
4229  pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
4230  sOutlineText(rOutlineText)
4231 {
4232 }
4233 
4235 {
4236 }
4237 
4238 Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo()
4239 {
4240  static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
4241  return xRet;
4242 }
4243 
4245  const OUString& /*PropertyName*/, const Any& /*aValue*/)
4246 {
4247  throw UnknownPropertyException();
4248 }
4249 
4250 Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
4251 {
4252  if(rPropertyName != UNO_LINK_DISPLAY_NAME)
4253  throw UnknownPropertyException();
4254 
4255  return Any(sOutlineText);
4256 }
4257 
4259  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4260 {
4261 }
4262 
4264  const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
4265 {
4266 }
4267 
4269  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4270 {
4271 }
4272 
4274  const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
4275 {
4276 }
4277 
4279 {
4280  return "SwXOutlineTarget";
4281 }
4282 
4283 sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName)
4284 {
4285  return cppu::supportsService(this, ServiceName);
4286 }
4287 
4289 {
4290  Sequence<OUString> aRet { "com.sun.star.document.LinkTarget" };
4291 
4292  return aRet;
4293 }
4294 
4296 SvxUnoForbiddenCharsTable ( rDoc.getIDocumentSettingAccess().getForbiddenCharacterTable() )
4297 ,m_pDoc(&rDoc)
4298 {
4299 }
4300 
4302 {
4303 }
4304 
4306 {
4307  Reference<XInterface> xRet;
4308  if(m_pDoc)
4309  {
4310  switch(nWhich)
4311  {
4312  // #i52858#
4313  // assure that Draw model is created, if it doesn't exist.
4315  if(!xDashTable.is())
4317  xRet = xDashTable;
4318  break;
4320  if(!xGradientTable.is())
4322  xRet = xGradientTable;
4323  break;
4325  if(!xHatchTable.is())
4327  xRet = xHatchTable;
4328  break;
4330  if(!xBitmapTable.is())
4332  xRet = xBitmapTable;
4333  break;
4335  if(!xTransGradientTable.is())
4337  xRet = xTransGradientTable;
4338  break;
4340  if(!xMarkerTable.is())
4342  xRet = xMarkerTable;
4343  break;
4345  if(!xDrawDefaults.is())
4346  xDrawDefaults = static_cast<cppu::OWeakObject*>(new SwSvxUnoDrawPool(m_pDoc));
4347  xRet = xDrawDefaults;
4348  break;
4349 #if OSL_DEBUG_LEVEL > 0
4350  default: OSL_FAIL("which table?");
4351 #endif
4352  }
4353  }
4354  return xRet;
4355 }
4356 
4358 {
4359  xDashTable = nullptr;
4360  xGradientTable = nullptr;
4361  xHatchTable = nullptr;
4362  xBitmapTable = nullptr;
4363  xTransGradientTable = nullptr;
4364  xMarkerTable = nullptr;
4365  xDrawDefaults = nullptr;
4366  m_pDoc = nullptr;
4368 }
4369 
4371 {
4372  if(m_pDoc)
4374 }
4375 
4377  SwViewShell& rSh, const SwViewOption &rViewOptions)
4378  : m_pShell(&rSh)
4379  , m_aOldViewOptions( rViewOptions )
4380 {
4381 }
4382 
4384 {
4385  if (m_pShell)
4386  {
4388  }
4389 }
4390 
4391 void
4392 SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const pPrtOptions, bool setShowPlaceHoldersInPDF)
4393 {
4394  // to avoid unnecessary reformatting the view options related to the content
4395  // below should only change if necessary, that is if respective content is present
4396  const bool bContainsHiddenChars = m_pShell->GetDoc()->ContainsHiddenChars();
4398  const bool bContainsHiddenFields = pFieldType && pFieldType->HasWriterListeners();
4400  const bool bContainsHiddenParagraphs = pFieldType && pFieldType->HasWriterListeners();
4402  const bool bContainsPlaceHolders = pFieldType && pFieldType->HasWriterListeners();
4403  const bool bContainsFields = m_pShell->IsAnyFieldInDoc();
4404 
4405  SwViewOption aRenderViewOptions( m_aOldViewOptions );
4406 
4407  // disable anything in the view that should not be printed (or exported to PDF) by default
4408  // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids"
4409  // in section "Display of ...")
4410  aRenderViewOptions.SetParagraph( false ); // paragraph end
4411  aRenderViewOptions.SetSoftHyph( false ); // aka custom hyphens
4412  aRenderViewOptions.SetBlank( false ); // spaces
4413  aRenderViewOptions.SetHardBlank( false ); // non-breaking spaces
4414  aRenderViewOptions.SetTab( false ); // tabs
4415  aRenderViewOptions.SetLineBreak( false ); // breaks (type 1)
4416  aRenderViewOptions.SetPageBreak( false ); // breaks (type 2)
4417  aRenderViewOptions.SetColumnBreak( false ); // breaks (type 3)
4418  bool bVal = pPrtOptions && pPrtOptions->m_bPrintHiddenText;
4419  if (bContainsHiddenChars)
4420  aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text
4421  if (bContainsHiddenFields)
4422  aRenderViewOptions.SetShowHiddenField( bVal );
4423  if (bContainsHiddenParagraphs)
4424  aRenderViewOptions.SetShowHiddenPara( bVal );
4425 
4426  if (bContainsPlaceHolders)
4427  {
4428  // should always be printed in PDF export!
4429  bVal = !pPrtOptions ? setShowPlaceHoldersInPDF : pPrtOptions->m_bPrintTextPlaceholder;
4430  aRenderViewOptions.SetShowPlaceHolderFields( bVal );
4431  }
4432 
4433  if (bContainsFields)
4434  aRenderViewOptions.SetFieldName( false );
4435 
4436  // we need to set this flag in order to get to see the visible effect of
4437  // some of the above settings (needed for correct rendering)
4438  aRenderViewOptions.SetViewMetaChars( true );
4439 
4440  if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary
4441  {
4442  aRenderViewOptions.SetPrinting( pPrtOptions != nullptr );
4443  m_pShell->ApplyViewOptions( aRenderViewOptions );
4444  }
4445 }
4446 
4447 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual VclPtr< vcl::Window > getDocWindow() override
Definition: unotxdoc.cxx:3411
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:3995
OUString const & getRuntimeUID() const
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:233
long Width() const
css::uno::Reference< css::uno::XInterface > xDrawDefaults
Definition: unotxdoc.hxx:592
void SetLineBreak(bool b)
Definition: viewopt.hxx:238
static void UpdatePagesForPrintingWithPostItData(SwRenderData &rData, const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount)
Definition: doc.cxx:781
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:405
bool hasValidSignatures() const
SwViewShell * GetViewShell() const
Definition: pview.hxx:235
virtual ~SwXOutlineTarget() override
Definition: unotxdoc.cxx:4234
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotxdoc.cxx:4250
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:2113
long GetHeight() const
const SfxItemPropertySet * pPropSet
Definition: unotxdoc.hxx:558
static bool HasValidData(const css::uno::Reference< css::datatransfer::XTransferable > &rTransferable)
const OUString & GetTOIAutoMarkURL() const
Definition: doc.hxx:946
void SetSoftHyph(bool b)
Definition: viewopt.hxx:249
virtual OUString SAL_CALL getImplementationName() override
Definition: unotxdoc.cxx:3956
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:92
css::uno::Reference< css::uno::XInterface > xHatchTable
Definition: unotxdoc.hxx:588
static bool HitAny(const Point &aPos)
#define EE_CHAR_LANGUAGE_CJK
bool HasReplaceAttributes() const
Definition: unosrch.cxx:636
bool IsValid() const
Definition: unotxdoc.hxx:454
css::uno::Reference< css::container::XNameAccess > mxXTextSections
Definition: unotxdoc.hxx:164
SdrView * GetDrawView()
Definition: vnew.cxx:376
virtual sal_Bool SAL_CALL hasByName(const OUString &Name) override
Definition: unotxdoc.cxx:3932
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:4203
#define WID_DOC_WORD_COUNT
Definition: unomap.hxx:233
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:78
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)
static void postKeyEventAsync(const VclPtr< vcl::Window > &xWindow, int nType, int nCharCode, int nKeyCode)
SwDocShell * GetDocShell()
Definition: doc.hxx:1341
#define EE_CHAR_LANGUAGE
static SwXTextRanges * Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1504
virtual ~SwXLinkNameAccessWrapper() override
Definition: unotxdoc.cxx:3991
SwXBodyText * pBodyText
Definition: unotxdoc.hxx:153
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getLinks() override
Definition: unotxdoc.cxx:4207
virtual void CalcLayout()
Definition: viewsh.cxx:982
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:1400
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:3427
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:270
static void lcl_SavePrintUIOptionsToDocumentPrintData(SwDoc &rDoc, const SwPrintUIOptions &rPrintUIOptions, bool bIsPDFEXport)
Definition: unotxdoc.cxx:2446
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:3324
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:231
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:2919
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:2338
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:4228
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:3617
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:2313
static bool IsPaste(const SwWrtShell &, const TransferableDataHelper &)
Definition: swdtflvr.cxx:1292
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:3921
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:2880
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:1649
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:3589
const SvxLanguageItem & GetLanguage(bool=true) const
Definition: charatr.hxx:92
virtual css::uno::Any SAL_CALL getByName(const OUString &Name) override
Definition: unotxdoc.cxx:3860
#define RES_FRMATR_END
Definition: hintids.hxx:236
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:567
void SetLandscape(bool b)
Definition: pvprtdat.hxx:64
Definition: doc.hxx:185
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotxdoc.cxx:3951
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:513
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:292
OUString m_sSearchText
Definition: unosrch.hxx:46
SwViewShell * m_pShell
Definition: unotxdoc.hxx:611
virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getNumberingRules() override
Definition: unotxdoc.cxx:657
void Height(long nNew)
Definition: swrect.hxx:189
const std::vector< basegfx::B2DRange > & GetAnnotationTextRanges()
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:2183
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:2177
void AdjustViewOptions(SwPrintData const *const pPrtOptions, bool setShowPlaceHoldersInPDF)
Definition: unotxdoc.cxx:4392
virtual void SAL_CALL acquire() override
::sw::DocumentRedlineManager const & GetDocumentRedlineManager() const
Definition: doc.cxx:377
void PaintTile(VirtualDevice &rDevice, int contextWidth, int contextHeight, int tilePosX, int tilePosY, long tileWidth, long tileHeight)
Paint tile.
Definition: viewsh.cxx:1894
virtual void SAL_CALL printPages(const css::uno::Sequence< css::beans::PropertyValue > &xOptions) override
Definition: unotxdoc.cxx:1141
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:512
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:4268
virtual void SAL_CALL addRefreshListener(const css::uno::Reference< css::util::XRefreshListener > &l) override
Definition: unotxdoc.cxx:2228
SwDrawPagesObj(const css::uno::Reference< css::drawing::XDrawPageSupplier > &rxDoc)
Definition: unotxdoc.cxx:1378
std::shared_ptr< SvxForbiddenCharactersTable > mxForbiddenChars
void Pos(const Point &rNew)
Definition: swrect.hxx:167
#define WID_DOC_REDLINE_DISPLAY
Definition: unomap.hxx:239
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:1328
sal_uInt8 GetCol() const
Definition: pvprtdat.hxx:60
void RecheckBrowseMode()
Definition: view0.cxx:175
css::uno::Reference< css::uno::XInterface > xMarkerTable
Definition: unotxdoc.hxx:591
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:142
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
virtual OUString SAL_CALL getImplementationName() override
Definition: unotxdoc.cxx:4278
void SetHardBlank(bool b)
Definition: viewopt.hxx:226
virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getRedlines() override
Definition: unotxdoc.cxx:2198
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotxdoc.cxx:1414
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:211
virtual ~SwXDocumentPropertyHelper() override
Definition: unotxdoc.cxx:4301
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:587
void SetPrintGraphic(bool b)
Definition: printdata.hxx:150
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unotxdoc.cxx:1758
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4096
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:1220
static void lcl_DisposeView(SfxViewFrame *pToClose, SwDocShell const *pDocShell)
Definition: unotxdoc.cxx:262
#define WID_DOC_CHANGES_PASSWORD
Definition: unomap.hxx:241
SwXDrawPage * pDrawPage
Definition: unotxdoc.hxx:149
SwXTextCursor * CreateTextCursor(const bool bIgnoreTables=false)
Definition: unotext.cxx:2309
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:1817
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:994
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:187
void CheckViewLayout(const SwViewOption *pViewOpt, const SwRect *pVisArea)
Definition: pagechg.cxx:2067
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:88
vcl::Window * GetWindow()
bool bAFormatByInpDelSpacesAtSttEnd
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:389
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:1353
virtual css::uno::Reference< css::frame::XController > SAL_CALL getCurrentController() override
#define RES_CHRATR_END
Definition: hintids.hxx:114
void Reactivate(SwDocShell *pNewDocShell)
Definition: unotxdoc.cxx:1456
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotxdoc.cxx:1830
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:1432
const SwView & GetView() const
Definition: wrtsh.hxx:426
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:2650
sal_Int32 PrintSource(OutputDevice *pOutDev, sal_Int32 nPage, bool bCalcNumPagesOnly)
Definition: srcview.cxx:682
FUNC_TYPE const nType
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:4195
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:458
static void CalculatePagePairsForProspectPrinting(const SwRootFrame &rLayout, SwRenderData &rData, const SwPrintUIOptions &rOptions, sal_Int32 nDocPageCount)
Definition: doc.cxx:920
SwCreateDrawTable
Definition: unotxdoc.hxx:580
char sal_Char
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unotxdoc.cxx:4139