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