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