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