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