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