diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/sidebar/PageMarginControl.cxx | 34 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizeControl.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/table/chartins.cxx | 106 | ||||
-rw-r--r-- | sw/source/uibase/uiview/pview.cxx | 70 | ||||
-rw-r--r-- | sw/source/uibase/uiview/srcview.cxx | 72 | ||||
-rw-r--r-- | sw/source/uibase/uiview/uivwimp.cxx | 30 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 72 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewport.cxx | 30 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewprt.cxx | 52 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewsrch.cxx | 49 | ||||
-rw-r--r-- | sw/source/uibase/uno/dlelstnr.cxx | 24 | ||||
-rw-r--r-- | sw/source/uibase/uno/unoatxt.cxx | 101 | ||||
-rw-r--r-- | sw/source/uibase/uno/unodispatch.cxx | 32 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 190 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxvw.cxx | 42 |
15 files changed, 466 insertions, 464 deletions
diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx index 258b5996d052..065588eda318 100644 --- a/sw/source/uibase/sidebar/PageMarginControl.cxx +++ b/sw/source/uibase/sidebar/PageMarginControl.cxx @@ -397,26 +397,26 @@ IMPL_LINK( PageMarginControl, SelectMarginHdl, weld::Button&, rControl, void ) } } - if ( bApplyNewPageMargins ) - { - const css::uno::Reference< css::document::XUndoManager > xUndoManager( getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) ); - if ( xUndoManager.is() ) - xUndoManager->enterUndoContext( "" ); - - ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin ); - ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin ); - if ( m_bMirrored != bMirrored ) - { - m_bMirrored = bMirrored; - ExecutePageLayoutChange( m_bMirrored ); - } + if ( !bApplyNewPageMargins ) + return; - if ( xUndoManager.is() ) - xUndoManager->leaveUndoContext(); + const css::uno::Reference< css::document::XUndoManager > xUndoManager( getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) ); + if ( xUndoManager.is() ) + xUndoManager->enterUndoContext( "" ); - m_bCustomValuesUsed = false; - m_xControl->EndPopupMode(); + ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin ); + ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin ); + if ( m_bMirrored != bMirrored ) + { + m_bMirrored = bMirrored; + ExecutePageLayoutChange( m_bMirrored ); } + + if ( xUndoManager.is() ) + xUndoManager->leaveUndoContext(); + + m_bCustomValuesUsed = false; + m_xControl->EndPopupMode(); } void PageMarginControl::ExecuteMarginLRChange( diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx index 5abdb4788609..00bcfc0a6a3d 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.cxx +++ b/sw/source/uibase/sidebar/PageSizeControl.cxx @@ -197,22 +197,22 @@ void PageSizeControl::ExecuteSizeChange( const Paper ePaper ) bool bLandscape = false; const SfxPoolItem *pItem; MapUnit eUnit = lcl_GetUnit(); - if ( SfxViewFrame::Current() ) - { - SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); - bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); + if ( !SfxViewFrame::Current() ) + return; - std::unique_ptr<SvxSizeItem> pPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) ); - Size aPageSize = SvxPaperInfo::GetPaperSize( ePaper, eUnit ); - if ( bLandscape ) - { - Swap( aPageSize ); - } - pPageSizeItem->SetSize( aPageSize ); + SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); + bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); - SfxViewFrame::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, - SfxCallMode::RECORD, { pPageSizeItem.get() }); + std::unique_ptr<SvxSizeItem> pPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) ); + Size aPageSize = SvxPaperInfo::GetPaperSize( ePaper, eUnit ); + if ( bLandscape ) + { + Swap( aPageSize ); } + pPageSizeItem->SetSize( aPageSize ); + + SfxViewFrame::Current()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_SIZE, + SfxCallMode::RECORD, { pPageSizeItem.get() }); } diff --git a/sw/source/uibase/table/chartins.cxx b/sw/source/uibase/table/chartins.cxx index fd73a71efe2e..dba654611592 100644 --- a/sw/source/uibase/table/chartins.cxx +++ b/sw/source/uibase/table/chartins.cxx @@ -158,70 +158,70 @@ SwInsertChart::SwInsertChart( const Link<css::ui::dialogs::DialogClosedEvent*, v //@todo get context from writer if that has one uno::Reference< uno::XComponentContext > xContext( ::cppu::defaultBootstrap_InitialComponentContext() ); - if( xContext.is() && xChartModel.is() && xDataProvider.is()) + if( !(xContext.is() && xChartModel.is() && xDataProvider.is())) + return; + + uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); + if(!xMCF.is()) + return; + + uno::Reference< ui::dialogs::XAsynchronousExecutableDialog > xDialog( + xMCF->createInstanceWithContext( + "com.sun.star.comp.chart2.WizardDialog", xContext), + uno::UNO_QUERY); + uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY ); + if( xInit.is() ) { - uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); - if(xMCF.is()) + // initialize dialog + uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence( { - uno::Reference< ui::dialogs::XAsynchronousExecutableDialog > xDialog( - xMCF->createInstanceWithContext( - "com.sun.star.comp.chart2.WizardDialog", xContext), - uno::UNO_QUERY); - uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY ); - if( xInit.is() ) + {"ParentWindow", uno::Any(uno::Reference< awt::XWindow >())}, + {"ChartModel", uno::Any(xChartModel)} + })); + xInit->initialize( aSeq ); + + // try to set the dialog's position so it doesn't hide the chart + uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY ); + if ( xDialogProps.is() ) + { + try { - // initialize dialog - uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence( - { - {"ParentWindow", uno::Any(uno::Reference< awt::XWindow >())}, - {"ChartModel", uno::Any(xChartModel)} - })); - xInit->initialize( aSeq ); - - // try to set the dialog's position so it doesn't hide the chart - uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY ); - if ( xDialogProps.is() ) + //get dialog size: + awt::Size aDialogAWTSize; + if( xDialogProps->getPropertyValue("Size") + >>= aDialogAWTSize ) { - try - { - //get dialog size: - awt::Size aDialogAWTSize; - if( xDialogProps->getPropertyValue("Size") - >>= aDialogAWTSize ) - { - Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height ); - if ( !aDialogSize.IsEmpty() ) - { - //calculate and set new position - SwRect aSwRect; - if (pFlyFrameFormat) - aSwRect = pFlyFrameFormat->GetAnchoredObj()->GetObjRectWithSpaces(); - tools::Rectangle aRect( aSwRect.SVRect() ); - Point aDialogPos = SwGetChartDialogPos( &rWrtShell.GetView().GetEditWin(), aDialogSize, aRect ); - xDialogProps->setPropertyValue("Position", - uno::makeAny( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) ); - } - } - } - catch (const uno::Exception&) + Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height ); + if ( !aDialogSize.IsEmpty() ) { - OSL_FAIL("Chart wizard couldn't be positioned automatically" ); + //calculate and set new position + SwRect aSwRect; + if (pFlyFrameFormat) + aSwRect = pFlyFrameFormat->GetAnchoredObj()->GetObjRectWithSpaces(); + tools::Rectangle aRect( aSwRect.SVRect() ); + Point aDialogPos = SwGetChartDialogPos( &rWrtShell.GetView().GetEditWin(), aDialogSize, aRect ); + xDialogProps->setPropertyValue("Position", + uno::makeAny( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) ); } } - - ::svt::DialogClosedListener* pListener = new ::svt::DialogClosedListener(); - pListener->SetDialogClosedLink( rLink ); - css::uno::Reference<css::ui::dialogs::XDialogClosedListener> xListener( pListener ); - - xDialog->startExecuteModal( xListener ); } - else + catch (const uno::Exception&) { - uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); - if( xComponent.is()) - xComponent->dispose(); + OSL_FAIL("Chart wizard couldn't be positioned automatically" ); } } + + ::svt::DialogClosedListener* pListener = new ::svt::DialogClosedListener(); + pListener->SetDialogClosedLink( rLink ); + css::uno::Reference<css::ui::dialogs::XDialogClosedListener> xListener( pListener ); + + xDialog->startExecuteModal( xListener ); + } + else + { + uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); + if( xComponent.is()) + xComponent->dispose(); } } diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index 3a499aea528e..cb8c44e143c1 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -468,45 +468,45 @@ void SwPagePreviewWin::Command( const CommandEvent& rCEvt ) void SwPagePreviewWin::MouseButtonDown( const MouseEvent& rMEvt ) { // consider single-click to set selected page - if( MOUSE_LEFT == ( rMEvt.GetModifier() + rMEvt.GetButtons() ) ) + if( MOUSE_LEFT != ( rMEvt.GetModifier() + rMEvt.GetButtons() ) ) + return; + + Point aPreviewPos( PixelToLogic( rMEvt.GetPosPixel() ) ); + Point aDocPos; + bool bPosInEmptyPage; + sal_uInt16 nNewSelectedPage; + bool bIsDocPos = + mpPgPreviewLayout->IsPreviewPosInDocPreviewPage( aPreviewPos, + aDocPos, bPosInEmptyPage, nNewSelectedPage ); + if ( bIsDocPos && rMEvt.GetClicks() == 2 ) { - Point aPreviewPos( PixelToLogic( rMEvt.GetPosPixel() ) ); - Point aDocPos; - bool bPosInEmptyPage; - sal_uInt16 nNewSelectedPage; - bool bIsDocPos = - mpPgPreviewLayout->IsPreviewPosInDocPreviewPage( aPreviewPos, - aDocPos, bPosInEmptyPage, nNewSelectedPage ); - if ( bIsDocPos && rMEvt.GetClicks() == 2 ) + // close page preview, set new cursor position and switch to + // normal view. + OUString sNewCursorPos = OUString::number( aDocPos.X() ) + ";" + + OUString::number( aDocPos.Y() ) + ";"; + mrView.SetNewCursorPos( sNewCursorPos ); + + SfxViewFrame *pTmpFrame = mrView.GetViewFrame(); + pTmpFrame->GetBindings().Execute( SID_VIEWSHELL0, nullptr, + SfxCallMode::ASYNCHRON ); + } + else if ( bIsDocPos || bPosInEmptyPage ) + { + // show clicked page as the selected one + mpPgPreviewLayout->MarkNewSelectedPage( nNewSelectedPage ); + GetViewShell()->ShowPreviewSelection( nNewSelectedPage ); + // adjust position at vertical scrollbar. + if ( mpPgPreviewLayout->DoesPreviewLayoutRowsFitIntoWindow() ) { - // close page preview, set new cursor position and switch to - // normal view. - OUString sNewCursorPos = OUString::number( aDocPos.X() ) + ";" + - OUString::number( aDocPos.Y() ) + ";"; - mrView.SetNewCursorPos( sNewCursorPos ); - - SfxViewFrame *pTmpFrame = mrView.GetViewFrame(); - pTmpFrame->GetBindings().Execute( SID_VIEWSHELL0, nullptr, - SfxCallMode::ASYNCHRON ); + mrView.SetVScrollbarThumbPos( nNewSelectedPage ); } - else if ( bIsDocPos || bPosInEmptyPage ) + // invalidate page status. + static sal_uInt16 aInval[] = { - // show clicked page as the selected one - mpPgPreviewLayout->MarkNewSelectedPage( nNewSelectedPage ); - GetViewShell()->ShowPreviewSelection( nNewSelectedPage ); - // adjust position at vertical scrollbar. - if ( mpPgPreviewLayout->DoesPreviewLayoutRowsFitIntoWindow() ) - { - mrView.SetVScrollbarThumbPos( nNewSelectedPage ); - } - // invalidate page status. - static sal_uInt16 aInval[] = - { - FN_STAT_PAGE, 0 - }; - SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings(); - rBindings.Invalidate( aInval ); - } + FN_STAT_PAGE, 0 + }; + SfxBindings& rBindings = mrView.GetViewFrame()->GetBindings(); + rBindings.Invalidate( aInval ); } } diff --git a/sw/source/uibase/uiview/srcview.cxx b/sw/source/uibase/uiview/srcview.cxx index 0c3aaa4a3acc..62f306a9dcf7 100644 --- a/sw/source/uibase/uiview/srcview.cxx +++ b/sw/source/uibase/uiview/srcview.cxx @@ -582,49 +582,49 @@ void SwSrcView::StartSearchAndReplace(const SvxSearchItem& rSearchItem, nFound = 0; } - if( !nFound ) + if( nFound ) + return; + + bool bNotFoundMessage = false; + if(!bRecursive) + { + bNotFoundMessage = bAtStart; + } + else if(bAtStart) + { + bNotFoundMessage = true; + } + + if(bApi) + return; + + if(bNotFoundMessage) + { + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/infonotfounddialog.ui")); + std::unique_ptr<weld::MessageDialog> xInfoBox(xBuilder->weld_message_dialog("InfoNotFoundDialog")); + xInfoBox->run(); + } + else if(!bRecursive) { - bool bNotFoundMessage = false; - if(!bRecursive) + int nRet; + + if (!bForward) { - bNotFoundMessage = bAtStart; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/querycontinueenddialog.ui")); + std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryContinueEndDialog")); + nRet = xQueryBox->run(); } - else if(bAtStart) + else { - bNotFoundMessage = true; + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/querycontinuebegindialog.ui")); + std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryContinueBeginDialog")); + nRet = xQueryBox->run(); } - if(!bApi) + if (nRet == RET_YES) { - if(bNotFoundMessage) - { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/infonotfounddialog.ui")); - std::unique_ptr<weld::MessageDialog> xInfoBox(xBuilder->weld_message_dialog("InfoNotFoundDialog")); - xInfoBox->run(); - } - else if(!bRecursive) - { - int nRet; - - if (!bForward) - { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/querycontinueenddialog.ui")); - std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryContinueEndDialog")); - nRet = xQueryBox->run(); - } - else - { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/querycontinuebegindialog.ui")); - std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryContinueBeginDialog")); - nRet = xQueryBox->run(); - } - - if (nRet == RET_YES) - { - pTextView->SetSelection( TextSelection( aPaM, aPaM ) ); - StartSearchAndReplace( rSearchItem, false, true ); - } - } + pTextView->SetSelection( TextSelection( aPaM, aPaM ) ); + StartSearchAndReplace( rSearchItem, false, true ); } } } diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx index 6a45751ad1d9..b607ccf9b256 100644 --- a/sw/source/uibase/uiview/uivwimp.cxx +++ b/sw/source/uibase/uiview/uivwimp.cxx @@ -293,25 +293,25 @@ void SAL_CALL SwClipboardChangeListener::changedContents( const css::datatransfe { const SolarMutexGuard aGuard; - if( pView ) - { - { - TransferableDataHelper aDataHelper( rEventObject.Contents ); - SwWrtShell& rSh = pView->GetWrtShell(); + if( !pView ) + return; - pView->m_nLastPasteDestination = SwTransferable::GetSotDestination( rSh ); - pView->m_bPasteState = aDataHelper.GetXTransferable().is() && - SwTransferable::IsPaste( rSh, aDataHelper ); + { + TransferableDataHelper aDataHelper( rEventObject.Contents ); + SwWrtShell& rSh = pView->GetWrtShell(); - pView->m_bPasteSpecialState = aDataHelper.GetXTransferable().is() && - SwTransferable::IsPasteSpecial( rSh, aDataHelper ); - } + pView->m_nLastPasteDestination = SwTransferable::GetSotDestination( rSh ); + pView->m_bPasteState = aDataHelper.GetXTransferable().is() && + SwTransferable::IsPaste( rSh, aDataHelper ); - SfxBindings& rBind = pView->GetViewFrame()->GetBindings(); - rBind.Invalidate( SID_PASTE ); - rBind.Invalidate( SID_PASTE_SPECIAL ); - rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); + pView->m_bPasteSpecialState = aDataHelper.GetXTransferable().is() && + SwTransferable::IsPasteSpecial( rSh, aDataHelper ); } + + SfxBindings& rBind = pView->GetViewFrame()->GetBindings(); + rBind.Invalidate( SID_PASTE ); + rBind.Invalidate( SID_PASTE_SPECIAL ); + rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); } void SwClipboardChangeListener::AddRemoveListener( bool bAdd ) diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index 281e2d09553c..85f9082b977f 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -381,48 +381,48 @@ void SwView::ExitDraw() { NoRotate(); - if(m_pShell) + if(!m_pShell) + return; + + // the shell may be invalid at close/reload/SwitchToViewShell + SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher(); + sal_uInt16 nIdx = 0; + SfxShell* pTest = nullptr; + do { - // the shell may be invalid at close/reload/SwitchToViewShell - SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher(); - sal_uInt16 nIdx = 0; - SfxShell* pTest = nullptr; - do - { - pTest = pDispatch->GetShell(nIdx++); - } - while( pTest && pTest != this && pTest != m_pShell); - if(pTest == m_pShell && - // don't call LeaveSelFrameMode() etc. for the below, - // because objects may still be selected: - dynamic_cast< const SwDrawBaseShell *>( m_pShell ) == nullptr && - dynamic_cast< const SwBezierShell *>( m_pShell ) == nullptr && - dynamic_cast< const svx::ExtrusionBar *>( m_pShell ) == nullptr && - dynamic_cast< const svx::FontworkBar *>( m_pShell ) == nullptr) - { - SdrView *pSdrView = m_pWrtShell->GetDrawView(); + pTest = pDispatch->GetShell(nIdx++); + } + while( pTest && pTest != this && pTest != m_pShell); + if(!(pTest == m_pShell && + // don't call LeaveSelFrameMode() etc. for the below, + // because objects may still be selected: + dynamic_cast< const SwDrawBaseShell *>( m_pShell ) == nullptr && + dynamic_cast< const SwBezierShell *>( m_pShell ) == nullptr && + dynamic_cast< const svx::ExtrusionBar *>( m_pShell ) == nullptr && + dynamic_cast< const svx::FontworkBar *>( m_pShell ) == nullptr)) + return; - if (pSdrView && pSdrView->IsGroupEntered()) - { - pSdrView->LeaveOneGroup(); - pSdrView->UnmarkAll(); - GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP); - } + SdrView *pSdrView = m_pWrtShell->GetDrawView(); - if (GetDrawFuncPtr()) - { - if (m_pWrtShell->IsSelFrameMode()) - m_pWrtShell->LeaveSelFrameMode(); - GetDrawFuncPtr()->Deactivate(); + if (pSdrView && pSdrView->IsGroupEntered()) + { + pSdrView->LeaveOneGroup(); + pSdrView->UnmarkAll(); + GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP); + } - SetDrawFuncPtr(nullptr); - LeaveDrawCreate(); + if (GetDrawFuncPtr()) + { + if (m_pWrtShell->IsSelFrameMode()) + m_pWrtShell->LeaveSelFrameMode(); + GetDrawFuncPtr()->Deactivate(); - GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW); - } - GetEditWin().SetPointer(PointerStyle::Text); - } + SetDrawFuncPtr(nullptr); + LeaveDrawCreate(); + + GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW); } + GetEditWin().SetPointer(PointerStyle::Text); } // Disable rotate mode diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx index 136283bc8053..66df1f44c950 100644 --- a/sw/source/uibase/uiview/viewport.cxx +++ b/sw/source/uibase/uiview/viewport.cxx @@ -739,23 +739,23 @@ IMPL_LINK( SwView, ScrollHdl, ScrollBar *, p, void ) IMPL_LINK( SwView, EndScrollHdl, ScrollBar *, p, void ) { SwScrollbar* pScrollbar = static_cast<SwScrollbar*>(p); - if ( !GetWrtShell().ActionPend() ) - { - if(nPgNum) - { - nPgNum = 0; - Help::ShowQuickHelp(pScrollbar, tools::Rectangle(), OUString()); - } - Point aPos( m_aVisArea.TopLeft() ); - bool bBorder = IsDocumentBorder(); - lcl_GetPos(this, aPos, pScrollbar, bBorder); - if ( bBorder && aPos == m_aVisArea.TopLeft() ) - UpdateScrollbars(); - else - SetVisArea( aPos, false ); + if ( GetWrtShell().ActionPend() ) + return; - GetViewFrame()->GetBindings().Update(FN_STAT_PAGE); + if(nPgNum) + { + nPgNum = 0; + Help::ShowQuickHelp(pScrollbar, tools::Rectangle(), OUString()); } + Point aPos( m_aVisArea.TopLeft() ); + bool bBorder = IsDocumentBorder(); + lcl_GetPos(this, aPos, pScrollbar, bBorder); + if ( bBorder && aPos == m_aVisArea.TopLeft() ) + UpdateScrollbars(); + else + SetVisArea( aPos, false ); + + GetViewFrame()->GetBindings().Update(FN_STAT_PAGE); } // Calculates the size of the m_aVisArea in dependency of the size of diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx index ba259e62d9b8..0617b8387fe9 100644 --- a/sw/source/uibase/uiview/viewprt.cxx +++ b/sw/source/uibase/uiview/viewprt.cxx @@ -318,32 +318,32 @@ void SetAppPrintOptions( SwViewShell* pSh, bool bWeb ) const IDocumentDeviceAccess& rIDDA = pSh->getIDocumentDeviceAccess(); const SwPrintData& aPrtData = rIDDA.getPrintData(); - if( rIDDA.getPrinter( false ) ) - { - // Close application own printing options in SfxPrinter. - SwAddPrinterItem aAddPrinterItem(aPrtData); - SfxItemSet aSet( - pSh->GetAttrPool(), - svl::Items< - SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, - SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, - SID_HTML_MODE, SID_HTML_MODE, - FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER>{}); - - if(bWeb) - aSet.Put(SfxUInt16Item(SID_HTML_MODE, - ::GetHtmlMode(static_cast<SwWrtShell*>(pSh)->GetView().GetDocShell()))); - aSet.Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, - officecfg::Office::Common::Print::Warning::NotFound::get() )); - aSet.Put(aAddPrinterItem); - aSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, - static_cast<int>(officecfg::Office::Common::Print::Warning::PaperSize::get() - ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE) | - static_cast<int>(officecfg::Office::Common::Print::Warning::PaperOrientation::get() - ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE ))); - - rIDDA.getPrinter( true )->SetOptions( aSet ); - } + if( !rIDDA.getPrinter( false ) ) + return; + + // Close application own printing options in SfxPrinter. + SwAddPrinterItem aAddPrinterItem(aPrtData); + SfxItemSet aSet( + pSh->GetAttrPool(), + svl::Items< + SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, + SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, + SID_HTML_MODE, SID_HTML_MODE, + FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER>{}); + + if(bWeb) + aSet.Put(SfxUInt16Item(SID_HTML_MODE, + ::GetHtmlMode(static_cast<SwWrtShell*>(pSh)->GetView().GetDocShell()))); + aSet.Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, + officecfg::Office::Common::Print::Warning::NotFound::get() )); + aSet.Put(aAddPrinterItem); + aSet.Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, + static_cast<int>(officecfg::Office::Common::Print::Warning::PaperSize::get() + ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE) | + static_cast<int>(officecfg::Office::Common::Print::Warning::PaperOrientation::get() + ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE ))); + + rIDDA.getPrinter( true )->SetOptions( aSet ); } diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 440b77ad7968..c037f5394a5d 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -89,37 +89,38 @@ static void lcl_addContainerToJson(boost::property_tree::ptree& rTree, const OSt static void lcl_emitSearchResultCallbacks(SvxSearchItem const * pSearchItem, SwWrtShell const * pWrtShell, bool bHighlightAll) { // Emit a callback also about the selection rectangles, grouped by matches. - if (SwPaM* pPaM = pWrtShell->GetCursor()) + SwPaM* pPaM = pWrtShell->GetCursor(); + if (!pPaM) + return; + + std::vector<OString> aMatches; + for (SwPaM& rPaM : pPaM->GetRingContainer()) { - std::vector<OString> aMatches; - for (SwPaM& rPaM : pPaM->GetRingContainer()) + if (SwShellCursor* pShellCursor = dynamic_cast<SwShellCursor*>(&rPaM)) { - if (SwShellCursor* pShellCursor = dynamic_cast<SwShellCursor*>(&rPaM)) + std::vector<OString> aSelectionRectangles; + pShellCursor->SwSelPaintRects::Show(&aSelectionRectangles); + std::vector<OString> aRect; + for (const OString & rSelectionRectangle : aSelectionRectangles) { - std::vector<OString> aSelectionRectangles; - pShellCursor->SwSelPaintRects::Show(&aSelectionRectangles); - std::vector<OString> aRect; - for (const OString & rSelectionRectangle : aSelectionRectangles) - { - if (rSelectionRectangle.isEmpty()) - continue; - aRect.push_back(rSelectionRectangle); - } - OString sRect = comphelper::string::join("; ", aRect); - aMatches.push_back(sRect); + if (rSelectionRectangle.isEmpty()) + continue; + aRect.push_back(rSelectionRectangle); } + OString sRect = comphelper::string::join("; ", aRect); + aMatches.push_back(sRect); } - boost::property_tree::ptree aTree; - aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr()); - aTree.put("highlightAll", bHighlightAll); - lcl_addContainerToJson(aTree, "searchResultSelection", aMatches); + } + boost::property_tree::ptree aTree; + aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr()); + aTree.put("highlightAll", bHighlightAll); + lcl_addContainerToJson(aTree, "searchResultSelection", aMatches); - std::stringstream aStream; - boost::property_tree::write_json(aStream, aTree); - OString aPayload = aStream.str().c_str(); + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree); + OString aPayload = aStream.str().c_str(); - pWrtShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr()); - } + pWrtShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr()); } void SwView::ExecSearch(SfxRequest& rReq) diff --git a/sw/source/uibase/uno/dlelstnr.cxx b/sw/source/uibase/uno/dlelstnr.cxx index aeb72b54056f..76a66603928b 100644 --- a/sw/source/uibase/uno/dlelstnr.cxx +++ b/sw/source/uibase/uno/dlelstnr.cxx @@ -83,19 +83,19 @@ void SAL_CALL SwLinguServiceEventListener::processLinguServiceEvent( { SwModule::CheckSpellChanges( false, bIsSpellWrong, bIsSpellAll, false ); } - if (rLngSvcEvent.nEvent & HYPHENATE_AGAIN) - { - SwView *pSwView = SwModule::GetFirstView(); + if (!(rLngSvcEvent.nEvent & HYPHENATE_AGAIN)) + return; - //!! since this function may be called within the ctor of - //!! SwView (during formatting) where the WrtShell is not yet - //!! created, we have to check for the WrtShellPtr to see - //!! if it is already available - while (pSwView && pSwView->GetWrtShellPtr()) - { - pSwView->GetWrtShell().ChgHyphenation(); - pSwView = SwModule::GetNextView( pSwView ); - } + SwView *pSwView = SwModule::GetFirstView(); + + //!! since this function may be called within the ctor of + //!! SwView (during formatting) where the WrtShell is not yet + //!! created, we have to check for the WrtShellPtr to see + //!! if it is already available + while (pSwView && pSwView->GetWrtShellPtr()) + { + pSwView->GetWrtShell().ChgHyphenation(); + pSwView = SwModule::GetNextView( pSwView ); } } diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx index 2a13d735b3bc..b4f1cfe2e194 100644 --- a/sw/source/uibase/uno/unoatxt.cxx +++ b/sw/source/uibase/uno/unoatxt.cxx @@ -708,47 +708,48 @@ SwXAutoTextEntry::~SwXAutoTextEntry() void SwXAutoTextEntry::implFlushDocument( bool _bCloseDoc ) { - if ( xDocSh.is() ) - { - if ( xDocSh->GetDoc()->getIDocumentState().IsModified () ) - xDocSh->Save(); + if ( !xDocSh.is() ) + return; - if ( _bCloseDoc ) - { - // stop listening at the document - EndListening( *xDocSh ); + if ( xDocSh->GetDoc()->getIDocumentState().IsModified () ) + xDocSh->Save(); - xDocSh->DoClose(); - xDocSh.clear(); - } + if ( _bCloseDoc ) + { + // stop listening at the document + EndListening( *xDocSh ); + + xDocSh->DoClose(); + xDocSh.clear(); } } void SwXAutoTextEntry::Notify( SfxBroadcaster& _rBC, const SfxHint& _rHint ) { - if ( &_rBC == xDocSh.get() ) - { // it's our document - if (const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&_rHint)) + if ( &_rBC != xDocSh.get() ) + return; + +// it's our document + if (const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&_rHint)) + { + if (SfxEventHintId::PrepareCloseDoc == pEventHint->GetEventId()) { - if (SfxEventHintId::PrepareCloseDoc == pEventHint->GetEventId()) - { - implFlushDocument(); - mxBodyText.clear(); - EndListening( *xDocSh ); - xDocSh.clear(); - } + implFlushDocument(); + mxBodyText.clear(); + EndListening( *xDocSh ); + xDocSh.clear(); } - else + } + else + { + if ( SfxHintId::Deinitializing == _rHint.GetId() ) { - if ( SfxHintId::Deinitializing == _rHint.GetId() ) - { - // our document is dying (possibly because we're shutting down, and the document was notified - // earlier than we are?) - // stop listening at the docu - EndListening( *xDocSh ); - // and release our reference - xDocSh.clear(); - } + // our document is dying (possibly because we're shutting down, and the document was notified + // earlier than we are?) + // stop listening at the docu + EndListening( *xDocSh ); + // and release our reference + xDocSh.clear(); } } } @@ -987,17 +988,17 @@ void SwAutoTextEventDescriptor::replaceByName( OSL_ENSURE( pBlocks, "can't get autotext group; SwAutoTextEntry has illegal name?"); - if( pBlocks && !pBlocks->GetError()) + if( !(pBlocks && !pBlocks->GetError())) + return; + + sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() ); + if( nIndex != USHRT_MAX ) { - sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() ); - if( nIndex != USHRT_MAX ) + SvxMacroTableDtor aMacroTable; + if( pBlocks->GetMacroTable( nIndex, aMacroTable ) ) { - SvxMacroTableDtor aMacroTable; - if( pBlocks->GetMacroTable( nIndex, aMacroTable ) ) - { - aMacroTable.Insert( nEvent, rMacro ); - pBlocks->SetMacroTable( nIndex, aMacroTable ); - } + aMacroTable.Insert( nEvent, rMacro ); + pBlocks->SetMacroTable( nIndex, aMacroTable ); } } // else: ignore @@ -1024,18 +1025,18 @@ void SwAutoTextEventDescriptor::getByName( SvxMacro aEmptyMacro(sEmptyStr, sEmptyStr); rMacro = aEmptyMacro; - if ( pBlocks && !pBlocks->GetError()) + if ( !(pBlocks && !pBlocks->GetError())) + return; + + sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() ); + if( nIndex != USHRT_MAX ) { - sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() ); - if( nIndex != USHRT_MAX ) + SvxMacroTableDtor aMacroTable; + if( pBlocks->GetMacroTable( nIndex, aMacroTable ) ) { - SvxMacroTableDtor aMacroTable; - if( pBlocks->GetMacroTable( nIndex, aMacroTable ) ) - { - SvxMacro *pMacro = aMacroTable.Get( nEvent ); - if( pMacro ) - rMacro = *pMacro; - } + SvxMacro *pMacro = aMacroTable.Get( nEvent ); + if( pMacro ) + rMacro = *pMacro; } } } diff --git a/sw/source/uibase/uno/unodispatch.cxx b/sw/source/uibase/uno/unodispatch.cxx index 3c6412dfad6a..4060c0d08a39 100644 --- a/sw/source/uibase/uno/unodispatch.cxx +++ b/sw/source/uibase/uno/unodispatch.cxx @@ -338,23 +338,23 @@ void SwXDispatch::selectionChanged( const lang::EventObject& ) ShellMode::ListText == eMode || ShellMode::TableText == eMode || ShellMode::TableListText == eMode; - if(bEnable != m_bOldEnable) - { - m_bOldEnable = bEnable; - frame::FeatureStateEvent aEvent; - aEvent.IsEnabled = bEnable; - aEvent.Source = *static_cast<cppu::OWeakObject*>(this); + if(bEnable == m_bOldEnable) + return; - // calls to statusChanged may call addStatusListener or removeStatusListener - // so copy m_aStatusListenerVector on stack - auto copyStatusListenerVector = m_aStatusListenerVector; - for (auto & status : copyStatusListenerVector) - { - aEvent.FeatureURL = status.aURL; - if (status.aURL.Complete != cURLDocumentDataSource) - // the document's data source does not depend on the selection, so it's state does not change here - status.xListener->statusChanged( aEvent ); - } + m_bOldEnable = bEnable; + frame::FeatureStateEvent aEvent; + aEvent.IsEnabled = bEnable; + aEvent.Source = *static_cast<cppu::OWeakObject*>(this); + + // calls to statusChanged may call addStatusListener or removeStatusListener + // so copy m_aStatusListenerVector on stack + auto copyStatusListenerVector = m_aStatusListenerVector; + for (auto & status : copyStatusListenerVector) + { + aEvent.FeatureURL = status.aURL; + if (status.aURL.Complete != cURLDocumentDataSource) + // the document's data source does not depend on the selection, so it's state does not change here + status.xListener->statusChanged( aEvent ); } } diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index a590e61f040a..11ef3d90df17 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -449,36 +449,36 @@ SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper () void SwXTextDocument::GetNumberFormatter() { - if(IsValid()) + if(!IsValid()) + return; + + if(!xNumFormatAgg.is()) { - if(!xNumFormatAgg.is()) + if ( pDocShell->GetDoc() ) { - if ( pDocShell->GetDoc() ) - { - SvNumberFormatsSupplierObj* pNumFormat = new SvNumberFormatsSupplierObj( - pDocShell->GetDoc()->GetNumberFormatter()); - Reference< util::XNumberFormatsSupplier > xTmp = pNumFormat; - xNumFormatAgg.set(xTmp, UNO_QUERY); - } - if(xNumFormatAgg.is()) - xNumFormatAgg->setDelegator(static_cast<cppu::OWeakObject*>(static_cast<SwXTextDocumentBaseClass*>(this))); + SvNumberFormatsSupplierObj* pNumFormat = new SvNumberFormatsSupplierObj( + pDocShell->GetDoc()->GetNumberFormatter()); + Reference< util::XNumberFormatsSupplier > xTmp = pNumFormat; + xNumFormatAgg.set(xTmp, UNO_QUERY); } - else + if(xNumFormatAgg.is()) + xNumFormatAgg->setDelegator(static_cast<cppu::OWeakObject*>(static_cast<SwXTextDocumentBaseClass*>(this))); + } + else + { + const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get(); + Any aNumTunnel = xNumFormatAgg->queryAggregation(rTunnelType); + SvNumberFormatsSupplierObj* pNumFormat = nullptr; + Reference< XUnoTunnel > xNumTunnel; + if(aNumTunnel >>= xNumTunnel) { - const uno::Type& rTunnelType = cppu::UnoType<XUnoTunnel>::get(); - Any aNumTunnel = xNumFormatAgg->queryAggregation(rTunnelType); - SvNumberFormatsSupplierObj* pNumFormat = nullptr; - Reference< XUnoTunnel > xNumTunnel; - if(aNumTunnel >>= xNumTunnel) - { - pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>( - xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId())); + pNumFormat = reinterpret_cast<SvNumberFormatsSupplierObj*>( + xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId())); - } - OSL_ENSURE(pNumFormat, "No number formatter available"); - if (pNumFormat && !pNumFormat->GetNumberFormatter()) - pNumFormat->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter()); } + OSL_ENSURE(pNumFormat, "No number formatter available"); + if (pNumFormat && !pNumFormat->GetNumberFormatter()) + pNumFormat->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter()); } } @@ -3232,20 +3232,20 @@ void SwXTextDocument::setClientZoom(int nTilePixelWidth_, int /*nTilePixelHeight // for in place chart editing. We assume that x and y scale is roughly // the same. SfxInPlaceClient* pIPClient = pDocShell->GetView()->GetIPClient(); - if (pIPClient) + if (!pIPClient) + return; + + SwViewShell* pWrtViewShell = pDocShell->GetWrtShell(); + double fScale = nTilePixelWidth_ * TWIPS_PER_PIXEL / (nTileTwipWidth_ * 1.0); + SwViewOption aOption(*(pWrtViewShell->GetViewOptions())); + if (aOption.GetZoom() != fScale * 100) { - SwViewShell* pWrtViewShell = pDocShell->GetWrtShell(); - double fScale = nTilePixelWidth_ * TWIPS_PER_PIXEL / (nTileTwipWidth_ * 1.0); - SwViewOption aOption(*(pWrtViewShell->GetViewOptions())); - if (aOption.GetZoom() != fScale * 100) - { - aOption.SetZoom(fScale * 100); - pWrtViewShell->ApplyViewOptions(aOption); + aOption.SetZoom(fScale * 100); + pWrtViewShell->ApplyViewOptions(aOption); - // Changing the zoom value doesn't always trigger the updating of - // the client ole object area, so we call it directly. - pIPClient->VisAreaChanged(); - } + // Changing the zoom value doesn't always trigger the updating of + // the client ole object area, so we call it directly. + pIPClient->VisAreaChanged(); } } @@ -3266,44 +3266,44 @@ void SwXTextDocument::getTrackedChanges(tools::JsonWriter& rJson) // Disable since usability is very low beyond some small number of changes. static bool bDisableRedlineComments = getenv("DISABLE_REDLINE") != nullptr; - if (!bDisableRedlineComments) - { - const SwRedlineTable& rRedlineTable - = pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); - for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i) + if (bDisableRedlineComments) + return; + + const SwRedlineTable& rRedlineTable + = pDocShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); + for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i) + { + auto redlineNode = rJson.startNode(""); + rJson.put("index", rRedlineTable[i]->GetId()); + rJson.put("author", rRedlineTable[i]->GetAuthorString(1)); + rJson.put("type", SwRedlineTypeToOUString( + rRedlineTable[i]->GetRedlineData().GetType())); + rJson.put("comment", + rRedlineTable[i]->GetRedlineData().GetComment()); + rJson.put("description", rRedlineTable[i]->GetDescr()); + OUString sDateTime = utl::toISO8601( + rRedlineTable[i]->GetRedlineData().GetTimeStamp().GetUNODateTime()); + rJson.put("dateTime", sDateTime); + + SwContentNode* pContentNd = rRedlineTable[i]->GetContentNode(); + SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current()); + if (pView && pContentNd) { - auto redlineNode = rJson.startNode(""); - rJson.put("index", rRedlineTable[i]->GetId()); - rJson.put("author", rRedlineTable[i]->GetAuthorString(1)); - rJson.put("type", SwRedlineTypeToOUString( - rRedlineTable[i]->GetRedlineData().GetType())); - rJson.put("comment", - rRedlineTable[i]->GetRedlineData().GetComment()); - rJson.put("description", rRedlineTable[i]->GetDescr()); - OUString sDateTime = utl::toISO8601( - rRedlineTable[i]->GetRedlineData().GetTimeStamp().GetUNODateTime()); - rJson.put("dateTime", sDateTime); - - SwContentNode* pContentNd = rRedlineTable[i]->GetContentNode(); - 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()); + SwShellCursor aCursor(pView->GetWrtShell(), *(rRedlineTable[i]->Start())); + aCursor.SetMark(); + aCursor.GetMark()->nNode = *pContentNd; + aCursor.GetMark()->nContent.Assign(pContentNd, + rRedlineTable[i]->End()->nContent.GetIndex()); - aCursor.FillRects(); + aCursor.FillRects(); - SwRects* pRects(&aCursor); - std::vector<OString> aRects; - for (const SwRect& rNextRect : *pRects) - aRects.push_back(rNextRect.SVRect().toString()); + SwRects* pRects(&aCursor); + std::vector<OString> aRects; + for (const SwRect& rNextRect : *pRects) + aRects.push_back(rNextRect.SVRect().toString()); - const OString sRects = comphelper::string::join("; ", aRects); - rJson.put("textRange", sRects); - } + const OString sRects = comphelper::string::join("; ", aRects); + rJson.put("textRange", sRects); } } } @@ -3363,33 +3363,33 @@ void SwXTextDocument::getPostIts(tools::JsonWriter& rJsonWriter) void SwXTextDocument::executeFromFieldEvent(const StringMap& aArguments) { auto aIter = aArguments.find("type"); - if (aIter != aArguments.end() && aIter->second == "drop-down") + if (!(aIter != aArguments.end() && aIter->second == "drop-down")) + return; + + aIter = aArguments.find("cmd"); + if (!(aIter != aArguments.end() && aIter->second == "selected")) + return; + + aIter = aArguments.find("data"); + if (aIter == aArguments.end()) + return; + + sal_Int32 nSelection = aIter->second.toInt32(); + SwPosition aPos(*pDocShell->GetWrtShell()->GetCursor()->GetPoint()); + sw::mark::IFieldmark* pFieldBM = pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos); + if ( !pFieldBM ) + { + --aPos.nContent; + pFieldBM = pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos); + } + if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN) { - aIter = aArguments.find("cmd"); - if (aIter != aArguments.end() && aIter->second == "selected") + if (nSelection >= 0) { - aIter = aArguments.find("data"); - if (aIter != aArguments.end()) - { - sal_Int32 nSelection = aIter->second.toInt32(); - SwPosition aPos(*pDocShell->GetWrtShell()->GetCursor()->GetPoint()); - sw::mark::IFieldmark* pFieldBM = pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos); - if ( !pFieldBM ) - { - --aPos.nContent; - pFieldBM = pDocShell->GetWrtShell()->getIDocumentMarkAccess()->getFieldmarkFor(aPos); - } - if (pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDROPDOWN) - { - if (nSelection >= 0) - { - (*pFieldBM->GetParameters())[ODF_FORMDROPDOWN_RESULT] <<= nSelection; - pFieldBM->Invalidate(); - pDocShell->GetWrtShell()->SetModified(); - pDocShell->GetView()->GetEditWin().LogicInvalidate(nullptr); - } - } - } + (*pFieldBM->GetParameters())[ODF_FORMDROPDOWN_RESULT] <<= nSelection; + pFieldBM->Invalidate(); + pDocShell->GetWrtShell()->SetModified(); + pDocShell->GetView()->GetEditWin().LogicInvalidate(nullptr); } } } diff --git a/sw/source/uibase/uno/unotxvw.cxx b/sw/source/uibase/uno/unotxvw.cxx index b83a52500e4d..464d4192ce15 100644 --- a/sw/source/uibase/uno/unotxvw.cxx +++ b/sw/source/uibase/uno/unotxvw.cxx @@ -1406,30 +1406,30 @@ OUString SwXTextViewCursor::getString() void SwXTextViewCursor::setString(const OUString& aString) { SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection( false )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); + if(!m_pView) + return; - ShellMode eSelMode = m_pView->GetShellMode(); - switch(eSelMode) - { - //! since setString for SEL_TABLE_TEXT (with possible - //! multi selection of cells) would not work properly we - //! will ignore this case for both - //! functions (setString AND getString) because of symmetrie. + if (!IsTextSelection( false )) + throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - case ShellMode::ListText : - case ShellMode::TableListText : - case ShellMode::Text : - { - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwCursor* pShellCursor = rSh.GetSwCursor(); - SwUnoCursorHelper::SetString(*pShellCursor, aString); - break; - } - default:;//prevent warning + ShellMode eSelMode = m_pView->GetShellMode(); + switch(eSelMode) + { + //! since setString for SEL_TABLE_TEXT (with possible + //! multi selection of cells) would not work properly we + //! will ignore this case for both + //! functions (setString AND getString) because of symmetrie. + + case ShellMode::ListText : + case ShellMode::TableListText : + case ShellMode::Text : + { + SwWrtShell& rSh = m_pView->GetWrtShell(); + SwCursor* pShellCursor = rSh.GetSwCursor(); + SwUnoCursorHelper::SetString(*pShellCursor, aString); + break; } + default:;//prevent warning } } |