summaryrefslogtreecommitdiff
path: root/sw/source/uibase/uno/unotxdoc.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase/uno/unotxdoc.cxx')
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx1336
1 files changed, 748 insertions, 588 deletions
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 1a0615b0f09f..d2641b6c4db4 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -19,10 +19,12 @@
#include <sal/config.h>
#include <officecfg/Office/Common.hxx>
+#include <comphelper/dispatchcommand.hxx>
+#include <comphelper/propertysequence.hxx>
#include <comphelper/string.hxx>
#include <AnnotationWin.hxx>
#include <o3tl/any.hxx>
-#include <osl/mutex.hxx>
+#include <utility>
#include <vcl/virdev.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/svapp.hxx>
@@ -30,12 +32,13 @@
#include <sfx2/bindings.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/lokhelper.hxx>
+#include <sfx2/LokControlHandler.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/printer.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <toolkit/awt/vclxdevice.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
-#include <sfx2/lokcharthelper.hxx>
+#include <sfx2/lokcomponenthelpers.hxx>
#include <sfx2/ipclient.hxx>
#include <editeng/svxacorr.hxx>
#include <editeng/acorrcfg.hxx>
@@ -51,6 +54,7 @@
#include <rootfrm.hxx>
#include <svl/stritem.hxx>
#include <unotxdoc.hxx>
+#include <svl/numformat.hxx>
#include <svl/numuno.hxx>
#include <fldbas.hxx>
#include <unomap.hxx>
@@ -81,9 +85,10 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/NoSupportException.hpp>
-#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/lang/NotInitializedException.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/document/RedlineDisplayType.hpp>
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
#include <com/sun/star/frame/XController.hpp>
@@ -111,18 +116,17 @@
#include <IDocumentStatistics.hxx>
#include <IDocumentStylePoolAccess.hxx>
#include <IDocumentState.hxx>
-#include <svl/zforlist.hxx>
#include <drawdoc.hxx>
#include <SwStyleNameMapper.hxx>
#include <osl/file.hxx>
#include <comphelper/lok.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/storagehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <unotools/saveopt.hxx>
+#include <sfx2/dispatch.hxx>
#include <swruler.hxx>
#include <docufld.hxx>
-
#include <EnhancedPDFExportHelper.hxx>
#include <numrule.hxx>
@@ -153,16 +157,24 @@
#include <editeng/editview.hxx>
#include <svx/svdoutl.hxx>
#include <svx/svdview.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include <comphelper/servicehelper.hxx>
#include <memory>
#include <redline.hxx>
#include <DocumentRedlineManager.hxx>
#include <xmloff/odffields.hxx>
#include <tools/json_writer.hxx>
+#include <tools/UnitConversion.hxx>
#include <svx/svdpage.hxx>
+#include <o3tl/string_view.hxx>
+#include <comphelper/sequenceashashmap.hxx>
-#define TWIPS_PER_PIXEL 15
+#include <IDocumentOutlineNodes.hxx>
+#include <SearchResultLocator.hxx>
+#include <textcontentcontrol.hxx>
+#include <unocontentcontrol.hxx>
+#include <unoport.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::text;
@@ -256,35 +268,26 @@ static void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell const * pDocShel
class SwXTextDocument::Impl
{
-private:
- ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
-
public:
- ::comphelper::OInterfaceContainerHelper2 m_RefreshListeners;
-
- Impl() : m_RefreshListeners(m_Mutex) { }
-
+ std::mutex m_Mutex; // just for OInterfaceContainerHelper4
+ ::comphelper::OInterfaceContainerHelper4<css::util::XRefreshListener> m_RefreshListeners;
};
-namespace
-{
- class theSwXTextDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextDocumentUnoTunnelId > {};
-}
-
const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId()
{
- return theSwXTextDocumentUnoTunnelId::get().getSeq();
+ static const comphelper::UnoIdInit theSwXTextDocumentUnoTunnelId;
+ return theSwXTextDocumentUnoTunnelId.getSeq();
}
sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId )
{
- if( isUnoTunnelId<SwXTextDocument>(rId) )
+ if( comphelper::isUnoTunnelId<SwXTextDocument>(rId) )
{
- return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ return comphelper::getSomething_cast(this);
}
- if( isUnoTunnelId<SfxObjectShell>(rId) )
+ if( comphelper::isUnoTunnelId<SfxObjectShell>(rId) )
{
- return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(m_pDocShell ));
+ return comphelper::getSomething_cast(m_pDocShell);
}
sal_Int64 nRet = SfxBaseModel::getSomething( rId );
@@ -333,21 +336,16 @@ Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType )
return aRet;
}
-void SAL_CALL SwXTextDocument::acquire()throw()
+void SAL_CALL SwXTextDocument::acquire()noexcept
{
SfxBaseModel::acquire();
}
-void SAL_CALL SwXTextDocument::release()throw()
+void SAL_CALL SwXTextDocument::release()noexcept
{
SfxBaseModel::release();
}
-Reference< XAdapter > SwXTextDocument::queryAdapter( )
-{
- return SfxBaseModel::queryAdapter();
-}
-
Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes()
{
Sequence< uno::Type > aNumTypes;
@@ -372,50 +370,39 @@ Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes()
}
SwXTextDocument::SwXTextDocument(SwDocShell* pShell)
- : SfxBaseModel(pShell)
+ : SwXTextDocumentBaseClass(pShell)
, m_pImpl(new Impl)
,
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)),
-
m_pDocShell(pShell),
-
m_bObjectValid(pShell != nullptr),
-
- m_pDrawPage(nullptr),
- mxXDrawPage(),
- m_pBodyText(nullptr),
- mxXNumberingRules(),
- mxXFootnotes(),
- mxXFootnoteSettings(),
- mxXEndnotes(),
- mxXEndnoteSettings(),
- mxXReferenceMarks(),
- mxXTextFieldTypes(),
- mxXTextFieldMasters(),
- mxXTextSections(),
- mxXBookmarks(),
- mxXTextTables(),
- mxXTextFrames(),
- mxXGraphicObjects(),
- mxXEmbeddedObjects(),
- mxXStyleFamilies(),
- mxXAutoStyles(),
- mxXChapterNumbering(),
- mxXDocumentIndexes(),
-
- mxXLineNumberingProperties(),
- mxLinkTargetSupplier(),
- mxXRedlines(),
m_pHiddenViewFrame(nullptr),
// #i117783#
m_bApplyPagePrintSettingsFromXPagePrintable( false )
{
}
+void SwXTextDocument::ThrowIfInvalid() const
+{
+ if (!m_bObjectValid)
+ throw DisposedException(u"SwXTextDocument not valid"_ustr,
+ const_cast<SwXTextDocument*>(this)->getXWeak());
+}
+
+SwDoc& SwXTextDocument::GetDocOrThrow() const
+{
+ ThrowIfInvalid();
+ if (SwDoc* pDoc = m_pDocShell->GetDoc())
+ return *pDoc;
+ throw css::lang::NotInitializedException(
+ u"Document not initialized by a call to attachResource() or load()"_ustr,
+ const_cast<SwXTextDocument*>(this)->getXWeak());
+}
+
SdrModel& SwXTextDocument::getSdrModelFromUnoModel() const
{
- OSL_ENSURE(m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetOrCreateDrawModel(), "No SdrModel in SwDoc, should not happen");
- return *m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
+ assert(GetDocOrThrow().getIDocumentDrawModelAccess().GetOrCreateDrawModel());
+ return *GetDocOrThrow().getIDocumentDrawModelAccess().GetDrawModel();
}
SwXTextDocument::~SwXTextDocument()
@@ -442,55 +429,53 @@ SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper ()
{
if(!mxPropertyHelper.is())
{
- mxPropertyHelper = new SwXDocumentPropertyHelper(*m_pDocShell->GetDoc());
+ mxPropertyHelper = new SwXDocumentPropertyHelper(GetDocOrThrow());
}
return mxPropertyHelper.get();
}
void SwXTextDocument::GetNumberFormatter()
{
- if(!IsValid())
+ if (!m_bObjectValid)
return;
if(!m_xNumFormatAgg.is())
{
if ( m_pDocShell->GetDoc() )
{
- SvNumberFormatsSupplierObj* pNumFormat = new SvNumberFormatsSupplierObj(
+ rtl::Reference<SvNumberFormatsSupplierObj> pNumFormat = new SvNumberFormatsSupplierObj(
m_pDocShell->GetDoc()->GetNumberFormatter());
- Reference< util::XNumberFormatsSupplier > xTmp = pNumFormat;
- m_xNumFormatAgg.set(xTmp, UNO_QUERY);
+ m_xNumFormatAgg = pNumFormat;
}
if(m_xNumFormatAgg.is())
- m_xNumFormatAgg->setDelegator(static_cast<cppu::OWeakObject*>(static_cast<SwXTextDocumentBaseClass*>(this)));
+ m_xNumFormatAgg->setDelegator(getXWeak());
}
else
{
const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
Any aNumTunnel = m_xNumFormatAgg->queryAggregation(rTunnelType);
- SvNumberFormatsSupplierObj* pNumFormat = nullptr;
Reference< XUnoTunnel > xNumTunnel;
- if(aNumTunnel >>= xNumTunnel)
- {
- pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
- xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
-
- }
+ aNumTunnel >>= xNumTunnel;
+ SvNumberFormatsSupplierObj* pNumFormat
+ = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(xNumTunnel);
OSL_ENSURE(pNumFormat, "No number formatter available");
if (pNumFormat && !pNumFormat->GetNumberFormatter())
- pNumFormat->SetNumberFormatter(m_pDocShell->GetDoc()->GetNumberFormatter());
+ pNumFormat->SetNumberFormatter(GetDocOrThrow().GetNumberFormatter());
}
}
Reference< XText > SwXTextDocument::getText()
{
+ return getBodyText();
+}
+
+rtl::Reference< SwXBodyText > SwXTextDocument::getBodyText()
+{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!m_xBodyText.is())
{
- m_pBodyText = new SwXBodyText(m_pDocShell->GetDoc());
- m_xBodyText = m_pBodyText;
+ m_xBodyText = new SwXBodyText(m_pDocShell->GetDoc());
}
return m_xBodyText;
}
@@ -498,15 +483,13 @@ Reference< XText > SwXTextDocument::getText()
void SwXTextDocument::reformat()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
}
void SwXTextDocument::lockControllers()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
maActionArr.emplace_front(new UnoActionContext(m_pDocShell->GetDoc()));
}
@@ -540,7 +523,7 @@ Reference< XInterface > SwXTextDocument::getCurrentSelection()
{
SolarMutexGuard aGuard;
Reference< XInterface > xRef;
- if(IsValid())
+ if (m_bObjectValid)
{
SwView* pView = static_cast<SwView*>(SfxViewShell::GetFirst(true, checkSfxViewShell<SwView>));
while(pView && pView->GetObjectShell() != m_pDocShell)
@@ -598,7 +581,7 @@ void SwXTextDocument::close( sal_Bool bDeliverOwnership )
m_pDocShell->CallAutomationDocumentEventSinks( "Close", aArgs );
}
SolarMutexGuard aGuard;
- if(IsValid() && m_pHiddenViewFrame)
+ if (m_bObjectValid && m_pHiddenViewFrame)
lcl_DisposeView( m_pHiddenViewFrame, m_pDocShell);
SfxBaseModel::close(bDeliverOwnership);
}
@@ -616,8 +599,7 @@ void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener
Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXLineNumberingProperties.is())
{
@@ -629,8 +611,7 @@ Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties()
Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXChapterNumbering.is())
{
mxXChapterNumbering = new SwXChapterNumbering(*m_pDocShell);
@@ -641,8 +622,7 @@ Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules()
Reference< XIndexAccess > SwXTextDocument::getNumberingRules()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXNumberingRules.is() )
{
mxXNumberingRules = new SwXNumberingRulesCollection( m_pDocShell->GetDoc() );
@@ -653,8 +633,7 @@ Reference< XIndexAccess > SwXTextDocument::getNumberingRules()
Reference< XIndexAccess > SwXTextDocument::getFootnotes()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXFootnotes.is())
{
mxXFootnotes = new SwXFootnotes(false, m_pDocShell->GetDoc());
@@ -666,8 +645,7 @@ Reference< XPropertySet > SAL_CALL
SwXTextDocument::getFootnoteSettings()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXFootnoteSettings.is())
{
mxXFootnoteSettings = new SwXFootnoteProperties(m_pDocShell->GetDoc());
@@ -678,8 +656,7 @@ Reference< XPropertySet > SAL_CALL
Reference< XIndexAccess > SwXTextDocument::getEndnotes()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXEndnotes.is())
{
mxXEndnotes = new SwXFootnotes(true, m_pDocShell->GetDoc());
@@ -690,8 +667,7 @@ Reference< XIndexAccess > SwXTextDocument::getEndnotes()
Reference< XPropertySet > SwXTextDocument::getEndnoteSettings()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXEndnoteSettings.is())
{
mxXEndnoteSettings = new SwXEndnoteProperties(m_pDocShell->GetDoc());
@@ -699,20 +675,26 @@ Reference< XPropertySet > SwXTextDocument::getEndnoteSettings()
return mxXEndnoteSettings;
}
-Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor()
+Reference< XIndexAccess > SwXTextDocument::getContentControls()
{
SolarMutexGuard aGuard;
- Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch;
- return xRet;
+ ThrowIfInvalid();
+ if(!mxXContentControls.is())
+ {
+ mxXContentControls = new SwXContentControls(m_pDocShell->GetDoc());
+ }
+ return mxXContentControls;
+}
+
+Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor()
+{
+ return new SwXTextSearch;
}
SwUnoCursor* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCursor)
{
- getText();
- XText *const pText = m_xBodyText.get();
- SwXBodyText* pBText = static_cast<SwXBodyText*>(pText);
- SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true);
- xCursor.set( static_cast<text::XWordCursor*>(pXTextCursor) );
+ rtl::Reference<SwXTextCursor> pXTextCursor = getBodyText()->CreateTextCursor(true);
+ xCursor.set( static_cast<text::XWordCursor*>(pXTextCursor.get()) );
auto& rUnoCursor(pXTextCursor->GetCursor());
rUnoCursor.SetRemainInSection(false);
@@ -722,17 +704,14 @@ SwUnoCursor* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & x
sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc)
{
SolarMutexGuard aGuard;
- Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY_THROW);
- if(!IsValid() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
+ auto* pSearch = dynamic_cast<SwXTextSearch*>(xDesc.get());
+ if (!pSearch)
+ throw DisposedException("", getXWeak());
Reference< XTextCursor > xCursor;
auto pUnoCursor(CreateCursorForSearch(xCursor));
-
- const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
- xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
-
- int eRanges(FindRanges::InBody|FindRanges::InSelAll);
+ FindRanges eRanges(FindRanges::InBody|FindRanges::InSelAll);
i18nutil::SearchOptions2 aSearchOpt;
pSearch->FillSearchOptions( aSearchOpt );
@@ -742,27 +721,26 @@ sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor >
// Search should take place anywhere
pUnoCursor->SetRemainInSection(false);
- sal_uInt32 nResult;
+ sal_Int32 nResult;
UnoActionContext aContext(m_pDocShell->GetDoc());
//try attribute search first
if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes())
{
- SfxItemSet aSearch(m_pDocShell->GetDoc()->GetAttrPool(),
- svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ auto& pool = GetDocOrThrow().GetAttrPool();
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END-1,
RES_PARATR_BEGIN, RES_PARATR_END-1,
- RES_FRMATR_BEGIN, RES_FRMATR_END-1>{});
- SfxItemSet aReplace(m_pDocShell->GetDoc()->GetAttrPool(),
- svl::Items<RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1> aSearch(pool);
+ SfxItemSetFixed<RES_CHRATR_BEGIN, RES_CHRATR_END-1,
RES_PARATR_BEGIN, RES_PARATR_END-1,
- RES_FRMATR_BEGIN, RES_FRMATR_END-1>{});
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1> aReplace(pool);
pSearch->FillSearchItemSet(aSearch);
pSearch->FillReplaceItemSet(aReplace);
bool bCancel;
- nResult = static_cast<sal_Int32>(pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
+ nResult = pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
eStart, eEnd, bCancel,
- static_cast<FindRanges>(eRanges),
+ eRanges,
!pSearch->m_sSearchText.isEmpty() ? &aSearchOpt : nullptr,
- &aReplace ));
+ &aReplace );
}
else if(pSearch->m_bStyles)
{
@@ -772,7 +750,7 @@ sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor >
bool bCancel;
nResult = pUnoCursor->FindFormat(*pSearchColl,
eStart, eEnd, bCancel,
- static_cast<FindRanges>(eRanges), pReplaceColl );
+ eRanges, pReplaceColl );
}
else
@@ -781,19 +759,16 @@ sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor >
bool bCancel;
nResult = pUnoCursor->Find_Text(aSearchOpt, false/*bSearchInNotes*/,
eStart, eEnd, bCancel,
- static_cast<FindRanges>(eRanges),
+ eRanges,
true );
}
- return static_cast<sal_Int32>(nResult);
+ return nResult;
}
Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor()
{
- SolarMutexGuard aGuard;
- Reference< util::XSearchDescriptor > xRet = new SwXTextSearch;
- return xRet;
-
+ return new SwXTextSearch;
}
// Used for findAll/First/Next
@@ -804,8 +779,9 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor >
sal_Int32& nResult,
Reference< XInterface > const & xLastResult)
{
- const auto pSearch = comphelper::getUnoTunnelImplementation<SwXTextSearch>(xDesc);
- if(!IsValid() || !pSearch)
+ ThrowIfInvalid();
+ const auto pSearch = dynamic_cast<SwXTextSearch*>(xDesc.get());
+ if (!pSearch)
return nullptr;
auto pUnoCursor(CreateCursorForSearch(xCursor));
@@ -813,13 +789,7 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor >
bool bParentInExtra = false;
if(xLastResult.is())
{
- Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
- OTextCursorHelper* pPosCursor = nullptr;
- if(xCursorTunnel.is())
- {
- pPosCursor = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
- OTextCursorHelper::getUnoTunnelId()));
- }
+ OTextCursorHelper* pPosCursor = dynamic_cast<OTextCursorHelper*>(xLastResult.get());
SwPaM* pCursor = pPosCursor ? pPosCursor->GetPaM() : nullptr;
if(pCursor)
{
@@ -828,12 +798,7 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor >
}
else
{
- SwXTextRange* pRange = nullptr;
- if(xCursorTunnel.is())
- {
- pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
- SwXTextRange::getUnoTunnelId()));
- }
+ SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xLastResult.get());
if(!pRange)
return nullptr;
pRange->GetPositions(*pUnoCursor);
@@ -844,7 +809,7 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor >
pUnoCursor->DeleteMark();
}
}
- const SwNode& rRangeNode = pUnoCursor->GetNode();
+ const SwNode& rRangeNode = pUnoCursor->GetPointNode();
bParentInExtra = rRangeNode.FindFlyStartNode() ||
rRangeNode.FindFootnoteStartNode() ||
rRangeNode.FindHeaderStartNode() ||
@@ -876,19 +841,18 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor >
//try attribute search first
if(pSearch->HasSearchAttributes())
{
- SfxItemSet aSearch(
- m_pDocShell->GetDoc()->GetAttrPool(),
- svl::Items<
+ SfxItemSetFixed<
RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
RES_TXTATR_INETFMT, RES_TXTATR_CHARFMT,
RES_PARATR_BEGIN, RES_PARATR_END - 1,
- RES_FRMATR_BEGIN, RES_FRMATR_END - 1>{});
+ RES_FRMATR_BEGIN, RES_FRMATR_END - 1>
+ aSearch( GetDocOrThrow().GetAttrPool() );
pSearch->FillSearchItemSet(aSearch);
bool bCancel;
- nResult = static_cast<sal_Int32>(pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
+ nResult = pUnoCursor->FindAttrs(aSearch, !pSearch->m_bStyles,
eStart, eEnd, bCancel,
eRanges,
- !pSearch->m_sSearchText.isEmpty() ? &aSearchOpt : nullptr ));
+ !pSearch->m_sSearchText.isEmpty() ? &aSearchOpt : nullptr );
}
else if(pSearch->m_bStyles)
{
@@ -896,17 +860,17 @@ SwUnoCursor* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor >
//pSearch->sReplaceText
SwTextFormatColl *pReplaceColl = nullptr;
bool bCancel;
- nResult = static_cast<sal_Int32>(pUnoCursor->FindFormat(*pSearchColl,
+ nResult = pUnoCursor->FindFormat(*pSearchColl,
eStart, eEnd, bCancel,
- eRanges, pReplaceColl ));
+ eRanges, pReplaceColl );
}
else
{
//todo/mba: assuming that notes should be omitted
bool bCancel;
- nResult = static_cast<sal_Int32>(pUnoCursor->Find_Text(aSearchOpt, false/*bSearchInNotes*/,
+ nResult = pUnoCursor->Find_Text(aSearchOpt, false/*bSearchInNotes*/,
eStart, eEnd, bCancel,
- eRanges ));
+ eRanges );
}
if(nResult || (eRanges&(FindRanges::InSelAll|FindRanges::InOther)))
break;
@@ -943,7 +907,7 @@ Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSear
if(nResult)
{
const uno::Reference< text::XText > xParent =
- ::sw::CreateParentXText(*m_pDocShell->GetDoc(),
+ ::sw::CreateParentXText(GetDocOrThrow(),
*pResultCursor->GetPoint());
xRet = *new SwXTextCursor(xParent, *pResultCursor);
}
@@ -965,7 +929,7 @@ Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface >
if(nResult)
{
const uno::Reference< text::XText > xParent =
- ::sw::CreateParentXText(*m_pDocShell->GetDoc(),
+ ::sw::CreateParentXText(GetDocOrThrow(),
*pResultCursor->GetPoint());
xRet = *new SwXTextCursor(xParent, *pResultCursor);
@@ -977,18 +941,17 @@ Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings()
{
SolarMutexGuard aGuard;
Sequence< beans::PropertyValue > aSeq(9);
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
beans::PropertyValue* pArray = aSeq.getArray();
SwPagePreviewPrtData aData;
- const SwPagePreviewPrtData* pData = m_pDocShell->GetDoc()->GetPreviewPrtData();
+ const SwPagePreviewPrtData* pData = GetDocOrThrow().GetPreviewPrtData();
if(pData)
aData = *pData;
Any aVal;
- aVal <<= static_cast<sal_Int16>(aData.GetRow());
+ aVal <<= aData.GetRow();
pArray[0] = beans::PropertyValue("PageRows", -1, aVal, PropertyState_DIRECT_VALUE);
- aVal <<= static_cast<sal_Int16>(aData.GetCol());
+ aVal <<= aData.GetCol();
pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE);
aVal <<= static_cast<sal_Int32>(convertTwipToMm100(aData.GetLeftSpace()));
pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE);
@@ -1027,10 +990,11 @@ static sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, bool& bException)
return nRet;
}
-static OUString lcl_CreateOutlineString( size_t nIndex,
- const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
+static OUString lcl_CreateOutlineString(const size_t nIndex, const SwDoc* pDoc)
{
OUStringBuffer sEntry;
+ const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
+ const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
const SwTextNode * pTextNd = rOutlineNodes[ nIndex ]->GetTextNode();
SwNumberTree::tNumberVector aNumVector = pTextNd->GetNumberVector();
if( pOutlRule && pTextNd->GetNumRule())
@@ -1041,23 +1005,23 @@ static OUString lcl_CreateOutlineString( size_t nIndex,
tools::Long nVal = aNumVector[nLevel];
nVal ++;
nVal -= pOutlRule->Get(nLevel).GetStart();
- sEntry.append(OUString::number( nVal ));
- sEntry.append(".");
+ sEntry.append( OUString::number(nVal) + ".");
}
- sEntry.append( rOutlineNodes[ nIndex ]->
- GetTextNode()->GetExpandText(nullptr) );
+ OUString sOutlineText = pDoc->getIDocumentOutlineNodes().getOutlineText(
+ nIndex, pDoc->GetDocShell()->GetWrtShell()->GetLayout(), false);
+ sEntry.append(sOutlineText);
return sEntry.makeStringAndClear();
}
void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings)
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
SwPagePreviewPrtData aData;
+ SwDoc& rDoc = GetDocOrThrow();
//if only a few properties are coming, then use the current settings
- const SwPagePreviewPrtData* pData = m_pDocShell->GetDoc()->GetPreviewPrtData();
+ const SwPagePreviewPrtData* pData = rDoc.GetPreviewPrtData();
if(pData)
aData = *pData;
for(const beans::PropertyValue& rProperty : aSettings)
@@ -1070,42 +1034,42 @@ void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue
{
if(!nVal || nVal > 0xff)
throw RuntimeException("Invalid value");
- aData.SetRow(static_cast<sal_uInt8>(nVal));
+ aData.SetRow(nVal);
}
else if(sName == "PageColumns")
{
if(!nVal || nVal > 0xff)
throw RuntimeException("Invalid value");
- aData.SetCol(static_cast<sal_uInt8>(nVal));
+ aData.SetCol(nVal);
}
else if(sName == "LeftMargin")
{
- aData.SetLeftSpace(convertMm100ToTwip(nVal));
+ aData.SetLeftSpace(o3tl::toTwips(nVal, o3tl::Length::mm100));
}
else if(sName == "RightMargin")
{
- aData.SetRightSpace(convertMm100ToTwip(nVal));
+ aData.SetRightSpace(o3tl::toTwips(nVal, o3tl::Length::mm100));
}
else if(sName == "TopMargin")
{
- aData.SetTopSpace(convertMm100ToTwip(nVal));
+ aData.SetTopSpace(o3tl::toTwips(nVal, o3tl::Length::mm100));
}
else if(sName == "BottomMargin")
{
- aData.SetBottomSpace(convertMm100ToTwip(nVal));
+ aData.SetBottomSpace(o3tl::toTwips(nVal, o3tl::Length::mm100));
}
else if(sName == "HoriMargin")
{
- aData.SetHorzSpace(convertMm100ToTwip(nVal));
+ aData.SetHorzSpace(o3tl::toTwips(nVal, o3tl::Length::mm100));
}
else if(sName == "VertMargin")
{
- aData.SetVertSpace(convertMm100ToTwip(nVal));
+ aData.SetVertSpace(o3tl::toTwips(nVal, o3tl::Length::mm100));
}
else if(sName == "IsLandscape")
{
- auto b = o3tl::tryAccess<bool>(rVal);
- bException = !b;
+ std::optional<const bool> b = o3tl::tryAccess<bool>(rVal);
+ bException = !b.has_value();
if (b)
{
aData.SetLandscape(*b);
@@ -1116,19 +1080,18 @@ void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue
if(bException)
throw RuntimeException();
}
- m_pDocShell->GetDoc()->SetPreviewPrtData(&aData);
+ rDoc.SetPreviewPrtData(&aData);
}
void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions)
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
SfxViewFrame* pFrame = SfxViewFrame::LoadHiddenDocument( *m_pDocShell, SfxInterfaceId(7) );
SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SfxCallMode::SYNCHRON,
- m_pDocShell->GetDoc()->GetAttrPool());
+ GetDocOrThrow().GetAttrPool());
aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, true));
for ( const beans::PropertyValue &rProp : xOptions )
@@ -1162,8 +1125,8 @@ void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOption
// Collate-Property
else if ( rProp.Name == UNO_NAME_COLLATE )
{
- auto b = o3tl::tryAccess<bool>(rProp.Value);
- if ( !b )
+ std::optional<const bool> b = o3tl::tryAccess<bool>(rProp.Value);
+ if ( !b.has_value() )
throw IllegalArgumentException();
aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *b ) );
@@ -1172,8 +1135,8 @@ void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOption
// Sort-Property
else if ( rProp.Name == UNO_NAME_SORT )
{
- auto b = o3tl::tryAccess<bool>(rProp.Value);
- if ( !b )
+ std::optional<const bool> b = o3tl::tryAccess<bool>(rProp.Value);
+ if ( !b.has_value() )
throw IllegalArgumentException();
aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *b ) );
@@ -1202,8 +1165,7 @@ void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOption
Reference< XNameAccess > SwXTextDocument::getReferenceMarks()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXReferenceMarks.is())
{
mxXReferenceMarks = new SwXReferenceMarks(m_pDocShell->GetDoc());
@@ -1214,8 +1176,7 @@ Reference< XNameAccess > SwXTextDocument::getReferenceMarks()
Reference< XEnumerationAccess > SwXTextDocument::getTextFields()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXTextFieldTypes.is())
{
mxXTextFieldTypes = new SwXTextFieldTypes(m_pDocShell->GetDoc());
@@ -1226,8 +1187,7 @@ Reference< XEnumerationAccess > SwXTextDocument::getTextFields()
Reference< XNameAccess > SwXTextDocument::getTextFieldMasters()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXTextFieldMasters.is())
{
mxXTextFieldMasters = new SwXTextFieldMasters(m_pDocShell->GetDoc());
@@ -1238,8 +1198,7 @@ Reference< XNameAccess > SwXTextDocument::getTextFieldMasters()
Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXEmbeddedObjects.is())
{
mxXEmbeddedObjects = new SwXTextEmbeddedObjects(m_pDocShell->GetDoc());
@@ -1250,8 +1209,7 @@ Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects()
Reference< XNameAccess > SwXTextDocument::getBookmarks()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXBookmarks.is())
{
mxXBookmarks = new SwXBookmarks(m_pDocShell->GetDoc());
@@ -1262,8 +1220,7 @@ Reference< XNameAccess > SwXTextDocument::getBookmarks()
Reference< XNameAccess > SwXTextDocument::getTextSections()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXTextSections.is())
{
mxXTextSections = new SwXTextSections(m_pDocShell->GetDoc());
@@ -1274,8 +1231,7 @@ Reference< XNameAccess > SwXTextDocument::getTextSections()
Reference< XNameAccess > SwXTextDocument::getTextTables()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXTextTables.is())
{
mxXTextTables = new SwXTextTables(m_pDocShell->GetDoc());
@@ -1286,8 +1242,7 @@ Reference< XNameAccess > SwXTextDocument::getTextTables()
Reference< XNameAccess > SwXTextDocument::getGraphicObjects()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXGraphicObjects.is())
{
mxXGraphicObjects = new SwXTextGraphicObjects(m_pDocShell->GetDoc());
@@ -1298,8 +1253,7 @@ Reference< XNameAccess > SwXTextDocument::getGraphicObjects()
Reference< XNameAccess > SwXTextDocument::getTextFrames()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXTextFrames.is())
{
mxXTextFrames = new SwXTextFrames(m_pDocShell->GetDoc());
@@ -1310,8 +1264,7 @@ Reference< XNameAccess > SwXTextDocument::getTextFrames()
Reference< XNameAccess > SwXTextDocument::getStyleFamilies()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXStyleFamilies.is())
{
mxXStyleFamilies = new SwXStyleFamilies(*m_pDocShell);
@@ -1322,8 +1275,7 @@ Reference< XNameAccess > SwXTextDocument::getStyleFamilies()
uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXAutoStyles.is())
{
mxXAutoStyles = new SwXAutoStyles(*m_pDocShell);
@@ -1335,19 +1287,16 @@ uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
- if(!mxXDrawPage.is())
+ ThrowIfInvalid();
+ if(!m_xDrawPage.is())
{
- m_pDrawPage = new SwXDrawPage(m_pDocShell->GetDoc());
- mxXDrawPage = m_pDrawPage;
- // Create a Reference to trigger the complete initialization of the
- // object. Otherwise in some corner cases it would get initialized
- // at ::InitNewDoc -> which would get called during
- // close() or dispose() -> n#681746
- uno::Reference<lang::XComponent> xTriggerInit( mxXDrawPage, uno::UNO_QUERY );
+ SwDoc& rDoc = GetDocOrThrow();
+ // #i52858#
+ SwDrawModel* pModel = rDoc.getIDocumentDrawModelAccess().GetOrCreateDrawModel();
+ SdrPage* pPage = pModel->GetPage( 0 );
+ m_xDrawPage = new SwFmDrawPage(&rDoc, pPage);
}
- return mxXDrawPage;
+ return m_xDrawPage;
}
namespace {
@@ -1359,7 +1308,7 @@ class SwDrawPagesObj : public cppu::WeakImplHelper<
private:
css::uno::Reference< css::drawing::XDrawPageSupplier > m_xDoc;
public:
- SwDrawPagesObj(const css::uno::Reference< css::drawing::XDrawPageSupplier >& rxDoc) : m_xDoc(rxDoc) {}
+ SwDrawPagesObj(css::uno::Reference< css::drawing::XDrawPageSupplier > xDoc) : m_xDoc(std::move(xDoc)) {}
// XDrawPages
virtual css::uno::Reference< css::drawing::XDrawPage > SAL_CALL
@@ -1383,7 +1332,6 @@ public:
// XElementAccess
virtual css::uno::Type SAL_CALL getElementType() override
{
- SolarMutexGuard aGuard;
return cppu::UnoType<drawing::XDrawPage>::get();
}
@@ -1423,20 +1371,20 @@ void SwXTextDocument::Invalidate()
{
const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
Any aNumTunnel = m_xNumFormatAgg->queryAggregation(rTunnelType);
- SvNumberFormatsSupplierObj* pNumFormat = nullptr;
Reference< XUnoTunnel > xNumTunnel;
- if(aNumTunnel >>= xNumTunnel)
- {
- pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
- xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ aNumTunnel >>= xNumTunnel;
+ SvNumberFormatsSupplierObj* pNumFormat
+ = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(xNumTunnel);
+ OSL_ENSURE(pNumFormat, "No number formatter available");
+ if (pNumFormat)
pNumFormat->SetNumberFormatter(nullptr);
- }
OSL_ENSURE(pNumFormat, "No number formatter available");
}
InitNewDoc();
m_pDocShell = nullptr;
- lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
- m_pImpl->m_RefreshListeners.disposeAndClear(ev);
+ lang::EventObject const ev(getXWeak());
+ std::unique_lock aGuard(m_pImpl->m_Mutex);
+ m_pImpl->m_RefreshListeners.disposeAndClear(aGuard, ev);
}
void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell)
@@ -1452,50 +1400,38 @@ void SwXTextDocument::InitNewDoc()
// first invalidate all collections, then delete references and Set to zero
if(mxXTextTables.is())
{
- XNameAccess* pTables = mxXTextTables.get();
- static_cast<SwXTextTables*>(pTables)->Invalidate();
+ mxXTextTables->Invalidate();
mxXTextTables.clear();
}
if(mxXTextFrames.is())
{
- XNameAccess* pFrames = mxXTextFrames.get();
- static_cast<SwXTextFrames*>(pFrames)->Invalidate();
+ mxXTextFrames->Invalidate();
mxXTextFrames.clear();
}
if(mxXGraphicObjects.is())
{
- XNameAccess* pFrames = mxXGraphicObjects.get();
- static_cast<SwXTextGraphicObjects*>(pFrames)->Invalidate();
+ mxXGraphicObjects->Invalidate();
mxXGraphicObjects.clear();
}
if(mxXEmbeddedObjects.is())
{
- XNameAccess* pOLE = mxXEmbeddedObjects.get();
- static_cast<SwXTextEmbeddedObjects*>(pOLE)->Invalidate();
+ mxXEmbeddedObjects->Invalidate();
mxXEmbeddedObjects.clear();
}
- if(m_xBodyText.is())
- {
- m_xBodyText = nullptr;
- m_pBodyText = nullptr;
- }
+ m_xBodyText.clear();
if(m_xNumFormatAgg.is())
{
const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get();
Any aNumTunnel = m_xNumFormatAgg->queryAggregation(rTunnelType);
- SvNumberFormatsSupplierObj* pNumFormat = nullptr;
Reference< XUnoTunnel > xNumTunnel;
- if(aNumTunnel >>= xNumTunnel)
- {
- pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>(
- xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
-
- }
+ aNumTunnel >>= xNumTunnel;
+ SvNumberFormatsSupplierObj* pNumFormat
+ = comphelper::getFromUnoTunnel<SvNumberFormatsSupplierObj>(xNumTunnel);
OSL_ENSURE(pNumFormat, "No number formatter available");
if (pNumFormat)
pNumFormat->SetNumberFormatter(nullptr);
@@ -1503,126 +1439,114 @@ void SwXTextDocument::InitNewDoc()
if(mxXTextFieldTypes.is())
{
- XEnumerationAccess* pT = mxXTextFieldTypes.get();
- static_cast<SwXTextFieldTypes*>(pT)->Invalidate();
+ mxXTextFieldTypes->Invalidate();
mxXTextFieldTypes.clear();
}
if(mxXTextFieldMasters.is())
{
- XNameAccess* pT = mxXTextFieldMasters.get();
- static_cast<SwXTextFieldMasters*>(pT)->Invalidate();
+ mxXTextFieldMasters->Invalidate();
mxXTextFieldMasters.clear();
}
if(mxXTextSections.is())
{
- XNameAccess* pSect = mxXTextSections.get();
- static_cast<SwXTextSections*>(pSect)->Invalidate();
+ mxXTextSections->Invalidate();
mxXTextSections.clear();
}
- if(mxXDrawPage.is())
+ if(m_xDrawPage.is())
{
// #i91798#, #i91895#
// dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
- uno::Reference<lang::XComponent> xComp( mxXDrawPage, uno::UNO_QUERY );
- xComp->dispose();
- m_pDrawPage->InvalidateSwDoc();
- mxXDrawPage.clear();
+ m_xDrawPage->dispose();
+ m_xDrawPage->InvalidateSwDoc();
+ m_xDrawPage.clear();
}
if ( mxXNumberingRules.is() )
{
- XIndexAccess* pNum = mxXNumberingRules.get();
- static_cast<SwXNumberingRulesCollection*>(pNum)->Invalidate();
+ mxXNumberingRules->Invalidate();
mxXNumberingRules.clear();
}
if(mxXFootnotes.is())
{
- XIndexAccess* pFootnote = mxXFootnotes.get();
- static_cast<SwXFootnotes*>(pFootnote)->Invalidate();
+ mxXFootnotes->Invalidate();
mxXFootnotes.clear();
}
if(mxXEndnotes.is())
{
- XIndexAccess* pFootnote = mxXEndnotes.get();
- static_cast<SwXFootnotes*>(pFootnote)->Invalidate();
+ mxXEndnotes->Invalidate();
mxXEndnotes.clear();
}
+ if(mxXContentControls.is())
+ {
+ mxXContentControls->Invalidate();
+ mxXContentControls.clear();
+ }
+
if(mxXDocumentIndexes.is())
{
- XIndexAccess* pIdxs = mxXDocumentIndexes.get();
- static_cast<SwXDocumentIndexes*>(pIdxs)->Invalidate();
+ mxXDocumentIndexes->Invalidate();
mxXDocumentIndexes.clear();
}
if(mxXStyleFamilies.is())
{
- XNameAccess* pStyles = mxXStyleFamilies.get();
- static_cast<SwXStyleFamilies*>(pStyles)->Invalidate();
+ mxXStyleFamilies->Invalidate();
mxXStyleFamilies.clear();
}
if(mxXAutoStyles.is())
{
- XNameAccess* pStyles = mxXAutoStyles.get();
- static_cast<SwXAutoStyles*>(pStyles)->Invalidate();
+ mxXAutoStyles->Invalidate();
mxXAutoStyles.clear();
}
if(mxXBookmarks.is())
{
- XNameAccess* pBm = mxXBookmarks.get();
- static_cast<SwXBookmarks*>(pBm)->Invalidate();
+ mxXBookmarks->Invalidate();
mxXBookmarks.clear();
}
if(mxXChapterNumbering.is())
{
- XIndexReplace* pCh = mxXChapterNumbering.get();
- static_cast<SwXChapterNumbering*>(pCh)->Invalidate();
+ mxXChapterNumbering->Invalidate();
mxXChapterNumbering.clear();
}
if(mxXFootnoteSettings.is())
{
- XPropertySet* pFntSet = mxXFootnoteSettings.get();
- static_cast<SwXFootnoteProperties*>(pFntSet)->Invalidate();
+ mxXFootnoteSettings->Invalidate();
mxXFootnoteSettings.clear();
}
if(mxXEndnoteSettings.is())
{
- XPropertySet* pEndSet = mxXEndnoteSettings.get();
- static_cast<SwXEndnoteProperties*>(pEndSet)->Invalidate();
+ mxXEndnoteSettings->Invalidate();
mxXEndnoteSettings.clear();
}
if(mxXLineNumberingProperties.is())
{
- XPropertySet* pLine = mxXLineNumberingProperties.get();
- static_cast<SwXLineNumberingProperties*>(pLine)->Invalidate();
+ mxXLineNumberingProperties->Invalidate();
mxXLineNumberingProperties.clear();
}
if(mxXReferenceMarks.is())
{
- XNameAccess* pMarks = mxXReferenceMarks.get();
- static_cast<SwXReferenceMarks*>(pMarks)->Invalidate();
+ mxXReferenceMarks->Invalidate();
mxXReferenceMarks.clear();
}
if(mxLinkTargetSupplier.is())
{
- XNameAccess* pAccess = mxLinkTargetSupplier.get();
- static_cast<SwXLinkTargetSupplier*>(pAccess)->Invalidate();
+ mxLinkTargetSupplier->Invalidate();
mxLinkTargetSupplier.clear();
}
if(mxXRedlines.is())
{
- XEnumerationAccess* pMarks = mxXRedlines.get();
- static_cast<SwXRedlines*>(pMarks)->Invalidate();
+ mxXRedlines->Invalidate();
mxXRedlines.clear();
}
if(mxPropertyHelper.is())
@@ -1637,13 +1561,12 @@ css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
css::uno::Sequence<css::uno::Any> const * arguments)
{
SolarMutexGuard aGuard;
- if (!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
const SwServiceType nType = SwXServiceProvider::GetProviderType(rServiceName);
if (nType != SwServiceType::Invalid)
{
- return SwXServiceProvider::MakeInstance(nType, *m_pDocShell->GetDoc());
+ return SwXServiceProvider::MakeInstance(nType, GetDocOrThrow());
}
if (rServiceName == "com.sun.star.drawing.DashTable")
{
@@ -1679,7 +1602,7 @@ css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
}
if (rServiceName == "com.sun.star.document.ImportEmbeddedObjectResolver")
{
- return static_cast<cppu::OWeakObject *>(
+ return cppu::getXWeak(
new SvXMLEmbeddedObjectHelper(
*m_pDocShell, SvXMLEmbeddedObjectHelperMode::Read));
}
@@ -1690,7 +1613,7 @@ css::uno::Reference<css::uno::XInterface> SwXTextDocument::create(
if (rServiceName == "com.sun.star.chart2.data.DataProvider")
{
return Reference<XInterface>(
- dynamic_cast<chart2::data::XDataProvider *>(
+ cppu::getXWeak(
m_pDocShell->getIDocumentChartDataProviderAccess().
GetChartDataProvider()));
}
@@ -1751,7 +1674,7 @@ Sequence< OUString > SwXTextDocument::getAvailableServiceNames()
if (i != -1)
{
auto nLength = aRet.getLength();
- aRet[i] = aRet[nLength - 1];
+ aRet.getArray()[i] = aRet[nLength - 1];
aRet.realloc( nLength - 1 );
}
Sequence< OUString > aOwn = SwXServiceProvider::GetAllServiceNames();
@@ -1803,8 +1726,7 @@ Sequence< OUString > SwXTextDocument::getSupportedServiceNames()
Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
if(!mxXDocumentIndexes.is())
{
@@ -1822,10 +1744,9 @@ Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo()
void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& aValue)
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
- const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
+ const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
if(!pEntry)
throw UnknownPropertyException(rPropertyName);
@@ -1838,8 +1759,7 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
case WID_DOC_WORD_COUNT :
throw RuntimeException(
"bad WID",
- static_cast< cppu::OWeakObject * >(
- static_cast< SwXTextDocumentBaseClass * >(this)));
+ getXWeak());
case WID_DOC_WORD_SEPARATOR :
{
OUString sDelim;
@@ -1850,19 +1770,21 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
case WID_DOC_CHANGES_RECORD:
case WID_DOC_CHANGES_SHOW:
{
+ SwDoc& rDoc = GetDocOrThrow();
+ sw::DocumentRedlineManager& rRedlineManager = rDoc.GetDocumentRedlineManager();
bool bSet = *o3tl::doAccess<bool>(aValue);
- RedlineFlags eMode = m_pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
+ RedlineFlags eMode = rRedlineManager.GetRedlineFlags();
if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
{
eMode |= RedlineFlags(RedlineFlags::ShowInsert | RedlineFlags::ShowDelete);
if( !bSet )
- m_pDocShell->GetDoc()->GetDocumentRedlineManager().SetHideRedlines(true);
+ rRedlineManager.SetHideRedlines(true);
}
else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
{
eMode = bSet ? eMode|RedlineFlags::On : eMode&~RedlineFlags::On;
}
- m_pDocShell->GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags( eMode );
+ rRedlineManager.SetRedlineFlags(eMode);
}
break;
case WID_DOC_CHANGES_PASSWORD:
@@ -1870,13 +1792,13 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
Sequence <sal_Int8> aNew;
if(aValue >>= aNew)
{
- SwDoc* pDoc = m_pDocShell->GetDoc();
- pDoc->getIDocumentRedlineAccess().SetRedlinePassword(aNew);
+ auto& rRedlineAccess = GetDocOrThrow().getIDocumentRedlineAccess();
+ rRedlineAccess.SetRedlinePassword(aNew);
if(aNew.hasElements())
{
- RedlineFlags eMode = pDoc->getIDocumentRedlineAccess().GetRedlineFlags();
+ RedlineFlags eMode = rRedlineAccess.GetRedlineFlags();
eMode |= RedlineFlags::On;
- pDoc->getIDocumentRedlineAccess().SetRedlineFlags( eMode );
+ rRedlineAccess.SetRedlineFlags(eMode);
}
}
}
@@ -1885,7 +1807,7 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
{
OUString sURL;
aValue >>= sURL;
- m_pDocShell->GetDoc()->SetTOIAutoMarkURL(sURL);
+ GetDocOrThrow().SetTOIAutoMarkURL(sURL);
}
break;
case WID_DOC_HIDE_TIPS :
@@ -1893,7 +1815,8 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
break;
case WID_DOC_REDLINE_DISPLAY:
{
- RedlineFlags eRedMode = m_pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
+ auto& rRedlineAccess = GetDocOrThrow().getIDocumentRedlineAccess();
+ RedlineFlags eRedMode = rRedlineAccess.GetRedlineFlags();
eRedMode = eRedMode & (~RedlineFlags::ShowMask);
sal_Int16 nSet = 0;
aValue >>= nSet;
@@ -1907,82 +1830,75 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
break;
default: throw IllegalArgumentException();
}
- m_pDocShell->GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags(eRedMode);
+ rRedlineAccess.SetRedlineFlags(eRedMode);
}
break;
case WID_DOC_TWO_DIGIT_YEAR:
{
sal_Int16 nYear = 0;
aValue >>= nYear;
- SfxRequest aRequest ( SID_ATTR_YEAR2000, SfxCallMode::SLOT, m_pDocShell->GetDoc()->GetAttrPool());
+ SfxRequest aRequest ( SID_ATTR_YEAR2000, SfxCallMode::SLOT, GetDocOrThrow().GetAttrPool());
aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
m_pDocShell->Execute ( aRequest );
}
break;
case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
{
- SwDrawModel * pDrawDoc = m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
+ auto& rDrawModelAccess = GetDocOrThrow().getIDocumentDrawModelAccess();
bool bAuto = *o3tl::doAccess<bool>(aValue);
+ // if setting to true, and we don't have an
+ // SdrModel, then we are changing the default and
+ // must thus create an SdrModel, if we don't have an
+ // SdrModel and we are leaving the default at false,
+ // we don't need to make an SdrModel and can do nothing
+ // #i52858# - method name changed
+ SwDrawModel* pDrawDoc
+ = bAuto ? rDrawModelAccess.GetOrCreateDrawModel() : rDrawModelAccess.GetDrawModel();
if ( nullptr != pDrawDoc )
pDrawDoc->SetAutoControlFocus( bAuto );
- else if (bAuto)
- {
- // if setting to true, and we don't have an
- // SdrModel, then we are changing the default and
- // must thus create an SdrModel, if we don't have an
- // SdrModel and we are leaving the default at false,
- // we don't need to make an SdrModel and can do nothing
- // #i52858# - method name changed
- pDrawDoc = m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
- pDrawDoc->SetAutoControlFocus ( bAuto );
- }
}
break;
case WID_DOC_APPLY_FORM_DESIGN_MODE:
{
- SwDrawModel * pDrawDoc = m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
+ auto& rDrawModelAccess = GetDocOrThrow().getIDocumentDrawModelAccess();
bool bMode = *o3tl::doAccess<bool>(aValue);
+ // if setting to false, and we don't have an
+ // SdrModel, then we are changing the default and
+ // must thus create an SdrModel, if we don't have an
+ // SdrModel and we are leaving the default at true,
+ // we don't need to make an SdrModel and can do
+ // nothing
+ // #i52858# - method name changed
+ SwDrawModel* pDrawDoc
+ = bMode ? rDrawModelAccess.GetDrawModel() : rDrawModelAccess.GetOrCreateDrawModel();
if ( nullptr != pDrawDoc )
pDrawDoc->SetOpenInDesignMode( bMode );
- else if (!bMode)
- {
- // if setting to false, and we don't have an
- // SdrModel, then we are changing the default and
- // must thus create an SdrModel, if we don't have an
- // SdrModel and we are leaving the default at true,
- // we don't need to make an SdrModel and can do
- // nothing
- // #i52858# - method name changed
- pDrawDoc = m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
- pDrawDoc->SetOpenInDesignMode ( bMode );
- }
}
break;
// #i42634# New property to set the bInReading
// flag at the document, used during binary import
case WID_DOC_LOCK_UPDATES :
{
- SwDoc* pDoc = m_pDocShell->GetDoc();
bool bBool (false);
if( aValue >>= bBool )
{
- pDoc->SetInReading( bBool );
+ GetDocOrThrow().SetInReading( bBool );
}
}
break;
case WID_DOC_WRITERFILTER:
{
- SwDoc* pDoc = m_pDocShell->GetDoc();
+ SwDoc& rDoc = GetDocOrThrow();
bool bBool = {};
if (aValue >>= bBool)
{ // HACK: writerfilter has to use API to set this :(
- bool bOld = pDoc->IsInWriterfilterImport();
- pDoc->SetInWriterfilterImport(bBool);
+ bool bOld = rDoc.IsInWriterfilterImport();
+ rDoc.SetInWriterfilterImport(bBool);
if (bOld && !bBool)
{
- pDoc->getIDocumentFieldsAccess().SetFieldsDirty(false, nullptr, 0);
+ rDoc.getIDocumentFieldsAccess().SetFieldsDirty(false, nullptr, SwNodeOffset(0));
}
}
}
@@ -1995,7 +1911,7 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
{
bool bDefaultPageMode( false );
aValue >>= bDefaultPageMode;
- m_pDocShell->GetDoc()->SetDefaultPageMode( bDefaultPageMode );
+ GetDocOrThrow().SetDefaultPageMode( bDefaultPageMode );
}
break;
case WID_DOC_INTEROP_GRAB_BAG:
@@ -2004,10 +1920,11 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
default:
{
- const SfxPoolItem& rItem = m_pDocShell->GetDoc()->GetDefault(pEntry->nWID);
+ SwDoc& rDoc = GetDocOrThrow();
+ const SfxPoolItem& rItem = rDoc.GetDefault(pEntry->nWID);
std::unique_ptr<SfxPoolItem> pNewItem(rItem.Clone());
pNewItem->PutValue(aValue, pEntry->nMemberId);
- m_pDocShell->GetDoc()->SetDefault(*pNewItem);
+ rDoc.SetDefault(*pNewItem);
}
}
}
@@ -2015,10 +1932,36 @@ void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any&
Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
+
+ if (rPropertyName == "ODFExport_ListNodes")
+ {
+ // A hack to avoid writing random list ids to ODF when they are not referred later
+ // see XMLTextParagraphExport::DocumentListNodes ctor
+
+ // Sequence of nodes, each of them represented by three-element sequence:
+ // [ index, styleIntPtr, list_id ]
+ std::vector<css::uno::Sequence<css::uno::Any>> nodes;
+
+ const SwDoc& rDoc = GetDocOrThrow();
+ for (const SwNumRule* pNumRule : rDoc.GetNumRuleTable())
+ {
+ SwNumRule::tTextNodeList textNodes;
+ pNumRule->GetTextNodeList(textNodes);
+ css::uno::Any styleIntPtr(reinterpret_cast<sal_uInt64>(pNumRule));
+
+ for (const SwTextNode* pTextNode : textNodes)
+ {
+ css::uno::Any index(pTextNode->GetIndex().get());
+ css::uno::Any list_id(pTextNode->GetListId());
+
+ nodes.push_back({ index, styleIntPtr, list_id });
+ }
+ }
+ return css::uno::Any(comphelper::containerToSequence(nodes));
+ }
- const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
+ const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
if(!pEntry)
throw UnknownPropertyException(rPropertyName);
@@ -2032,7 +1975,7 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
case WID_DOC_PARA_COUNT :
case WID_DOC_WORD_COUNT :
{
- const SwDocStat& rStat(m_pDocShell->GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( false, true ));
+ const SwDocStat& rStat(GetDocOrThrow().getIDocumentStatistics().GetUpdatedDocStat( false, true ));
sal_Int32 nValue;
switch(pEntry->nWID)
{
@@ -2051,7 +1994,7 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
case WID_DOC_CHANGES_RECORD:
case WID_DOC_CHANGES_SHOW:
{
- const RedlineFlags eMode = m_pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
+ const RedlineFlags eMode = GetDocOrThrow().getIDocumentRedlineAccess().GetRedlineFlags();
bool bSet = false;
if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
{
@@ -2065,20 +2008,17 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
}
break;
case WID_DOC_CHANGES_PASSWORD:
- {
- SwDoc* pDoc = m_pDocShell->GetDoc();
- aAny <<= pDoc->getIDocumentRedlineAccess().GetRedlinePassword();
- }
+ aAny <<= GetDocOrThrow().getIDocumentRedlineAccess().GetRedlinePassword();
break;
case WID_DOC_AUTO_MARK_URL :
- aAny <<= m_pDocShell->GetDoc()->GetTOIAutoMarkURL();
+ aAny <<= GetDocOrThrow().GetTOIAutoMarkURL();
break;
case WID_DOC_HIDE_TIPS :
aAny <<= SW_MOD()->GetModuleConfig()->IsHideFieldTips();
break;
case WID_DOC_REDLINE_DISPLAY:
{
- RedlineFlags eRedMode = m_pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
+ RedlineFlags eRedMode = GetDocOrThrow().getIDocumentRedlineAccess().GetRedlineFlags();
eRedMode = eRedMode & RedlineFlags::ShowMask;
sal_Int16 nRet = RedlineDisplayType::NONE;
if(RedlineFlags::ShowInsert == eRedMode)
@@ -2093,18 +2033,18 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
case WID_DOC_FORBIDDEN_CHARS:
{
GetPropertyHelper();
- Reference<XForbiddenCharacters> xRet(static_cast<cppu::OWeakObject*>(mxPropertyHelper.get()), UNO_QUERY);
+ Reference<XForbiddenCharacters> xRet = mxPropertyHelper;
aAny <<= xRet;
}
break;
case WID_DOC_TWO_DIGIT_YEAR:
{
- aAny <<= static_cast < sal_Int16 > (m_pDocShell->GetDoc()->GetNumberFormatter ()->GetYear2000());
+ aAny <<= static_cast < sal_Int16 > (GetDocOrThrow().GetNumberFormatter ()->GetYear2000());
}
break;
case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
{
- SwDrawModel * pDrawDoc = m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
+ SwDrawModel * pDrawDoc = GetDocOrThrow().getIDocumentDrawModelAccess().GetDrawModel();
bool bAuto;
if ( nullptr != pDrawDoc )
bAuto = pDrawDoc->GetAutoControlFocus();
@@ -2115,7 +2055,7 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
break;
case WID_DOC_APPLY_FORM_DESIGN_MODE:
{
- SwDrawModel * pDrawDoc = m_pDocShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
+ SwDrawModel * pDrawDoc = GetDocOrThrow().getIDocumentDrawModelAccess().GetDrawModel();
bool bMode;
if ( nullptr != pDrawDoc )
bMode = pDrawDoc->GetOpenInDesignMode();
@@ -2144,7 +2084,7 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
aAny <<= getRuntimeUID();
break;
case WID_DOC_LOCK_UPDATES :
- aAny <<= m_pDocShell->GetDoc()->IsInReading();
+ aAny <<= GetDocOrThrow().IsInReading();
break;
case WID_DOC_BUILDID:
aAny <<= maBuildId;
@@ -2155,10 +2095,16 @@ Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
case WID_DOC_INTEROP_GRAB_BAG:
getGrabBagItem(aAny);
break;
+ case WID_DOC_ALLOW_LINK_UPDATE:
+ {
+ comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer = m_pDocShell->getEmbeddedObjectContainer();
+ aAny <<= rEmbeddedObjectContainer.getUserAllowsLinkUpdate();
+ }
+ break;
default:
{
- const SfxPoolItem& rItem = m_pDocShell->GetDoc()->GetDefault(pEntry->nWID);
+ const SfxPoolItem& rItem = GetDocOrThrow().GetDefault(pEntry->nWID);
rItem.QueryValue(aAny, pEntry->nMemberId);
}
}
@@ -2211,16 +2157,16 @@ void SwXTextDocument::NotifyRefreshListeners()
{
// why does SwBaseShell not just call refresh? maybe because it's rSh is
// (sometimes) a different shell than GetWrtShell()?
- lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this));
- m_pImpl->m_RefreshListeners.notifyEach(
+ lang::EventObject const ev(getXWeak());
+ std::unique_lock aGuard(m_pImpl->m_Mutex);
+ m_pImpl->m_RefreshListeners.notifyEach(aGuard,
& util::XRefreshListener::refreshed, ev);
}
void SwXTextDocument::refresh()
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
SwViewShell *pViewShell = m_pDocShell->GetWrtShell();
NotifyRefreshListeners();
@@ -2231,28 +2177,33 @@ void SwXTextDocument::refresh()
void SAL_CALL SwXTextDocument::addRefreshListener(
const Reference<util::XRefreshListener> & xListener)
{
- // no need to lock here as m_pImpl is const and container threadsafe
- m_pImpl->m_RefreshListeners.addInterface(xListener);
+ if (xListener)
+ {
+ std::unique_lock aGuard(m_pImpl->m_Mutex);
+ m_pImpl->m_RefreshListeners.addInterface(aGuard, xListener);
+ }
}
void SAL_CALL SwXTextDocument::removeRefreshListener(
const Reference<util::XRefreshListener> & xListener)
{
- // no need to lock here as m_pImpl is const and container threadsafe
- m_pImpl->m_RefreshListeners.removeInterface(xListener);
+ if (xListener)
+ {
+ std::unique_lock aGuard(m_pImpl->m_Mutex);
+ m_pImpl->m_RefreshListeners.removeInterface(aGuard, xListener);
+ }
}
void SwXTextDocument::updateLinks( )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
- SwDoc* pDoc = m_pDocShell->GetDoc();
- sfx2::LinkManager& rLnkMan = pDoc->getIDocumentLinksAdministration().GetLinkManager();
+ SwDoc& rDoc = GetDocOrThrow();
+ sfx2::LinkManager& rLnkMan = rDoc.getIDocumentLinksAdministration().GetLinkManager();
if( !rLnkMan.GetLinks().empty() )
{
- UnoActionContext aAction(pDoc);
+ UnoActionContext aAction(&rDoc);
rLnkMan.UpdateAllLinks( false, true, nullptr );
}
}
@@ -2261,10 +2212,9 @@ void SwXTextDocument::updateLinks( )
PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
- const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
+ const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
if(!pEntry)
throw UnknownPropertyException(rPropertyName);
return PropertyState_DIRECT_VALUE;
@@ -2275,7 +2225,7 @@ Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Seq
const sal_Int32 nCount = rPropertyNames.getLength();
Sequence < PropertyState > aRet ( nCount );
- std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.begin(),
+ std::transform(rPropertyNames.begin(), rPropertyNames.end(), aRet.getArray(),
[this](const OUString& rName) -> PropertyState { return getPropertyState(rName); });
return aRet;
@@ -2284,10 +2234,9 @@ Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Seq
void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
- const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
+ const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
if(!pEntry)
throw UnknownPropertyException(rPropertyName);
switch(pEntry->nWID)
@@ -2299,10 +2248,9 @@ void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyNa
Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
- const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
+ const SfxItemPropertyMapEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName);
if(!pEntry)
throw UnknownPropertyException(rPropertyName);
Any aAny;
@@ -2322,7 +2270,7 @@ static VclPtr< OutputDevice > lcl_GetOutputDevice( const SwPrintUIOptions &rPrin
aAny >>= xRenderDevice;
if (xRenderDevice.is())
{
- VCLXDevice* pDevice = comphelper::getUnoTunnelImplementation<VCLXDevice>( xRenderDevice );
+ VCLXDevice* pDevice = dynamic_cast<VCLXDevice*>( xRenderDevice.get() );
pOut = pDevice ? pDevice->GetOutputDevice() : VclPtr< OutputDevice >();
}
@@ -2454,12 +2402,9 @@ static void lcl_SavePrintUIOptionsToDocumentPrintData(
SwPrintData aDocPrintData( rDoc.getIDocumentDeviceAccess().getPrintData() );
aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() );
- aDocPrintData.SetPrintTable( true ); // for now it was decided that tables should always be printed
- aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() );
aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() );
aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() );
aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() );
- aDocPrintData.SetPrintReverse( false ); /*handled by print dialog now*/
aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() );
aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) );
aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() );
@@ -2467,7 +2412,6 @@ static void lcl_SavePrintUIOptionsToDocumentPrintData(
aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() );
aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() );
aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() );
- // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself
// arDocPrintData.SetFaxName( s ); n/a in File/Print dialog
aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() );
aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() );
@@ -2480,11 +2424,7 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
const uno::Sequence< beans::PropertyValue >& rxOptions )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- {
- throw DisposedException( OUString(),
- static_cast< XTextDocument* >(this) );
- }
+ ThrowIfInvalid();
const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
bool bIsSwSrcView = false;
@@ -2646,6 +2586,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
}
}
OSL_ENSURE( nRet >= 0, "negative number of pages???" );
+ // tdf#144989 the layout is complete now - prevent DoIdleJobs() from
+ // messing it up, particulary SwDocUpdateField::MakeFieldList_() unhiding
+ // sections
+ pDoc->getIDocumentTimerAccess().BlockIdling();
return nRet;
}
@@ -2656,10 +2600,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
const uno::Sequence< beans::PropertyValue >& rxOptions )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- {
- throw DisposedException("", static_cast< XTextDocument* >(this));
- }
+ ThrowIfInvalid();
const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
bool bIsSwSrcView = false;
@@ -2690,14 +2631,6 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
if (0 > nRenderer)
throw IllegalArgumentException();
- // TODO/mba: we really need a generic way to get the SwViewShell!
- SwViewShell* pVwSh = nullptr;
- SwView* pSwView = dynamic_cast<SwView*>( pView );
- if ( pSwView )
- pVwSh = pSwView->GetWrtShellPtr();
- else
- pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell();
-
sal_Int32 nMaxRenderer = 0;
if (!bIsSwSrcView && m_pRenderData)
{
@@ -2788,42 +2721,51 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
}
else
{
- aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
- aPageSize = awt::Size ( convertTwipToMm100( aTmpSize.Width() ),
- convertTwipToMm100( aTmpSize.Height() ));
- Point aPoint = pVwSh->GetPagePos(nPage);
- aPagePos = awt::Point(convertTwipToMm100(aPoint.X()), convertTwipToMm100(aPoint.Y()));
+ // TODO/mba: we really need a generic way to get the SwViewShell!
+ SwViewShell* pVwSh = nullptr;
+ SwView* pSwView = dynamic_cast<SwView*>( pView );
+ if ( pSwView )
+ pVwSh = pSwView->GetWrtShellPtr();
+ else
+ pVwSh = static_cast<SwPagePreview*>(pView)->GetViewShell();
+
+ if (pVwSh)
+ {
+ aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages );
+ aPageSize = awt::Size ( convertTwipToMm100( aTmpSize.Width() ),
+ convertTwipToMm100( aTmpSize.Height() ));
+ Point aPoint = pVwSh->GetPagePos(nPage);
+ aPagePos = awt::Point(convertTwipToMm100(aPoint.X()), convertTwipToMm100(aPoint.Y()));
+ }
}
sal_Int32 nLen = 3;
- aRenderer.realloc(3);
- aRenderer[0].Name = "PageSize";
- aRenderer[0].Value <<= aPageSize;
- aRenderer[1].Name = "PageIncludesNonprintableArea";
- aRenderer[1].Value <<= true;
- aRenderer[2].Name = "PagePos";
- aRenderer[2].Value <<= aPagePos;
+ aRenderer = { comphelper::makePropertyValue("PageSize", aPageSize),
+ comphelper::makePropertyValue("PageIncludesNonprintableArea", true),
+ comphelper::makePropertyValue("PagePos", aPagePos) };
if (aPreferredPageSize.Width && aPreferredPageSize.Height)
{
++nLen;
aRenderer.realloc( nLen );
- aRenderer[ nLen - 1 ].Name = "PreferredPageSize";
- aRenderer[ nLen - 1 ].Value <<= aPreferredPageSize;
+ auto pRenderer = aRenderer.getArray();
+ pRenderer[ nLen - 1 ].Name = "PreferredPageSize";
+ pRenderer[ nLen - 1 ].Value <<= aPreferredPageSize;
}
if (nPrinterPaperTray >= 0)
{
++nLen;
aRenderer.realloc( nLen );
- aRenderer[ nLen - 1 ].Name = "PrinterPaperTray";
- aRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray;
+ auto pRenderer = aRenderer.getArray();
+ pRenderer[ nLen - 1 ].Name = "PrinterPaperTray";
+ pRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray;
}
}
// #i117783#
if ( m_bApplyPagePrintSettingsFromXPagePrintable )
{
- const SwPagePreviewPrtData* pPagePrintSettings =
- m_pDocShell->GetDoc()->GetPreviewPrtData();
+ SwDoc& rDoc = GetDocOrThrow();
+ const SwPagePreviewPrtData* pPagePrintSettings = rDoc.GetPreviewPrtData();
if ( pPagePrintSettings &&
( pPagePrintSettings->GetRow() > 1 ||
pPagePrintSettings->GetCol() > 1 ) )
@@ -2833,42 +2775,40 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
const sal_Int32 nRenderDataIdxStart = nLen;
nLen += 9;
aRenderer.realloc( nLen );
+ auto pRenderer = aRenderer.getArray();
// put page print settings attribute into render data
const sal_Int32 nRow = pPagePrintSettings->GetRow();
- aRenderer[ nRenderDataIdxStart + 0 ].Name = "NUpRows";
- aRenderer[ nRenderDataIdxStart + 0 ].Value <<= std::max<sal_Int32>( nRow, 1);
+ pRenderer[ nRenderDataIdxStart + 0 ].Name = "NUpRows";
+ pRenderer[ nRenderDataIdxStart + 0 ].Value <<= std::max<sal_Int32>( nRow, 1);
const sal_Int32 nCol = pPagePrintSettings->GetCol();
- aRenderer[ nRenderDataIdxStart + 1 ].Name = "NUpColumns";
- aRenderer[ nRenderDataIdxStart + 1 ].Value <<= std::max<sal_Int32>( nCol, 1);
- aRenderer[ nRenderDataIdxStart + 2 ].Name = "NUpPageMarginLeft";
- aRenderer[ nRenderDataIdxStart + 2 ].Value <<= pPagePrintSettings->GetLeftSpace();
- aRenderer[ nRenderDataIdxStart + 3 ].Name = "NUpPageMarginRight";
- aRenderer[ nRenderDataIdxStart + 3 ].Value <<= pPagePrintSettings->GetRightSpace();
- aRenderer[ nRenderDataIdxStart + 4 ].Name = "NUpPageMarginTop";
- aRenderer[ nRenderDataIdxStart + 4 ].Value <<= pPagePrintSettings->GetTopSpace();
- aRenderer[ nRenderDataIdxStart + 5 ].Name = "NUpPageMarginBottom";
- aRenderer[ nRenderDataIdxStart + 5 ].Value <<= pPagePrintSettings->GetBottomSpace();
- aRenderer[ nRenderDataIdxStart + 6 ].Name = "NUpHorizontalSpacing";
- aRenderer[ nRenderDataIdxStart + 6 ].Value <<= pPagePrintSettings->GetHorzSpace();
- aRenderer[ nRenderDataIdxStart + 7 ].Name = "NUpVerticalSpacing";
- aRenderer[ nRenderDataIdxStart + 7 ].Value <<= pPagePrintSettings->GetVertSpace();
+ pRenderer[ nRenderDataIdxStart + 1 ].Name = "NUpColumns";
+ pRenderer[ nRenderDataIdxStart + 1 ].Value <<= std::max<sal_Int32>( nCol, 1);
+ pRenderer[ nRenderDataIdxStart + 2 ].Name = "NUpPageMarginLeft";
+ pRenderer[ nRenderDataIdxStart + 2 ].Value <<= pPagePrintSettings->GetLeftSpace();
+ pRenderer[ nRenderDataIdxStart + 3 ].Name = "NUpPageMarginRight";
+ pRenderer[ nRenderDataIdxStart + 3 ].Value <<= pPagePrintSettings->GetRightSpace();
+ pRenderer[ nRenderDataIdxStart + 4 ].Name = "NUpPageMarginTop";
+ pRenderer[ nRenderDataIdxStart + 4 ].Value <<= pPagePrintSettings->GetTopSpace();
+ pRenderer[ nRenderDataIdxStart + 5 ].Name = "NUpPageMarginBottom";
+ pRenderer[ nRenderDataIdxStart + 5 ].Value <<= pPagePrintSettings->GetBottomSpace();
+ pRenderer[ nRenderDataIdxStart + 6 ].Name = "NUpHorizontalSpacing";
+ pRenderer[ nRenderDataIdxStart + 6 ].Value <<= pPagePrintSettings->GetHorzSpace();
+ pRenderer[ nRenderDataIdxStart + 7 ].Name = "NUpVerticalSpacing";
+ pRenderer[ nRenderDataIdxStart + 7 ].Value <<= pPagePrintSettings->GetVertSpace();
+ if (Printer* pPrinter = rDoc.getIDocumentDeviceAccess().getPrinter(false))
{
- Printer* pPrinter = m_pDocShell->GetDoc()->getIDocumentDeviceAccess().getPrinter( false );
- if ( pPrinter )
+ awt::Size aNewPageSize;
+ const Size aPageSize = pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
+ aNewPageSize = awt::Size( aPageSize.Width(), aPageSize.Height() );
+ if ( ( pPagePrintSettings->GetLandscape() &&
+ aPageSize.Width() < aPageSize.Height() ) ||
+ ( !pPagePrintSettings->GetLandscape() &&
+ aPageSize.Width() > aPageSize.Height() ) )
{
- awt::Size aNewPageSize;
- const Size aPageSize = pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
- aNewPageSize = awt::Size( aPageSize.Width(), aPageSize.Height() );
- if ( ( pPagePrintSettings->GetLandscape() &&
- aPageSize.Width() < aPageSize.Height() ) ||
- ( !pPagePrintSettings->GetLandscape() &&
- aPageSize.Width() > aPageSize.Height() ) )
- {
- aNewPageSize = awt::Size( aPageSize.Height(), aPageSize.Width() );
- }
- aRenderer[ nRenderDataIdxStart + 8 ].Name = "NUpPaperSize";
- aRenderer[ nRenderDataIdxStart + 8 ].Value <<= aNewPageSize;
+ aNewPageSize = awt::Size( aPageSize.Height(), aPageSize.Width() );
}
+ pRenderer[ nRenderDataIdxStart + 8 ].Name = "NUpPaperSize";
+ pRenderer[ nRenderDataIdxStart + 8 ].Value <<= aNewPageSize;
}
}
@@ -2925,11 +2865,7 @@ void SAL_CALL SwXTextDocument::render(
const uno::Sequence< beans::PropertyValue >& rxOptions )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- {
- throw DisposedException( OUString(),
- static_cast< XTextDocument* >(this) );
- }
+ ThrowIfInvalid();
// due to #110067# (document page count changes sometimes during
// PDF export/printing) we can not check for the upper bound properly.
@@ -3014,8 +2950,14 @@ void SAL_CALL SwXTextDocument::render(
SwWrtShell* pWrtShell = pSwView ? pSwView->GetWrtShellPtr() : nullptr;
- SwPrintData const& rSwPrtOptions =
- *m_pRenderData->GetSwPrtOptions();
+ SwPrintData rSwPrtOptions = *m_pRenderData->GetSwPrtOptions();
+ if (bIsPDFExport)
+ {
+ rSwPrtOptions.SetPrintPostIts(
+ lcl_GetBoolProperty(rxOptions, "ExportNotesInMargin")
+ ? SwPostItMode::InMargins
+ : SwPostItMode::NONE);
+ }
if (bIsPDFExport && (bFirstPage || bHasPDFExtOutDevData) && pWrtShell)
{
@@ -3058,8 +3000,7 @@ void SAL_CALL SwXTextDocument::render(
// prevent crash described in #i108805
SwDocShell *pRenderDocShell = pDoc->GetDocShell();
- SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet();
- pSet->Put( SfxBoolItem( SID_HIDDEN, false ) );
+ pRenderDocShell->GetMedium()->GetItemSet().Put( SfxBoolItem( SID_HIDDEN, false ) );
}
}
@@ -3069,6 +3010,8 @@ void SAL_CALL SwXTextDocument::render(
}
if( bLastPage )
{
+ // tdf#144989 enable DoIdleJobs() again after last page
+ pDoc->getIDocumentTimerAccess().UnblockIdling();
m_pRenderData.reset();
m_pPrintUIOptions.reset();
}
@@ -3079,35 +3022,29 @@ Reference<XNameContainer> SAL_CALL SwXTextDocument::getXForms()
{
SolarMutexGuard aGuard;
if ( !m_pDocShell )
- throw DisposedException( OUString(), static_cast< XTextDocument* >( this ) );
- SwDoc* pDoc = m_pDocShell->GetDoc();
- return pDoc->getXForms();
+ throw DisposedException(OUString(), getXWeak());
+ return GetDocOrThrow().getXForms();
}
uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
{
SolarMutexGuard aGuard;
- if (!IsValid())
- {
- throw DisposedException("SwXTextDocument not valid",
- static_cast<XTextDocument*>(this));
- }
+ ThrowIfInvalid();
return SwUnoCursorHelper::CreateFlatParagraphIterator(
- *m_pDocShell->GetDoc(), nTextMarkupType, bAutomatic);
+ GetDocOrThrow(), nTextMarkupType, bAutomatic);
}
uno::Reference< util::XCloneable > SwXTextDocument::createClone( )
{
SolarMutexGuard aGuard;
- if(!IsValid())
- throw DisposedException("", static_cast< XTextDocument* >(this));
+ ThrowIfInvalid();
// create a new document - hidden - copy the storage and return it
// SfxObjectShellRef is used here, since the model should control object lifetime after creation
// and thus SfxObjectShellLock is not allowed here
// the model holds reference to the shell, so the shell will not destructed at the end of method
- SfxObjectShellRef pShell = m_pDocShell->GetDoc()->CreateCopy(false, false);
+ SfxObjectShellRef pShell = GetDocOrThrow().CreateCopy(false, false);
uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( );
uno::Sequence< beans::PropertyValue > aTempMediaDescriptor;
@@ -3121,7 +3058,7 @@ void SwXTextDocument::addPasteEventListener(const uno::Reference<text::XPasteLis
{
SolarMutexGuard aGuard;
- if (IsValid() && xListener.is())
+ if (m_bObjectValid && xListener.is())
m_pDocShell->GetWrtShell()->GetPasteListeners().addInterface(xListener);
}
@@ -3130,7 +3067,7 @@ void SwXTextDocument::removePasteEventListener(
{
SolarMutexGuard aGuard;
- if (IsValid() && xListener.is())
+ if (m_bObjectValid && xListener.is())
m_pDocShell->GetWrtShell()->GetPasteListeners().removeInterface(xListener);
}
@@ -3145,6 +3082,17 @@ void SwXTextDocument::paintTile( VirtualDevice &rDevice,
LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+
+ // Draw Form controls
+ comphelper::LibreOfficeKit::setTiledPainting(true);
+ SwDrawModel* pDrawLayer = GetDocOrThrow().getIDocumentDrawModelAccess().GetDrawModel();
+ SdrPage* pPage = pDrawLayer->GetPage(sal_uInt16(0));
+ SdrView* pDrawView = pViewShell->GetDrawView();
+ SwEditWin& rEditWin = m_pDocShell->GetView()->GetEditWin();
+ tools::Rectangle aTileRect(Point(nTilePosX, nTilePosY), Size(nTileWidth, nTileHeight));
+ Size aOutputSize(nOutputWidth, nOutputHeight);
+ LokControlHandler::paintControlTile(pPage, pDrawView, rEditWin, rDevice, aOutputSize, aTileRect);
+ comphelper::LibreOfficeKit::setTiledPainting(false);
}
Size SwXTextDocument::getDocumentSize()
@@ -3156,7 +3104,7 @@ Size SwXTextDocument::getDocumentSize()
aDocSize.Height() + 2 * DOCUMENTBORDER);
}
-void SwXTextDocument::setPart(int nPart)
+void SwXTextDocument::setPart(int nPart, bool /*bAllowChangeFocus*/)
{
SolarMutexGuard aGuard;
@@ -3243,11 +3191,12 @@ void SwXTextDocument::setClientZoom(int nTilePixelWidth_, int /*nTilePixelHeight
return;
SwViewShell* pWrtViewShell = m_pDocShell->GetWrtShell();
- double fScale = nTilePixelWidth_ * TWIPS_PER_PIXEL / (nTileTwipWidth_ * 1.0);
+ double fScale = 100.0 * nTilePixelWidth_ / nTileTwipWidth_
+ * o3tl::convert(1.0, o3tl::Length::px, o3tl::Length::twip);
SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
- if (aOption.GetZoom() != fScale * 100)
+ if (aOption.GetZoom() != fScale)
{
- aOption.SetZoom(fScale * 100);
+ aOption.SetZoom(fScale);
pWrtViewShell->ApplyViewOptions(aOption);
// Changing the zoom value doesn't always trigger the updating of
@@ -3277,7 +3226,7 @@ void SwXTextDocument::getTrackedChanges(tools::JsonWriter& rJson)
return;
const SwRedlineTable& rRedlineTable
- = m_pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+ = GetDocOrThrow().getIDocumentRedlineAccess().GetRedlineTable();
for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
{
auto redlineNode = rJson.startStruct();
@@ -3292,15 +3241,13 @@ void SwXTextDocument::getTrackedChanges(tools::JsonWriter& rJson)
rRedlineTable[i]->GetRedlineData().GetTimeStamp().GetUNODateTime());
rJson.put("dateTime", sDateTime);
- SwContentNode* pContentNd = rRedlineTable[i]->GetContentNode();
+ SwContentNode* pContentNd = rRedlineTable[i]->GetPointContentNode();
SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
if (pView && pContentNd)
{
SwShellCursor aCursor(pView->GetWrtShell(), *(rRedlineTable[i]->Start()));
aCursor.SetMark();
- aCursor.GetMark()->nNode = *pContentNd;
- aCursor.GetMark()->nContent.Assign(pContentNd,
- rRedlineTable[i]->End()->nContent.GetIndex());
+ aCursor.GetMark()->Assign(*pContentNd, rRedlineTable[i]->End()->GetContentIndex());
aCursor.FillRects();
@@ -3334,6 +3281,11 @@ void SwXTextDocument::getPostIts(tools::JsonWriter& rJsonWriter)
{
sw::annotation::SwAnnotationWin* pWin = sidebarItem->mpPostIt.get();
+ if (!pWin)
+ {
+ continue;
+ }
+
const SwPostItField* pField = pWin->GetPostItField();
const SwRect& aRect = pWin->GetAnchorRect();
tools::Rectangle aSVRect(aRect.Pos().getX(),
@@ -3357,13 +3309,14 @@ void SwXTextDocument::getPostIts(tools::JsonWriter& rJsonWriter)
auto commentNode = rJsonWriter.startStruct();
rJsonWriter.put("id", pField->GetPostItId());
- rJsonWriter.put("parent", pWin->CalcParent());
+ rJsonWriter.put("parentId", pField->GetParentPostItId());
rJsonWriter.put("author", pField->GetPar1());
rJsonWriter.put("text", pField->GetPar2());
rJsonWriter.put("resolved", pField->GetResolved() ? "true" : "false");
rJsonWriter.put("dateTime", utl::toISO8601(pField->GetDateTime().GetUNODateTime()));
rJsonWriter.put("anchorPos", aSVRect.toString());
rJsonWriter.put("textRange", sRects);
+ rJsonWriter.put("layoutStatus", static_cast< sal_Int16 >(pWin->GetLayoutStatus()));
}
}
@@ -3383,11 +3336,11 @@ void SwXTextDocument::executeFromFieldEvent(const StringMap& aArguments)
sal_Int32 nSelection = aIter->second.toInt32();
SwPosition aPos(*m_pDocShell->GetWrtShell()->GetCursor()->GetPoint());
- sw::mark::IFieldmark* pFieldBM = m_pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos);
+ sw::mark::IFieldmark* pFieldBM = m_pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getInnerFieldmarkFor(aPos);
if ( !pFieldBM )
{
- --aPos.nContent;
- pFieldBM = m_pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos);
+ aPos.AdjustContent(-1);
+ pFieldBM = m_pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getInnerFieldmarkFor(aPos);
}
if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN)
{
@@ -3401,6 +3354,169 @@ void SwXTextDocument::executeFromFieldEvent(const StringMap& aArguments)
}
}
+std::vector<basegfx::B2DRange>
+SwXTextDocument::getSearchResultRectangles(const char* pPayload)
+{
+ SwDoc* pDoc = m_pDocShell->GetDoc();
+ if (!pDoc)
+ return std::vector<basegfx::B2DRange>();
+
+ sw::search::SearchResultLocator aLocator(pDoc);
+ sw::search::LocationResult aResult = aLocator.findForPayload(pPayload);
+ if (aResult.mbFound)
+ {
+ return aResult.maRectangles;
+ }
+ return std::vector<basegfx::B2DRange>();
+}
+
+OString SwXTextDocument::getViewRenderState(SfxViewShell* pViewShell)
+{
+ OStringBuffer aState;
+ SwView* pView = pViewShell ? dynamic_cast<SwView*>(pViewShell) : m_pDocShell->GetView();
+ if (pView && pView->GetWrtShellPtr())
+ {
+ const SwViewOption* pVOpt = pView->GetWrtShell().GetViewOptions();
+ if (pVOpt)
+ {
+ if (pVOpt->IsViewMetaChars())
+ aState.append('P');
+ if (pVOpt->IsOnlineSpell())
+ aState.append('S');
+ aState.append(';');
+
+ OString aThemeName = OUStringToOString(pVOpt->GetThemeName(), RTL_TEXTENCODING_UTF8);
+ aState.append(aThemeName);
+ }
+ }
+ return aState.makeStringAndClear();
+}
+
+namespace
+{
+inline constexpr OUString SELECTED_DATE_FORMAT = u"YYYY-MM-DD"_ustr;
+}
+
+void SwXTextDocument::executeContentControlEvent(const StringMap& rArguments)
+{
+ auto it = rArguments.find("type");
+ if (it == rArguments.end())
+ {
+ return;
+ }
+
+ if (it->second == "drop-down")
+ {
+ SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
+ const SwPosition* pStart = pWrtShell->GetCursor()->Start();
+ SwTextNode* pTextNode = pStart->GetNode().GetTextNode();
+ if (!pTextNode)
+ {
+ return;
+ }
+
+ SwTextAttr* pAttr = pTextNode->GetTextAttrAt(pStart->GetContentIndex(),
+ RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Parent);
+ if (!pAttr)
+ {
+ return;
+ }
+
+ auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
+ const SwFormatContentControl& rFormatContentControl = pTextContentControl->GetContentControl();
+ std::shared_ptr<SwContentControl> pContentControl = rFormatContentControl.GetContentControl();
+ if (!pContentControl->GetComboBox() && !pContentControl->GetDropDown())
+ {
+ return;
+ }
+
+ it = rArguments.find("selected");
+ if (it == rArguments.end())
+ {
+ return;
+ }
+
+ sal_Int32 nSelection = it->second.toInt32();
+ pContentControl->SetSelectedListItem(nSelection);
+ pWrtShell->GotoContentControl(rFormatContentControl);
+ }
+ else if (it->second == "picture")
+ {
+ it = rArguments.find("changed");
+ if (it == rArguments.end())
+ {
+ return;
+ }
+
+ SwView* pView = m_pDocShell->GetView();
+ if (!pView)
+ {
+ return;
+ }
+
+ // The current placeholder is selected, so this will replace, not insert.
+ SfxStringItem aItem(SID_INSERT_GRAPHIC, it->second);
+ pView->GetViewFrame().GetDispatcher()->ExecuteList(SID_CHANGE_PICTURE,
+ SfxCallMode::SYNCHRON, { &aItem });
+ }
+ else if (it->second == "date")
+ {
+ SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell();
+ const SwPosition* pStart = pWrtShell->GetCursor()->Start();
+ SwTextNode* pTextNode = pStart->GetNode().GetTextNode();
+ if (!pTextNode)
+ {
+ return;
+ }
+
+ SwTextAttr* pAttr = pTextNode->GetTextAttrAt(pStart->GetContentIndex(),
+ RES_TXTATR_CONTENTCONTROL, ::sw::GetTextAttrMode::Parent);
+ if (!pAttr)
+ {
+ return;
+ }
+
+ auto pTextContentControl = static_txtattr_cast<SwTextContentControl*>(pAttr);
+ const SwFormatContentControl& rFormatContentControl
+ = pTextContentControl->GetContentControl();
+ std::shared_ptr<SwContentControl> pContentControl
+ = rFormatContentControl.GetContentControl();
+ if (!pContentControl->GetDate())
+ {
+ return;
+ }
+
+ it = rArguments.find("selected");
+ if (it == rArguments.end())
+ {
+ return;
+ }
+
+ OUString aSelectedDate = it->second.replaceAll("T00:00:00Z", "");
+ SwDoc& rDoc = pTextNode->GetDoc();
+ SvNumberFormatter* pNumberFormatter = rDoc.GetNumberFormatter();
+ sal_uInt32 nFormat
+ = pNumberFormatter->GetEntryKey(SELECTED_DATE_FORMAT, LANGUAGE_ENGLISH_US);
+ if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
+ {
+ sal_Int32 nCheckPos = 0;
+ SvNumFormatType nType;
+ OUString sFormat = SELECTED_DATE_FORMAT;
+ pNumberFormatter->PutEntry(sFormat, nCheckPos, nType, nFormat, LANGUAGE_ENGLISH_US);
+ }
+
+ if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
+ {
+ return;
+ }
+
+ double dCurrentDate = 0;
+ pNumberFormatter->IsNumberFormat(aSelectedDate, nFormat, dCurrentDate);
+ pContentControl->SetSelectedDate(dCurrentDate);
+ pWrtShell->GotoContentControl(rFormatContentControl);
+ }
+}
+
int SwXTextDocument::getPart()
{
SolarMutexGuard aGuard;
@@ -3414,14 +3530,11 @@ int SwXTextDocument::getPart()
OUString SwXTextDocument::getPartName(int nPart)
{
- SolarMutexGuard aGuard;
-
return SwResId(STR_PAGE) + OUString::number(nPart + 1);
}
OUString SwXTextDocument::getPartHash(int nPart)
{
- SolarMutexGuard aGuard;
OUString sPart(SwResId(STR_PAGE) + OUString::number(nPart + 1));
return OUString::number(sPart.hashCode());
@@ -3430,17 +3543,14 @@ OUString SwXTextDocument::getPartHash(int nPart)
VclPtr<vcl::Window> SwXTextDocument::getDocWindow()
{
SolarMutexGuard aGuard;
- VclPtr<vcl::Window> pWindow;
SwView* pView = m_pDocShell->GetView();
- if (pView)
- pWindow = &(pView->GetEditWin());
+ if (!pView)
+ return {};
- LokChartHelper aChartHelper(pView);
- VclPtr<vcl::Window> pChartWindow = aChartHelper.GetWindow();
- if (pChartWindow)
- pWindow = pChartWindow;
+ if (VclPtr<vcl::Window> pWindow = SfxLokHelper::getInPlaceDocWindow(pView))
+ return pWindow;
- return pWindow;
+ return &(pView->GetEditWin());
}
void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments)
@@ -3458,16 +3568,29 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
// Tiled rendering defaults.
SwViewOption aViewOption(*pViewShell->GetViewOptions());
aViewOption.SetHardBlank(false);
+
+ // Disable field shadings: the result would depend on the cursor position.
+ aViewOption.SetAppearanceFlag(ViewOptFlags::FieldShadings, false);
+ // The fancy header/footer controls don't work in tiled mode anyway, so
+ // explicitly disable them to enable skipping invalidating the view for
+ // the case of clicking in the header area of a document with no headers
+ aViewOption.SetUseHeaderFooterMenu(false);
+
+ OUString sThemeName;
+ OUString sOrigAuthor = SW_MOD()->GetRedlineAuthor(SW_MOD()->GetRedlineAuthor());
+ OUString sAuthor;
+
for (const beans::PropertyValue& rValue : rArguments)
{
if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has<bool>())
aViewOption.SetHideWhitespaceMode(rValue.Value.get<bool>());
else if (rValue.Name == ".uno:ShowBorderShadow" && rValue.Value.has<bool>())
- SwViewOption::SetAppearanceFlag(ViewOptFlags::Shadow , rValue.Value.get<bool>());
+ aViewOption.SetAppearanceFlag(ViewOptFlags::Shadow , rValue.Value.get<bool>());
else if (rValue.Name == ".uno:Author" && rValue.Value.has<OUString>())
{
+ sAuthor = rValue.Value.get<OUString>();
// Store the author name in the view.
- pView->SetRedlineAuthor(rValue.Value.get<OUString>());
+ pView->SetRedlineAuthor(sAuthor);
// Let the actual author name pick up the value from the current
// view, which would normally happen only during the next view
// switch.
@@ -3475,6 +3598,21 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
}
else if (rValue.Name == ".uno:SpellOnline" && rValue.Value.has<bool>())
aViewOption.SetOnlineSpell(rValue.Value.get<bool>());
+ else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>())
+ sThemeName = rValue.Value.get<OUString>();
+ }
+
+ if (!sAuthor.isEmpty() && sAuthor != sOrigAuthor)
+ {
+ SwView* pFirstView = static_cast<SwView*>(SfxViewShell::GetFirst());
+ if (pFirstView && SfxViewShell::GetNext(*pFirstView) == nullptr)
+ {
+ if (SwEditShell* pShell = &pFirstView->GetWrtShell())
+ {
+ pShell->SwViewShell::UpdateFields(true);
+ pShell->ResetModified();
+ }
+ }
}
// Set the initial zoom value to 1; usually it is set in setClientZoom and
@@ -3499,7 +3637,9 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
// be saved..." dialog appears, it is auto-cancelled with tiled rendering,
// causing 'Save' being disabled; so let's always save to the original
// format
- SvtSaveOptions().SetWarnAlienFormat(false);
+ auto xChanges = comphelper::ConfigurationChanges::create();
+ officecfg::Office::Common::Save::Document::WarnAlienFormat::set(false, xChanges);
+ xChanges->commit();
// disable word auto-completion suggestions, the tooltips are not visible,
// and the editeng-like auto-completion is annoying
@@ -3508,6 +3648,16 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css::
// don't change the whitespace at the beginning of paragraphs, this is
// annoying when taking minutes without further formatting
SwEditShell::GetAutoFormatFlags()->bAFormatByInpDelSpacesAtSttEnd = false;
+
+ // if we know what theme the user wants, then we can dispatch that now early
+ if (!sThemeName.isEmpty())
+ {
+ css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence(
+ {
+ { "NewTheme", uno::Any(sThemeName) }
+ }));
+ comphelper::dispatchCommand(".uno:ChangeTheme", aPropertyValues);
+ }
}
void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
@@ -3521,26 +3671,28 @@ void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int
SolarMutexGuard aGuard;
SwViewShell* pWrtViewShell = m_pDocShell->GetWrtShell();
+ if (!pWrtViewShell)
+ {
+ return;
+ }
+
SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
- double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0);
+ double fScale = aOption.GetZoom() / o3tl::convert(100.0, o3tl::Length::px, o3tl::Length::twip);
- // check if the user hit a chart which is being edited by this view
- SfxViewShell* pViewShell = m_pDocShell->GetView();
- LokChartHelper aChartHelper(pViewShell);
- if (aChartHelper.postMouseEvent(nType, nX, nY,
- nCount, nButtons, nModifier,
- fScale, fScale))
+ if (SfxLokHelper::testInPlaceComponentMouseEventHit(
+ m_pDocShell->GetView(), nType, nX, nY, nCount, nButtons, nModifier, fScale, fScale))
return;
- // check if the user hit a chart which is being edited by someone else
- // and, if so, skip current mouse event
- if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
- {
- if (LokChartHelper::HitAny(Point(nX, nY)))
+ // try to forward mouse event to controls
+ SwDrawModel* pDrawLayer = GetDocOrThrow().getIDocumentDrawModelAccess().GetDrawModel();
+ SdrPage* pPage = pDrawLayer->GetPage(sal_uInt16(0));
+ SdrView* pDrawView = pWrtViewShell->GetDrawView();
+ SwEditWin& rEditWin = m_pDocShell->GetView()->GetEditWin();
+ Point aPointTwip(nX, nY);
+ Point aPointHMMDraw = o3tl::convert(aPointTwip, o3tl::Length::twip, o3tl::Length::mm100);
+ if (LokControlHandler::postMouseEvent(pPage, pDrawView, rEditWin, nType, aPointHMMDraw, nCount, nButtons, nModifier))
return;
- }
- SwEditWin& rEditWin = m_pDocShell->GetView()->GetEditWin();
LokMouseEventData aMouseEventData(nType, Point(nX, nY), nCount,
MouseEventModifiers::SIMPLECLICK,
nButtons, nModifier);
@@ -3587,7 +3739,7 @@ uno::Reference<datatransfer::XTransferable> SwXTextDocument::getSelection()
{
// Editing shape text
EditView& rEditView = pSdrView->GetTextEditOutlinerView()->GetEditView();
- xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
+ xTransferable = rEditView.getEditEngine().CreateTransferable(rEditView.GetSelection());
}
}
@@ -3597,7 +3749,7 @@ uno::Reference<datatransfer::XTransferable> SwXTextDocument::getSelection()
{
// Editing postit text.
EditView& rEditView = pWin->GetOutlinerView()->GetEditView();
- xTransferable = rEditView.GetEditEngine()->CreateTransferable(rEditView.GetSelection());
+ xTransferable = rEditView.getEditEngine().CreateTransferable(rEditView.GetSelection());
}
}
@@ -3613,7 +3765,7 @@ void SwXTextDocument::setGraphicSelection(int nType, int nX, int nY)
SwViewShell* pWrtViewShell = m_pDocShell->GetWrtShell();
SwViewOption aOption(*(pWrtViewShell->GetViewOptions()));
- double fScale = aOption.GetZoom() / (TWIPS_PER_PIXEL * 100.0);
+ double fScale = aOption.GetZoom() / o3tl::convert(100.0, o3tl::Length::px, o3tl::Length::twip);
SfxViewShell* pViewShell = m_pDocShell->GetView();
LokChartHelper aChartHelper(pViewShell);
@@ -3651,7 +3803,7 @@ void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_I
sal_Int64 nWindowHandle;
Parent >>= nWindowHandle;
aData.hWnd = reinterpret_cast<HWND>(nWindowHandle);
- ScopedVclPtrInstance<VirtualDevice> xDevice(aData, Size(1, 1), DeviceFormat::DEFAULT);
+ ScopedVclPtrInstance<VirtualDevice> xDevice(aData, Size(1, 1), DeviceFormat::WITHOUT_ALPHA);
paintTile(*xDevice, nOutputWidth, nOutputHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
#else
// TODO: support other platforms
@@ -3689,14 +3841,14 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
throw IllegalArgumentException("nScriptTypes ranges from 1 to 7!", Reference< XInterface >(), 1);
if (!m_pDocShell)
throw DisposedException();
- SwDoc* pDoc = m_pDocShell->GetDoc();
+ SwDoc& rDoc = GetDocOrThrow();
// avoid duplicate values
std::set< LanguageType > aAllLangs;
//USER STYLES
- const SwCharFormats *pFormats = pDoc->GetCharFormats();
+ const SwCharFormats *pFormats = rDoc.GetCharFormats();
for(size_t i = 0; i < pFormats->size(); ++i)
{
const SwAttrSet &rAttrSet = (*pFormats)[i]->GetAttrSet();
@@ -3721,7 +3873,7 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
}
}
- const SwTextFormatColls *pColls = pDoc->GetTextFormatColls();
+ const SwTextFormatColls *pColls = rDoc.GetTextFormatColls();
for (size_t i = 0; i < pColls->size(); ++i)
{
const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
@@ -3755,32 +3907,32 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
for (IStyleAccess::SwAutoStyleFamily i : aFam)
{
std::vector< std::shared_ptr<SfxItemSet> > rStyles;
- pDoc->GetIStyleAccess().getAllStyles(rStyles, i);
+ rDoc.GetIStyleAccess().getAllStyles(rStyles, i);
while (!rStyles.empty())
{
std::shared_ptr<SfxItemSet> pStyle = rStyles.back();
rStyles.pop_back();
- const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
+ const SfxItemSet *pSet = pStyle.get();
LanguageType nLang = LANGUAGE_DONTKNOW;
if (bLatin)
{
assert(pSet);
- nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, false )).GetLanguage();
+ nLang = pSet->Get( RES_CHRATR_LANGUAGE, false ).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
}
if (bAsian)
{
assert(pSet);
- nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, false )).GetLanguage();
+ nLang = pSet->Get( RES_CHRATR_CJK_LANGUAGE, false ).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
}
if (bComplex)
{
assert(pSet);
- nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, false )).GetLanguage();
+ nLang = pSet->Get( RES_CHRATR_CTL_LANGUAGE, false ).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
}
@@ -3816,19 +3968,19 @@ uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
LanguageType nLang = LANGUAGE_DONTKNOW;
if (bLatin)
{
- nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, false )).GetLanguage();
+ nLang = aAttr.Get( EE_CHAR_LANGUAGE, false ).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
}
if (bAsian)
{
- nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, false )).GetLanguage();
+ nLang = aAttr.Get( EE_CHAR_LANGUAGE_CJK, false ).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
}
if (bComplex)
{
- nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, false )).GetLanguage();
+ nLang = aAttr.Get( EE_CHAR_LANGUAGE_CTL, false ).GetLanguage();
if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
aAllLangs.insert( nLang );
}
@@ -4001,20 +4153,20 @@ Sequence< OUString > SwXLinkTargetSupplier::getSupportedServiceNames()
}
SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(
- Reference< XNameAccess > const & xAccess, const OUString& rLinkDisplayName, const OUString& sSuffix ) :
+ Reference< XNameAccess > const & xAccess, OUString aLinkDisplayName, OUString sSuffix ) :
m_xRealAccess(xAccess),
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
- m_sLinkSuffix(sSuffix),
- m_sLinkDisplayName(rLinkDisplayName),
+ m_sLinkSuffix(std::move(sSuffix)),
+ m_sLinkDisplayName(std::move(aLinkDisplayName)),
m_pxDoc(nullptr)
{
}
SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc,
- const OUString& rLinkDisplayName, const OUString& sSuffix) :
+ OUString aLinkDisplayName, OUString sSuffix) :
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
- m_sLinkSuffix(sSuffix),
- m_sLinkDisplayName(rLinkDisplayName),
+ m_sLinkSuffix(std::move(sSuffix)),
+ m_sLinkDisplayName(std::move(aLinkDisplayName)),
m_pxDoc(&rxDoc)
{
}
@@ -4032,7 +4184,7 @@ Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
OUString sSuffix(m_sLinkSuffix);
if(sParam.getLength() > sSuffix.getLength() )
{
- OUString sCmp = sParam.copy(sParam.getLength() - sSuffix.getLength(),
+ std::u16string_view sCmp = sParam.subView(sParam.getLength() - sSuffix.getLength(),
sSuffix.getLength());
if(sCmp == sSuffix)
{
@@ -4049,11 +4201,14 @@ Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
for (size_t i = 0; i < nOutlineCount && !bFound; ++i)
{
- const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
- const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
- if(sParam == lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
+ if(sParam == lcl_CreateOutlineString(i, pDoc))
{
- Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
+ OUString sOutlineText =
+ pDoc->getIDocumentOutlineNodes().getOutlineText(
+ i, pDoc->GetDocShell()->GetWrtShell()->GetLayout());
+ sal_Int32 nOutlineLevel = pDoc->getIDocumentOutlineNodes().getOutlineLevel(i);
+ Reference<XPropertySet> xOutline =
+ new SwXOutlineTarget(sParam, sOutlineText, nOutlineLevel);
aRet <<= xOutline;
bFound = true;
}
@@ -4065,14 +4220,14 @@ Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
if (pModel)
{
SdrPage* pPage = pModel->GetPage(0);
- for (size_t i = 0; i < pPage->GetObjCount() && !bFound; ++i)
+ for (const rtl::Reference<SdrObject>& pObj : *pPage)
{
- SdrObject* pObj = pPage->GetObj(i);
if (sParam == pObj->GetName())
{
Reference<XPropertySet> xDrawingObject = new SwXDrawingObjectTarget(sParam);
aRet <<= xDrawingObject;
bFound = true;
+ break;
}
}
}
@@ -4109,11 +4264,9 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames()
const size_t nOutlineCount = rOutlineNodes.size();
aRet.realloc(nOutlineCount);
OUString* pResArr = aRet.getArray();
- const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
for (size_t i = 0; i < nOutlineCount; ++i)
{
- OUString sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule) + "|outline";
- pResArr[i] = sEntry;
+ pResArr[i] = lcl_CreateOutlineString(i, pDoc) + "|outline";
}
}
else if (m_sLinkSuffix == "|drawingobject")
@@ -4126,9 +4279,8 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames()
aRet.realloc(nObjCount);
OUString* pResArr = aRet.getArray();
auto j = 0;
- for (size_t i = 0; i < nObjCount; ++i)
+ for (const rtl::Reference<SdrObject>& pObj : *pPage)
{
- SdrObject* pObj = pPage->GetObj(i);
if (!pObj->GetName().isEmpty())
pResArr[j++] = pObj->GetName() + "|drawingobject";
}
@@ -4137,9 +4289,9 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames()
}
else
{
- Sequence< OUString > aOrg = m_xRealAccess->getElementNames();
+ const Sequence< OUString > aOrg = m_xRealAccess->getElementNames();
aRet.realloc(aOrg.getLength());
- std::transform(aOrg.begin(), aOrg.end(), aRet.begin(),
+ std::transform(aOrg.begin(), aOrg.end(), aRet.getArray(),
[this](const OUString& rOrg) -> OUString { return rOrg + m_sLinkSuffix; });
}
return aRet;
@@ -4151,7 +4303,7 @@ sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
OUString sParam(rName);
if(sParam.getLength() > m_sLinkSuffix.getLength() )
{
- OUString sCmp = sParam.copy(sParam.getLength() - m_sLinkSuffix.getLength(),
+ std::u16string_view sCmp = sParam.subView(sParam.getLength() - m_sLinkSuffix.getLength(),
m_sLinkSuffix.getLength());
if(sCmp == m_sLinkSuffix)
{
@@ -4167,10 +4319,7 @@ sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
for (size_t i = 0; i < nOutlineCount && !bRet; ++i)
{
- const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
- const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
- if(sParam ==
- lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
+ if(sParam == lcl_CreateOutlineString(i, pDoc))
{
bRet = true;
}
@@ -4182,11 +4331,13 @@ sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
if (pModel)
{
SdrPage* pPage = pModel->GetPage(0);
- const size_t nObjCount = pPage->GetObjCount();
- for (size_t i = 0; i < nObjCount && !bRet; ++i)
+ for (const rtl::Reference<SdrObject>& pObj : *pPage)
{
- if (sParam == pPage->GetObj(i)->GetName())
+ if (sParam == pObj->GetName())
+ {
bRet = true;
+ break;
+ }
}
}
}
@@ -4231,29 +4382,28 @@ void SwXLinkNameAccessWrapper::setPropertyValue(
throw UnknownPropertyException(rPropName);
}
-static Any lcl_GetDisplayBitmap(const OUString& _sLinkSuffix)
+static Any lcl_GetDisplayBitmap(std::u16string_view sLinkSuffix)
{
Any aRet;
- OUString sLinkSuffix = _sLinkSuffix;
- if(!sLinkSuffix.isEmpty())
- sLinkSuffix = sLinkSuffix.copy(1);
+ if(!sLinkSuffix.empty())
+ sLinkSuffix = sLinkSuffix.substr(1);
OUString sImgId;
- if(sLinkSuffix == "outline")
+ if(sLinkSuffix == u"outline")
sImgId = RID_BMP_NAVI_OUTLINE;
- else if(sLinkSuffix == "table")
+ else if(sLinkSuffix == u"table")
sImgId = RID_BMP_NAVI_TABLE;
- else if(sLinkSuffix == "frame")
+ else if(sLinkSuffix == u"frame")
sImgId = RID_BMP_NAVI_FRAME;
- else if(sLinkSuffix == "graphic")
+ else if(sLinkSuffix == u"graphic")
sImgId = RID_BMP_NAVI_GRAPHIC;
- else if(sLinkSuffix == "ole")
+ else if(sLinkSuffix == u"ole")
sImgId = RID_BMP_NAVI_OLE;
- else if(sLinkSuffix.isEmpty())
+ else if(sLinkSuffix.empty())
sImgId = RID_BMP_NAVI_BOOKMARK;
- else if(sLinkSuffix == "region")
+ else if(sLinkSuffix == u"region")
sImgId = RID_BMP_NAVI_REGION;
- else if(sLinkSuffix == "drawingobject")
+ else if(sLinkSuffix == u"drawingobject")
sImgId = RID_BMP_NAVI_DRAWOBJECT;
if (!sImgId.isEmpty())
@@ -4316,9 +4466,12 @@ Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames()
return aRet;
}
-SwXOutlineTarget::SwXOutlineTarget(const OUString& rOutlineText) :
+SwXOutlineTarget::SwXOutlineTarget(OUString aOutlineText, OUString aActualText,
+ const sal_Int32 nOutlineLevel) :
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
- m_sOutlineText(rOutlineText)
+ m_sOutlineText(std::move(aOutlineText)),
+ m_sActualText(std::move(aActualText)),
+ m_nOutlineLevel(nOutlineLevel)
{
}
@@ -4340,9 +4493,16 @@ void SwXOutlineTarget::setPropertyValue(
Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
{
- if(rPropertyName != UNO_LINK_DISPLAY_NAME)
+ if (rPropertyName != UNO_LINK_DISPLAY_NAME && rPropertyName != "ActualOutlineName" &&
+ rPropertyName != "OutlineLevel")
throw UnknownPropertyException(rPropertyName);
+ if (rPropertyName == "ActualOutlineName")
+ return Any(m_sActualText);
+
+ if (rPropertyName == "OutlineLevel")
+ return Any(m_nOutlineLevel);
+
return Any(m_sOutlineText);
}
@@ -4383,9 +4543,9 @@ Sequence< OUString > SwXOutlineTarget::getSupportedServiceNames()
return aRet;
}
-SwXDrawingObjectTarget::SwXDrawingObjectTarget(const OUString& rDrawingObjectText) :
+SwXDrawingObjectTarget::SwXDrawingObjectTarget(OUString aDrawingObjectText) :
m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
- m_sDrawingObjectText(rDrawingObjectText)
+ m_sDrawingObjectText(std::move(aDrawingObjectText))
{
}
@@ -4501,7 +4661,7 @@ Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(SwCreateDrawTable
break;
case SwCreateDrawTable::Defaults:
if(!m_xDrawDefaults.is())
- m_xDrawDefaults = static_cast<cppu::OWeakObject*>(new SwSvxUnoDrawPool(*m_pDoc));
+ m_xDrawDefaults = cppu::getXWeak(new SwSvxUnoDrawPool(*m_pDoc));
xRet = m_xDrawDefaults;
break;
#if OSL_DEBUG_LEVEL > 0