diff options
Diffstat (limited to 'sw/source/uibase/uno/unotxvw.cxx')
-rw-r--r-- | sw/source/uibase/uno/unotxvw.cxx | 328 |
1 files changed, 113 insertions, 215 deletions
diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index 3059016abdfe..fd6e6fdf8bb6 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -20,7 +20,6 @@ #include <memory> #include <viscrs.hxx> #include <o3tl/any.hxx> -#include <sfx2/frame.hxx> #include <sfx2/printer.hxx> #include <sfx2/viewfrm.hxx> #include <cmdid.h> @@ -73,6 +72,8 @@ #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/typeprovider.hxx> #include <tools/UnitConversion.hxx> +#include <comphelper/dumpxmltostring.hxx> +#include <fmtanchr.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -85,12 +86,10 @@ using namespace ::com::sun::star::frame; using ::com::sun::star::util::URL; SwXTextView::SwXTextView(SwView* pSwView) : - SfxBaseController(pSwView), + SwXTextView_Base(pSwView), m_SelChangedListeners(m_aMutex), m_pView(pSwView), - m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) ), - mxViewSettings(), - mxTextViewCursor() + m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) ) { } @@ -104,14 +103,12 @@ void SwXTextView::Invalidate() { if(mxViewSettings.is()) { - comphelper::ChainablePropertySet *pSettings = static_cast < comphelper::ChainablePropertySet * > ( mxViewSettings.get() ); - static_cast < SwXViewSettings* > ( pSettings )->Invalidate(); + mxViewSettings->Invalidate(); mxViewSettings.clear(); } if(mxTextViewCursor.is()) { - text::XTextViewCursor* pCursor = mxTextViewCursor.get(); - static_cast<SwXTextViewCursor*>(pCursor)->Invalidate(); + mxTextViewCursor->Invalidate(); mxTextViewCursor.clear(); } @@ -128,101 +125,6 @@ void SwXTextView::Invalidate() m_pView = nullptr; } -Sequence< uno::Type > SAL_CALL SwXTextView::getTypes( ) -{ - return cppu::OTypeCollection( - cppu::UnoType<XSelectionSupplier>::get(), - cppu::UnoType<XServiceInfo>::get(), - cppu::UnoType<XFormLayerAccess>::get(), - cppu::UnoType<XTextViewCursorSupplier>::get(), - cppu::UnoType<XTextViewTextRangeSupplier>::get(), - cppu::UnoType<XViewSettingsSupplier>::get(), - cppu::UnoType<XRubySelection>::get(), - cppu::UnoType<XPropertySet>::get(), - cppu::UnoType<datatransfer::XTransferableSupplier>::get(), - cppu::UnoType<datatransfer::XTransferableTextSupplier>::get(), - SfxBaseController::getTypes() - ).getTypes(); -} - -Sequence< sal_Int8 > SAL_CALL SwXTextView::getImplementationId( ) -{ - return css::uno::Sequence<sal_Int8>(); -} - -void SAL_CALL SwXTextView::acquire( )noexcept -{ - SfxBaseController::acquire(); -} - -void SAL_CALL SwXTextView::release( )noexcept -{ - SfxBaseController::release(); -} - -uno::Any SAL_CALL SwXTextView::queryInterface( const uno::Type& aType ) -{ - uno::Any aRet; - if(aType == cppu::UnoType<view::XSelectionSupplier>::get()) - { - uno::Reference<view::XSelectionSupplier> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<lang::XServiceInfo>::get()) - { - uno::Reference<lang::XServiceInfo> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<view::XControlAccess>::get()) - { - uno::Reference<view::XControlAccess> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<view::XFormLayerAccess>::get()) - { - uno::Reference<view::XFormLayerAccess> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<text::XTextViewCursorSupplier>::get()) - { - uno::Reference<text::XTextViewCursorSupplier> xRet = this; - aRet <<= xRet; - } - else if (aType == cppu::UnoType<text::XTextViewTextRangeSupplier>::get()) - { - uno::Reference<text::XTextViewTextRangeSupplier> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<view::XViewSettingsSupplier>::get()) - { - uno::Reference<view::XViewSettingsSupplier> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<XRubySelection>::get()) - { - uno::Reference<XRubySelection> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<XPropertySet>::get()) - { - uno::Reference<XPropertySet> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<datatransfer::XTransferableSupplier>::get()) - { - uno::Reference<datatransfer::XTransferableSupplier> xRet = this; - aRet <<= xRet; - } - else if(aType == cppu::UnoType<datatransfer::XTransferableTextSupplier>::get()) - { - uno::Reference<datatransfer::XTransferableTextSupplier> xRet = this; - aRet <<= xRet; - } - else - aRet = SfxBaseController::queryInterface(aType); - return aRet; -} - sal_Bool SwXTextView::select(const uno::Any& aInterface) { SolarMutexGuard aGuard; @@ -262,7 +164,10 @@ sal_Bool SwXTextView::select(const uno::Any& aInterface) rSh.SetSelection(*pPaM); // the pPaM has been copied - delete it while (pPaM->GetNext() != pPaM) + { + // coverity[deref_arg] - the SwPaM delete moves a new entry into GetNext() delete pPaM->GetNext(); + } delete pPaM; return true; } @@ -386,8 +291,8 @@ uno::Any SwXTextView::getSelection() SwFrameFormat *const pFormat = rSh.GetFlyFrameFormat(); if (pFormat) { - aRef = SwXTextFrame::CreateXTextFrame( - *pFormat->GetDoc(), pFormat); + aRef = cppu::getXWeak(SwXTextFrame::CreateXTextFrame( + *pFormat->GetDoc(), pFormat).get()); } } break; @@ -396,8 +301,8 @@ uno::Any SwXTextView::getSelection() SwFrameFormat *const pFormat = rSh.GetFlyFrameFormat(); if (pFormat) { - aRef = SwXTextGraphicObject::CreateXTextGraphicObject( - *pFormat->GetDoc(), pFormat); + aRef = cppu::getXWeak(SwXTextGraphicObject::CreateXTextGraphicObject( + *pFormat->GetDoc(), pFormat).get()); } } break; @@ -406,8 +311,8 @@ uno::Any SwXTextView::getSelection() SwFrameFormat *const pFormat = rSh.GetFlyFrameFormat(); if (pFormat) { - aRef = SwXTextEmbeddedObject::CreateXTextEmbeddedObject( - *pFormat->GetDoc(), pFormat); + aRef = cppu::getXWeak(SwXTextEmbeddedObject::CreateXTextEmbeddedObject( + *pFormat->GetDoc(), pFormat).get()); } } break; @@ -463,7 +368,7 @@ SdrObject* SwXTextView::GetControl( SdrObject* pControl = nullptr; if ( pFormShell && pDrawView && pWindow ) - pControl = pFormShell->GetFormControl( xModel, *pDrawView, *pWindow, xToFill ); + pControl = pFormShell->GetFormControl( xModel, *pDrawView, *pWindow->GetOutDev(), xToFill ); return pControl; } @@ -487,7 +392,7 @@ uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormCo uno::Reference< form::runtime::XFormController > xController; if ( pFormShell && pDrawView && pWindow ) - xController = FmFormShell::GetFormController( Form, *pDrawView, *pWindow ); + xController = FmFormShell::GetFormController( Form, *pDrawView, *pWindow->GetOutDev() ); return xController; } @@ -535,7 +440,29 @@ SwXTextView::createTextRangeByPixelPosition(const awt::Point& rPixelPosition) SwWrtShell& rSh = m_pView->GetWrtShell(); SwPosition aPosition(*rSh.GetCurrentShellCursor().GetPoint()); rSh.GetLayout()->GetModelPositionForViewPoint(&aPosition, aLogicPoint); - uno::Reference<text::XTextRange> xRet + + if (aPosition.GetNode().IsGrfNode()) + { + // The point is closest to a graphic node, look up its format. + const SwFrameFormat* pGraphicFormat = aPosition.GetNode().GetFlyFormat(); + if (pGraphicFormat) + { + // Get the anchor of this format. + const SwFormatAnchor& rAnchor = pGraphicFormat->GetAnchor(); + const SwPosition* pAnchor = rAnchor.GetContentAnchor(); + if (pAnchor) + { + aPosition = *pAnchor; + } + else + { + // Page-anchored graphics have no anchor. + return {}; + } + } + } + + rtl::Reference<SwXTextRange> xRet = SwXTextRange::CreateXTextRange(*rSh.GetDoc(), aPosition, /*pMark=*/nullptr); return xRet; @@ -677,8 +604,8 @@ SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc() { SwWrtShell& rOldSh = m_pView->GetWrtShell(); SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess().getPrinter( false ); - SwDocShell* pDocSh; - SfxObjectShellLock xDocSh( pDocSh = new SwDocShell(SfxObjectCreateMode::STANDARD) ); + rtl::Reference<SwDocShell> pDocSh = new SwDocShell(SfxObjectCreateMode::STANDARD); + SfxObjectShellLock xDocSh(pDocSh.get()); xDocSh->DoInitNew(); SwDoc *const pTempDoc( pDocSh->GetDoc() ); // #i103634#, #i112425#: do not expand numbering and fields on PDF export @@ -687,24 +614,25 @@ SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc() SfxViewFrame* pDocFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, SFX_INTERFACE_NONE ); SwView* pDocView = static_cast<SwView*>( pDocFrame->GetViewShell() ); pDocView->AttrChangedNotify(nullptr);//So that SelectShell is called. - SwWrtShell* pSh = pDocView->GetWrtShellPtr(); + if (SwWrtShell* pSh = pDocView->GetWrtShellPtr()) + { + IDocumentDeviceAccess& rIDDA = pSh->getIDocumentDeviceAccess(); + SfxPrinter* pTempPrinter = rIDDA.getPrinter( true ); - IDocumentDeviceAccess& rIDDA = pSh->getIDocumentDeviceAccess(); - SfxPrinter* pTempPrinter = rIDDA.getPrinter( true ); + const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc()); - const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc()); + IDocumentDeviceAccess& rIDDA_old = rOldSh.getIDocumentDeviceAccess(); - IDocumentDeviceAccess& rIDDA_old = rOldSh.getIDocumentDeviceAccess(); + if( rIDDA_old.getPrinter( false ) ) + { + rIDDA.setJobsetup( *rIDDA_old.getJobsetup() ); + //#69563# if it isn't the same printer then the pointer has been invalidated! + pTempPrinter = rIDDA.getPrinter( true ); + } - if( rIDDA_old.getPrinter( false ) ) - { - rIDDA.setJobsetup( *rIDDA_old.getJobsetup() ); - //#69563# if it isn't the same printer then the pointer has been invalidated! - pTempPrinter = rIDDA.getPrinter( true ); + pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue()); } - pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue()); - return xDocSh; } @@ -712,36 +640,23 @@ void SwXTextView::NotifySelChanged() { OSL_ENSURE( m_pView, "view is missing" ); - uno::Reference<uno::XInterface> const xInt( - static_cast<cppu::OWeakObject*>(static_cast<SfxBaseController*>(this))); - - lang::EventObject const aEvent(xInt); + lang::EventObject const aEvent(getXWeak()); m_SelChangedListeners.notifyEach( &view::XSelectionChangeListener::selectionChanged, aEvent); } -namespace { - struct DispatchListener - { - URL const & m_rURL; - Sequence<PropertyValue> const& m_rSeq; - explicit DispatchListener(URL const& rURL, - Sequence<PropertyValue> const& rSeq) - : m_rURL(rURL), m_rSeq(rSeq) { } - void operator()(uno::Reference<XDispatch> const & xListener) const - { - xListener->dispatch(m_rURL, m_rSeq); - } - }; -} - void SwXTextView::NotifyDBChanged() { URL aURL; aURL.Complete = OUString::createFromAscii(SwXDispatch::GetDBChangeURL()); - m_SelChangedListeners.forEach<XDispatch>( - DispatchListener(aURL, Sequence<PropertyValue>(0))); + m_SelChangedListeners.forEach( + [&aURL] (const uno::Reference<XSelectionChangeListener>& xListener) + { + uno::Reference<XDispatch> xDispatch(xListener, UNO_QUERY); + if (xDispatch) + xDispatch->dispatch(aURL, {}); + }); } uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextView::getPropertySetInfo( ) @@ -822,7 +737,7 @@ uno::Any SAL_CALL SwXTextView::getPropertyValue( const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions(); if (!pOpt) throw RuntimeException(); - aRet <<= bool(pOpt->GetCoreOptions() & ViewOptFlags1::OnlineSpell); + aRet <<= pOpt->IsOnlineSpell(); } break; default : @@ -951,7 +866,7 @@ void SwXTextViewCursor::collapseToStart() throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); SwWrtShell& rSh = m_pView->GetWrtShell(); if(rSh.HasSelection()) @@ -973,7 +888,7 @@ void SwXTextViewCursor::collapseToEnd() throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); SwWrtShell& rSh = m_pView->GetWrtShell(); if(rSh.HasSelection()) @@ -996,7 +911,7 @@ sal_Bool SwXTextViewCursor::isCollapsed() throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); const SwWrtShell& rSh = m_pView->GetWrtShell(); bRet = !rSh.HasSelection(); @@ -1013,9 +928,9 @@ sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand) throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); - bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, nCount, true ); + bRet = m_pView->GetWrtShell().Left( SwCursorSkipMode::Chars, bExpand, nCount, true ); return bRet; } @@ -1028,9 +943,9 @@ sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand) throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); - bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, nCount, true ); + bRet = m_pView->GetWrtShell().Right( SwCursorSkipMode::Chars, bExpand, nCount, true ); return bRet; @@ -1045,7 +960,7 @@ void SwXTextViewCursor::gotoRange( throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc()); if (!::sw::XTextRangeToSwPaM(rDestPam, xRange)) @@ -1070,19 +985,9 @@ void SwXTextViewCursor::gotoRange( *aOwnPaM.GetMark() = *pShellCursor->GetMark(); } - uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY); - SwXTextRange* pRange = nullptr; - SwXParagraph* pPara = nullptr; - OTextCursorHelper* pCursor = nullptr; - if(xRangeTunnel.is()) - { - pRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething( - SwXTextRange::getUnoTunnelId())); - pCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething( - OTextCursorHelper::getUnoTunnelId())); - pPara = reinterpret_cast<SwXParagraph*>(xRangeTunnel->getSomething( - SwXParagraph::getUnoTunnelId())); - } + SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xRange.get()); + SwXParagraph* pPara = dynamic_cast<SwXParagraph*>(xRange.get()); + OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xRange.get()); const FrameTypeFlags nFrameType = rSh.GetFrameType(nullptr,true); @@ -1098,20 +1003,20 @@ void SwXTextViewCursor::gotoRange( else if(nFrameType & FrameTypeFlags::FOOTNOTE) eSearchNodeType = SwFootnoteStartNode; - const SwStartNode* pOwnStartNode = aOwnPaM.GetNode(). + const SwStartNode* pOwnStartNode = aOwnPaM.GetPointNode(). FindSttNodeByType(eSearchNodeType); const SwNode* pSrcNode = nullptr; if(pCursor && pCursor->GetPaM()) { - pSrcNode = &pCursor->GetPaM()->GetNode(); + pSrcNode = &pCursor->GetPaM()->GetPointNode(); } else if (pRange) { SwPaM aPam(pRange->GetDoc().GetNodes()); if (pRange->GetPositions(aPam)) { - pSrcNode = &aPam.GetNode(); + pSrcNode = &aPam.GetPointNode(); } } else if (pPara && pPara->GetTextNode()) @@ -1146,8 +1051,7 @@ void SwXTextViewCursor::gotoRange( // by him and the transferred Range. SwPosition aOwnLeft(*aOwnPaM.Start()); SwPosition aOwnRight(*aOwnPaM.End()); - SwPosition* pParamLeft = rDestPam.Start(); - SwPosition* pParamRight = rDestPam.End(); + auto [pParamLeft, pParamRight] = rDestPam.StartEnd(); // SwPosition* // Now four SwPositions are there, two of them are needed, but which? if(aOwnRight > *pParamRight) *aOwnPaM.GetPoint() = aOwnRight; @@ -1184,7 +1088,7 @@ void SwXTextViewCursor::gotoStart(sal_Bool bExpand) throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); m_pView->GetWrtShell().StartOfSection( bExpand ); @@ -1198,7 +1102,7 @@ void SwXTextViewCursor::gotoEnd(sal_Bool bExpand) throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); m_pView->GetWrtShell().EndOfSection( bExpand ); @@ -1326,8 +1230,8 @@ sal_Bool SwXTextViewCursor::screenDown() SfxRequest aReq(FN_PAGEDOWN, SfxCallMode::SLOT, m_pView->GetPool()); m_pView->Execute(aReq); - const SfxPoolItem* pRet = aReq.GetReturnValue(); - bRet = pRet && static_cast<const SfxBoolItem*>(pRet)->GetValue(); + const SfxPoolItemHolder& rResult(aReq.GetReturnValue()); + bRet = rResult && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue(); return bRet; } @@ -1341,8 +1245,8 @@ sal_Bool SwXTextViewCursor::screenUp() SfxRequest aReq(FN_PAGEUP, SfxCallMode::SLOT, m_pView->GetPool()); m_pView->Execute(aReq); - const SfxPoolItem* pRet = aReq.GetReturnValue(); - bRet = pRet && static_cast<const SfxBoolItem*>(pRet)->GetValue(); + const SfxPoolItemHolder& rResult(aReq.GetReturnValue()); + bRet = rResult && static_cast<const SfxBoolItem*>(rResult.getItem())->GetValue(); return bRet; } @@ -1355,7 +1259,7 @@ uno::Reference< text::XText > SwXTextViewCursor::getText() throw uno::RuntimeException(); if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCursor = rSh.GetCursor(); @@ -1365,7 +1269,7 @@ uno::Reference< text::XText > SwXTextViewCursor::getText() return xRet; } -uno::Reference< text::XTextRange > SwXTextViewCursor::getStart() +uno::Reference< text::XTextRange > SwXTextViewCursor::getStart() { SolarMutexGuard aGuard; uno::Reference< text::XTextRange > xRet; @@ -1373,7 +1277,7 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getStart() throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCursor = rSh.GetCursor(); @@ -1383,15 +1287,15 @@ uno::Reference< text::XTextRange > SwXTextViewCursor::getStart() return xRet; } -uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd() +uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd() { SolarMutexGuard aGuard; - uno::Reference< text::XTextRange > xRet; + rtl::Reference<SwXTextRange> xRet; if(!m_pView) throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCursor = rSh.GetCursor(); @@ -1409,7 +1313,7 @@ OUString SwXTextViewCursor::getString() { if (!IsTextSelection( false )) { - SAL_WARN("sw.uno", "no text selection in getString() " << static_cast<cppu::OWeakObject*>(this)); + SAL_WARN("sw.uno", "no text selection in getString() " << getXWeak()); return uRet; } @@ -1444,7 +1348,7 @@ void SwXTextViewCursor::setString(const OUString& aString) return; if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); ShellMode eSelMode = m_pView->GetShellMode(); switch(eSelMode) @@ -1459,7 +1363,7 @@ void SwXTextViewCursor::setString(const OUString& aString) case ShellMode::Text : { SwWrtShell& rSh = m_pView->GetWrtShell(); - SwCursor* pShellCursor = rSh.GetSwCursor(); + SwCursor* pShellCursor = rSh.GetCursor(); SwUnoCursorHelper::SetString(*pShellCursor, aString); break; } @@ -1481,7 +1385,7 @@ void SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const SwWrtShell& rSh = m_pView->GetWrtShell(); SwPaM* pShellCursor = rSh.GetCursor(); - SwNode& rNode = pShellCursor->GetNode(); + SwNode& rNode = pShellCursor->GetPointNode(); if (!rNode.IsTextNode()) throw RuntimeException(); @@ -1591,7 +1495,7 @@ sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand) throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); bRet = m_pView->GetWrtShell().Down( bExpand, nCount, true ); @@ -1607,7 +1511,7 @@ sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand) throw uno::RuntimeException(); if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); bRet = m_pView->GetWrtShell().Up( bExpand, nCount, true ); @@ -1622,7 +1526,7 @@ sal_Bool SwXTextViewCursor::isAtStartOfLine() throw uno::RuntimeException(); if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); bRet = m_pView->GetWrtShell().IsAtLeftMargin(); @@ -1637,7 +1541,7 @@ sal_Bool SwXTextViewCursor::isAtEndOfLine() throw uno::RuntimeException(); if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); bRet = m_pView->GetWrtShell().IsAtRightMargin(); @@ -1651,7 +1555,7 @@ void SwXTextViewCursor::gotoEndOfLine(sal_Bool bExpand) throw uno::RuntimeException(); if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); m_pView->GetWrtShell().RightMargin(bExpand, true); @@ -1664,7 +1568,7 @@ void SwXTextViewCursor::gotoStartOfLine(sal_Bool bExpand) throw uno::RuntimeException(); if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("no text selection", getXWeak() ); m_pView->GetWrtShell().LeftMargin(bExpand, true); @@ -1691,24 +1595,6 @@ Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames() "com.sun.star.style.ParagraphPropertiesComplex" }; } -const uno::Sequence< sal_Int8 > & SwXTextViewCursor::getUnoTunnelId() -{ - static const UnoTunnelIdInit theSwXTextViewCursorUnoTunnelId; - return theSwXTextViewCursorUnoTunnelId.getSeq(); -} - -//XUnoTunnel -sal_Int64 SAL_CALL SwXTextViewCursor::getSomething( - const uno::Sequence< sal_Int8 >& rId ) -{ - if( isUnoTunnelId<SwXTextViewCursor>(rId) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); - } - return OTextCursorHelper::getSomething(rId); -} - -IMPLEMENT_FORWARD_XINTERFACE2(SwXTextViewCursor,SwXTextViewCursor_Base,OTextCursorHelper) const SwDoc* SwXTextViewCursor::GetDoc() const { SwWrtShell& rSh = m_pView->GetWrtShell(); @@ -1756,6 +1642,18 @@ SwXTextView::getTransferableForTextRange(uno::Reference<text::XTextRange> const& return pTransfer; } +OUString SAL_CALL SwXTextView::dump(const OUString& rKind) +{ + if (rKind == "layout") + { + SwRootFrame* pLayout = GetView()->GetWrtShell().GetLayout(); + return comphelper::dumpXmlToString([pLayout](xmlTextWriterPtr pWriter) + { pLayout->dumpAsXml(pWriter); }); + } + + return OUString(); +} + uno::Reference< datatransfer::XTransferable > SAL_CALL SwXTextView::getTransferable() { SolarMutexGuard aGuard; |