diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 10:41:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 13:43:27 +0200 |
commit | 19525a7f83203d734d0f234626e1ba0726ef14ff (patch) | |
tree | 0a0b934ddbf141f77291ca01c2d22faf2f337fe5 /sw | |
parent | 6a97decccb2d8ea32dfcd12b88901a15782de838 (diff) |
loplugin:flatten in sw/uibase/shells
Change-Id: I003c2c4e48bb59590ba952c74e3ee4733ce1051f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99764
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/shells/annotsh.cxx | 20 | ||||
-rw-r--r-- | sw/source/uibase/shells/basesh.cxx | 447 | ||||
-rw-r--r-- | sw/source/uibase/shells/drawsh.cxx | 96 | ||||
-rw-r--r-- | sw/source/uibase/shells/drwtxtex.cxx | 40 | ||||
-rw-r--r-- | sw/source/uibase/shells/drwtxtsh.cxx | 214 | ||||
-rw-r--r-- | sw/source/uibase/shells/frmsh.cxx | 524 | ||||
-rw-r--r-- | sw/source/uibase/shells/grfsh.cxx | 34 | ||||
-rw-r--r-- | sw/source/uibase/shells/langhelper.cxx | 130 | ||||
-rw-r--r-- | sw/source/uibase/shells/listsh.cxx | 104 | ||||
-rw-r--r-- | sw/source/uibase/shells/mediash.cxx | 80 | ||||
-rw-r--r-- | sw/source/uibase/shells/tabsh.cxx | 40 | ||||
-rw-r--r-- | sw/source/uibase/shells/textfld.cxx | 988 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh.cxx | 166 |
13 files changed, 1443 insertions, 1440 deletions
diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 0c81d1d00009..f43534d66eb3 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -1457,19 +1457,19 @@ void SwAnnotationShell::ExecTransliteration(SfxRequest const &rReq) void SwAnnotationShell::ExecRotateTransliteration( SfxRequest const & rReq ) { - if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE ) - { - SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); - if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin()) - return; + if( rReq.GetSlot() != SID_TRANSLITERATE_ROTATE_CASE ) + return; + + SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); + if (!pPostItMgr || !pPostItMgr->HasActiveSidebarWin()) + return; - OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); + OutlinerView* pOLV = pPostItMgr->GetActiveSidebarWin()->GetOutlinerView(); - if (!pOLV) - return; + if (!pOLV) + return; - pOLV->TransliterateText(m_aRotateCase.getNextMode()); - } + pOLV->TransliterateText(m_aRotateCase.getNextMode()); } void SwAnnotationShell::ExecUndo(SfxRequest &rReq) diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 7b91c5c8aee8..59faca317408 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -1261,69 +1261,71 @@ void SwBaseShell::Execute(SfxRequest &rReq) pItem = nullptr; pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem); - if(pItem) - switch(nSlot) + if(!pItem) + return; + + switch(nSlot) + { + case SID_ATTR_BRUSH: + case SID_ATTR_BORDER_SHADOW: + case RES_SHADOW: + { + rSh.StartAllAction(); + // Tabele cell(s) selected? + if ( rSh.IsTableMode() ) { - case SID_ATTR_BRUSH: - case SID_ATTR_BORDER_SHADOW: - case RES_SHADOW: + SwFrameFormat *pFormat = rSh.GetTableFormat(); + pFormat->SetFormatAttr( *pItem ); + } + else if ( rSh.IsFrameSelected() ) { - rSh.StartAllAction(); - // Tabele cell(s) selected? - if ( rSh.IsTableMode() ) - { - SwFrameFormat *pFormat = rSh.GetTableFormat(); - pFormat->SetFormatAttr( *pItem ); - } - else if ( rSh.IsFrameSelected() ) - { - // Set border attributes via Frame-Manager. - SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); - aMgr.SetAttrSet( *pArgs ); - aMgr.UpdateFlyFrame(); - } - else - { - rSh.SetAttrSet( *pArgs ); - } - rSh.EndAllAction(); + // Set border attributes via Frame-Manager. + SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); + aMgr.SetAttrSet( *pArgs ); + aMgr.UpdateFlyFrame(); } - break; - case FN_PAGE_STYLE_SET_LR_MARGIN: - case FN_PAGE_STYLE_SET_UL_MARGIN: - case FN_PAGE_STYLE_SET_NUMBER_FORMAT: - case FN_PAGE_STYLE_SET_PAPER_SIZE: - case FN_PAGE_STYLE_SET_PAPER_BIN: + else { - OSL_FAIL("not implemented"); + rSh.SetAttrSet( *pArgs ); } - break; + rSh.EndAllAction(); + } + break; + case FN_PAGE_STYLE_SET_LR_MARGIN: + case FN_PAGE_STYLE_SET_UL_MARGIN: + case FN_PAGE_STYLE_SET_NUMBER_FORMAT: + case FN_PAGE_STYLE_SET_PAPER_SIZE: + case FN_PAGE_STYLE_SET_PAPER_BIN: + { + OSL_FAIL("not implemented"); + } + break; - case SID_ATTR_BORDER_OUTER: + case SID_ATTR_BORDER_OUTER: + { + // Tabele cell(s) selected? + if ( rSh.IsTableMode() ) { - // Tabele cell(s) selected? - if ( rSh.IsTableMode() ) - { - // Set border attributes Get/SetTabBorders() - rSh.SetTabBorders(*pArgs); - } - else if ( rSh.IsFrameSelected() ) - { - // Set border attributes via Frame-Manager. - SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); - aMgr.SetAttrSet(*pArgs); - aMgr.UpdateFlyFrame(); - } - else - { - // Set border attributes via shell quite normally. - rSh.SetAttrItem( *pItem ); - } + // Set border attributes Get/SetTabBorders() + rSh.SetTabBorders(*pArgs); } - break; - default: - OSL_FAIL("wrong Dispatcher"); + else if ( rSh.IsFrameSelected() ) + { + // Set border attributes via Frame-Manager. + SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); + aMgr.SetAttrSet(*pArgs); + aMgr.UpdateFlyFrame(); } + else + { + // Set border attributes via shell quite normally. + rSh.SetAttrItem( *pItem ); + } + } + break; + default: + OSL_FAIL("wrong Dispatcher"); + } } // Here the state for SID_IMAP / SID_CONTOUR will be handled @@ -1335,94 +1337,93 @@ IMPL_LINK_NOARG(SwBaseShell, GraphicArrivedHdl, SwCursorShell&, void) if (CNT_GRF != rSh.SwEditShell::GetCntType()) return; GraphicType const nGrfType(rSh.GetGraphicType()); - if (GraphicType::NONE != nGrfType && - !aGrfUpdateSlots.empty() ) + if (GraphicType::NONE == nGrfType || aGrfUpdateSlots.empty()) + return; + + bool bProtect = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + for( const auto nSlot : aGrfUpdateSlots ) { - bool bProtect = FlyProtectFlags::NONE != rSh.IsSelObjProtected(FlyProtectFlags::Content|FlyProtectFlags::Parent); - SfxViewFrame* pVFrame = GetView().GetViewFrame(); - for( const auto nSlot : aGrfUpdateSlots ) + bool bSetState = false; + bool bState = false; + switch( nSlot ) { - bool bSetState = false; - bool bState = false; - switch( nSlot ) + case SID_IMAP: + case SID_IMAP_EXEC: { - case SID_IMAP: - case SID_IMAP_EXEC: - { - sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); - SfxChildWindow *pChildWindow = pVFrame->HasChildWindow(nId) ? - pVFrame->GetChildWindow(nId) : nullptr; - SvxIMapDlg *pDlg = pChildWindow ? - static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr; + sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); + SfxChildWindow *pChildWindow = pVFrame->HasChildWindow(nId) ? + pVFrame->GetChildWindow(nId) : nullptr; + SvxIMapDlg *pDlg = pChildWindow ? + static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr; - if( pDlg && ( SID_IMAP_EXEC == nSlot || - ( SID_IMAP == nSlot && !bProtect)) && - pDlg->GetEditingObject() != rSh.GetIMapInventor()) - lcl_UpdateIMapDlg( rSh ); + if( pDlg && ( SID_IMAP_EXEC == nSlot || + ( SID_IMAP == nSlot && !bProtect)) && + pDlg->GetEditingObject() != rSh.GetIMapInventor()) + lcl_UpdateIMapDlg( rSh ); - if( !bProtect && SID_IMAP == nSlot ) - { - bSetState = true; - bState = nullptr != pDlg; - } - } - break; - - case SID_CONTOUR_DLG: - if( !bProtect ) + if( !bProtect && SID_IMAP == nSlot ) { - sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); - SfxChildWindow *pChildWindow = pVFrame->HasChildWindow(nId) ? - pVFrame->GetChildWindow(nId) : nullptr; - SvxIMapDlg *pDlg = pChildWindow ? - static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr; - if( pDlg && pDlg->GetEditingObject() != - rSh.GetIMapInventor() ) - lcl_UpdateContourDlg( rSh, SelectionType::Graphic ); - bSetState = true; bState = nullptr != pDlg; } - break; + } + break; - case FN_FRAME_WRAP_CONTOUR: - if( !bProtect ) - { - SfxItemSet aSet(GetPool(), svl::Items<RES_SURROUND, RES_SURROUND>{}); - rSh.GetFlyFrameAttr(aSet); - const SwFormatSurround& rWrap = aSet.Get(RES_SURROUND); - bSetState = true; - bState = rWrap.IsContour(); - } - break; + case SID_CONTOUR_DLG: + if( !bProtect ) + { + sal_uInt16 nId = SvxContourDlgChildWindow::GetChildWindowId(); + SfxChildWindow *pChildWindow = pVFrame->HasChildWindow(nId) ? + pVFrame->GetChildWindow(nId) : nullptr; + SvxIMapDlg *pDlg = pChildWindow ? + static_cast<SvxIMapDlg*>(pChildWindow->GetController().get()) : nullptr; + if( pDlg && pDlg->GetEditingObject() != + rSh.GetIMapInventor() ) + lcl_UpdateContourDlg( rSh, SelectionType::Graphic ); - case SID_GRFFILTER: - case SID_GRFFILTER_INVERT: - case SID_GRFFILTER_SMOOTH: - case SID_GRFFILTER_SHARPEN: - case SID_GRFFILTER_REMOVENOISE: - case SID_GRFFILTER_SOBEL: - case SID_GRFFILTER_MOSAIC: - case SID_GRFFILTER_EMBOSS: - case SID_GRFFILTER_POSTER: - case SID_GRFFILTER_POPART: - case SID_GRFFILTER_SEPIA: - case SID_GRFFILTER_SOLARIZE: - bSetState = bState = GraphicType::Bitmap == nGrfType; - break; + bSetState = true; + bState = nullptr != pDlg; } + break; - if( bSetState ) + case FN_FRAME_WRAP_CONTOUR: + if( !bProtect ) { - SfxBoolItem aBool( nSlot, bState ); - if( pGetStateSet ) - pGetStateSet->Put( aBool ); - else - pVFrame->GetBindings().SetState( aBool ); + SfxItemSet aSet(GetPool(), svl::Items<RES_SURROUND, RES_SURROUND>{}); + rSh.GetFlyFrameAttr(aSet); + const SwFormatSurround& rWrap = aSet.Get(RES_SURROUND); + bSetState = true; + bState = rWrap.IsContour(); } + break; + + case SID_GRFFILTER: + case SID_GRFFILTER_INVERT: + case SID_GRFFILTER_SMOOTH: + case SID_GRFFILTER_SHARPEN: + case SID_GRFFILTER_REMOVENOISE: + case SID_GRFFILTER_SOBEL: + case SID_GRFFILTER_MOSAIC: + case SID_GRFFILTER_EMBOSS: + case SID_GRFFILTER_POSTER: + case SID_GRFFILTER_POPART: + case SID_GRFFILTER_SEPIA: + case SID_GRFFILTER_SOLARIZE: + bSetState = bState = GraphicType::Bitmap == nGrfType; + break; + } + + if( bSetState ) + { + SfxBoolItem aBool( nSlot, bState ); + if( pGetStateSet ) + pGetStateSet->Put( aBool ); + else + pVFrame->GetBindings().SetState( aBool ); } - aGrfUpdateSlots.clear(); } + aGrfUpdateSlots.clear(); } void SwBaseShell::GetState( SfxItemSet &rSet ) @@ -2743,125 +2744,125 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest ) const SfxItemSet* pArgs = _rRequest.GetArgs(); SwWrtShell& rSh = GetShell(); - if ( !( rSh.GetFrameType( nullptr, true ) & FrameTypeFlags::FOOTNOTE ) ) - { - SwView &rTempView = GetView(); // Because GetView() does not work after the shell exchange - bool bHTMLMode = 0 != (::GetHtmlMode(rTempView.GetDocShell())&HTMLMODE_ON); - bool bCallEndUndo = false; + if ( rSh.GetFrameType( nullptr, true ) & FrameTypeFlags::FOOTNOTE ) + return; - if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() && - !rSh.IsTableMode() ) - { - const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); - SwInsertTableOptions aInsTableOpts = pModOpt->GetInsTableFlags(bHTMLMode); + SwView &rTempView = GetView(); // Because GetView() does not work after the shell exchange + bool bHTMLMode = 0 != (::GetHtmlMode(rTempView.GetDocShell())&HTMLMODE_ON); + bool bCallEndUndo = false; - rSh.StartUndo(SwUndoId::INSTABLE); - bCallEndUndo = true; + if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() && + !rSh.IsTableMode() ) + { + const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); + SwInsertTableOptions aInsTableOpts = pModOpt->GetInsTableFlags(bHTMLMode); - bool bInserted = rSh.TextToTable( aInsTableOpts, '\t' ); - rSh.EnterStdMode(); - if (bInserted) - rTempView.AutoCaption(TABLE_CAP); - _rRequest.Done(); - } - else + rSh.StartUndo(SwUndoId::INSTABLE); + bCallEndUndo = true; + + bool bInserted = rSh.TextToTable( aInsTableOpts, '\t' ); + rSh.EnterStdMode(); + if (bInserted) + rTempView.AutoCaption(TABLE_CAP); + _rRequest.Done(); + } + else + { + sal_uInt16 nColsIn = 0; + sal_uInt16 nRowsIn = 0; + SwInsertTableOptions aInsTableOptsIn( SwInsertTableFlags::All, 1 ); + OUString aTableNameIn; + OUString aAutoNameIn; + std::unique_ptr<SwTableAutoFormat> pTAFormatIn; + + if( pArgs && pArgs->Count() >= 2 ) { - sal_uInt16 nColsIn = 0; - sal_uInt16 nRowsIn = 0; - SwInsertTableOptions aInsTableOptsIn( SwInsertTableFlags::All, 1 ); - OUString aTableNameIn; - OUString aAutoNameIn; - std::unique_ptr<SwTableAutoFormat> pTAFormatIn; - - if( pArgs && pArgs->Count() >= 2 ) - { - const SfxStringItem* pName = _rRequest.GetArg<SfxStringItem>(FN_INSERT_TABLE); - const SfxUInt16Item* pCols = _rRequest.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_COLUMN); - const SfxUInt16Item* pRows = _rRequest.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_ROW); - const SfxInt32Item* pFlags = _rRequest.GetArg<SfxInt32Item>(FN_PARAM_1); - const SfxStringItem* pAuto = _rRequest.GetArg<SfxStringItem>(FN_PARAM_2); - - if ( pName ) - aTableNameIn = pName->GetValue(); - if ( pCols ) - nColsIn = pCols->GetValue(); - if ( pRows ) - nRowsIn = pRows->GetValue(); - if ( pAuto ) - { - aAutoNameIn = pAuto->GetValue(); - if ( !aAutoNameIn.isEmpty() ) + const SfxStringItem* pName = _rRequest.GetArg<SfxStringItem>(FN_INSERT_TABLE); + const SfxUInt16Item* pCols = _rRequest.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_COLUMN); + const SfxUInt16Item* pRows = _rRequest.GetArg<SfxUInt16Item>(SID_ATTR_TABLE_ROW); + const SfxInt32Item* pFlags = _rRequest.GetArg<SfxInt32Item>(FN_PARAM_1); + const SfxStringItem* pAuto = _rRequest.GetArg<SfxStringItem>(FN_PARAM_2); + + if ( pName ) + aTableNameIn = pName->GetValue(); + if ( pCols ) + nColsIn = pCols->GetValue(); + if ( pRows ) + nRowsIn = pRows->GetValue(); + if ( pAuto ) + { + aAutoNameIn = pAuto->GetValue(); + if ( !aAutoNameIn.isEmpty() ) + { + SwTableAutoFormatTable aTableTable; + aTableTable.Load(); + for ( size_t n=0; n<aTableTable.size(); n++ ) { - SwTableAutoFormatTable aTableTable; - aTableTable.Load(); - for ( size_t n=0; n<aTableTable.size(); n++ ) + if ( aTableTable[n].GetName() == aAutoNameIn ) { - if ( aTableTable[n].GetName() == aAutoNameIn ) - { - pTAFormatIn.reset(new SwTableAutoFormat( aTableTable[n] )); - break; - } + pTAFormatIn.reset(new SwTableAutoFormat( aTableTable[n] )); + break; } } } - - if ( pFlags ) - aInsTableOptsIn.mnInsMode = static_cast<SwInsertTableFlags>(pFlags->GetValue()); - else - { - const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); - aInsTableOptsIn = pModOpt->GetInsTableFlags(bHTMLMode); - } } - if( !nColsIn || !nRowsIn ) + if ( pFlags ) + aInsTableOptsIn.mnInsMode = static_cast<SwInsertTableFlags>(pFlags->GetValue()); + else { - SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - std::shared_ptr<AbstractInsTableDlg> pAbstractDialog(pFact->CreateInsTableDlg(rTempView)); - std::shared_ptr<weld::DialogController> pDialogController(pAbstractDialog->getDialogController()); + const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig(); + aInsTableOptsIn = pModOpt->GetInsTableFlags(bHTMLMode); + } + } - weld::DialogController::runAsync(pDialogController, - [pAbstractDialog, &rSh, &rTempView, aTableNameIn, nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn] (sal_Int32 nResult) { - if( RET_OK == nResult ) - { - sal_uInt16 nCols = nColsIn; - sal_uInt16 nRows = nRowsIn; - SwInsertTableOptions aInsTableOpts = aInsTableOptsIn; - OUString aTableName = aTableNameIn; - OUString aAutoName = aAutoNameIn; - std::unique_ptr<SwTableAutoFormat> pTAFormat; + if( !nColsIn || !nRowsIn ) + { + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + std::shared_ptr<AbstractInsTableDlg> pAbstractDialog(pFact->CreateInsTableDlg(rTempView)); + std::shared_ptr<weld::DialogController> pDialogController(pAbstractDialog->getDialogController()); - pAbstractDialog->GetValues( aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat ); + weld::DialogController::runAsync(pDialogController, + [pAbstractDialog, &rSh, &rTempView, aTableNameIn, nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn] (sal_Int32 nResult) { + if( RET_OK == nResult ) + { + sal_uInt16 nCols = nColsIn; + sal_uInt16 nRows = nRowsIn; + SwInsertTableOptions aInsTableOpts = aInsTableOptsIn; + OUString aTableName = aTableNameIn; + OUString aAutoName = aAutoNameIn; + std::unique_ptr<SwTableAutoFormat> pTAFormat; - if( nCols && nRows ) - { - InsertTableImpl( rSh, rTempView, aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat ); - EndUndo(rSh); - } + pAbstractDialog->GetValues( aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat ); + + if( nCols && nRows ) + { + InsertTableImpl( rSh, rTempView, aTableName, nRows, nCols, aInsTableOpts, aAutoName, pTAFormat ); + EndUndo(rSh); } } - ); - } - else - { - // record before shell change - _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableNameIn ) ); - if ( !aAutoNameIn.isEmpty() ) - _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoNameIn ) ); - _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nColsIn ) ); - _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRowsIn ) ); - _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, static_cast<sal_Int32>(aInsTableOptsIn.mnInsMode) ) ); - _rRequest.Done(); + } + ); + } + else + { + // record before shell change + _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableNameIn ) ); + if ( !aAutoNameIn.isEmpty() ) + _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoNameIn ) ); + _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nColsIn ) ); + _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRowsIn ) ); + _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, static_cast<sal_Int32>(aInsTableOptsIn.mnInsMode) ) ); + _rRequest.Done(); - InsertTableImpl( rSh, rTempView, aTableNameIn, nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn, pTAFormatIn ); + InsertTableImpl( rSh, rTempView, aTableNameIn, nRowsIn, nColsIn, aInsTableOptsIn, aAutoNameIn, pTAFormatIn ); - bCallEndUndo = true; - } + bCallEndUndo = true; } - - if( bCallEndUndo ) - EndUndo(rSh); } + + if( bCallEndUndo ) + EndUndo(rSh); } void SwBaseShell::GetGalleryState( SfxItemSet &rSet ) diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx index 958a38b2a39a..fe8e6b470479 100644 --- a/sw/source/uibase/shells/drawsh.cxx +++ b/sw/source/uibase/shells/drawsh.cxx @@ -114,67 +114,67 @@ void SwDrawShell::InsertPictureFromFile(SdrObject& rObject) SwWrtShell &rSh = GetShell(); SdrView* pSdrView = rSh.GetDrawView(); - if(pSdrView) - { - SvxOpenGraphicDialog aDlg(SwResId(STR_INSERT_GRAPHIC), GetView().GetFrameWeld()); + if(!pSdrView) + return; - if (ERRCODE_NONE == aDlg.Execute()) - { - Graphic aGraphic; - ErrCode nError = aDlg.GetGraphic(aGraphic); + SvxOpenGraphicDialog aDlg(SwResId(STR_INSERT_GRAPHIC), GetView().GetFrameWeld()); - if(ERRCODE_NONE == nError) - { - const bool bAsLink(aDlg.IsAsLink()); - SdrObject* pResult = &rObject; + if (ERRCODE_NONE != aDlg.Execute()) + return; - rSh.StartUndo(SwUndoId::PASTE_CLIPBOARD); + Graphic aGraphic; + ErrCode nError = aDlg.GetGraphic(aGraphic); - if (SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(&rObject)) - { - SdrGrafObj* pNewGrafObj(pSdrGrafObj->CloneSdrObject(pSdrGrafObj->getSdrModelFromSdrObject())); + if(ERRCODE_NONE != nError) + return; - pNewGrafObj->SetGraphic(aGraphic); + const bool bAsLink(aDlg.IsAsLink()); + SdrObject* pResult = &rObject; - // #i123922# for handling MasterObject and virtual ones correctly, SW - // wants us to call ReplaceObject at the page, but that also - // triggers the same assertion (I tried it), so stay at the view method - pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj); + rSh.StartUndo(SwUndoId::PASTE_CLIPBOARD); - OUString aReferer; - SwDocShell *pDocShell = rSh.GetDoc()->GetDocShell(); - if (pDocShell->HasName()) { - aReferer = pDocShell->GetMedium()->GetName(); - } + if (SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(&rObject)) + { + SdrGrafObj* pNewGrafObj(pSdrGrafObj->CloneSdrObject(pSdrGrafObj->getSdrModelFromSdrObject())); - // set in all cases - the Clone() will have copied an existing link (!) - pNewGrafObj->SetGraphicLink( - bAsLink ? aDlg.GetPath() : OUString(), - aReferer, - bAsLink ? aDlg.GetDetectedFilter() : OUString()); + pNewGrafObj->SetGraphic(aGraphic); - pResult = pNewGrafObj; - } - else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject)) - { - pSdrView->AddUndo(std::make_unique<SdrUndoAttrObj>(rObject)); + // #i123922# for handling MasterObject and virtual ones correctly, SW + // wants us to call ReplaceObject at the page, but that also + // triggers the same assertion (I tried it), so stay at the view method + pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj); - SfxItemSet aSet(pSdrView->GetModel()->GetItemPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLBITMAP>{}); + OUString aReferer; + SwDocShell *pDocShell = rSh.GetDoc()->GetDocShell(); + if (pDocShell->HasName()) { + aReferer = pDocShell->GetMedium()->GetName(); + } - aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP)); - aSet.Put(XFillBitmapItem(OUString(), aGraphic)); - rObject.SetMergedItemSetAndBroadcast(aSet); - } + // set in all cases - the Clone() will have copied an existing link (!) + pNewGrafObj->SetGraphicLink( + bAsLink ? aDlg.GetPath() : OUString(), + aReferer, + bAsLink ? aDlg.GetDetectedFilter() : OUString()); - rSh.EndUndo( SwUndoId::END ); + pResult = pNewGrafObj; + } + else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject)) + { + pSdrView->AddUndo(std::make_unique<SdrUndoAttrObj>(rObject)); - if(pResult) - { - // we are done; mark the modified/new object - pSdrView->MarkObj(pResult, pSdrView->GetSdrPageView()); - } - } - } + SfxItemSet aSet(pSdrView->GetModel()->GetItemPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLBITMAP>{}); + + aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP)); + aSet.Put(XFillBitmapItem(OUString(), aGraphic)); + rObject.SetMergedItemSetAndBroadcast(aSet); + } + + rSh.EndUndo( SwUndoId::END ); + + if(pResult) + { + // we are done; mark the modified/new object + pSdrView->MarkObj(pResult, pSdrView->GetSdrPageView()); } } diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index 185b79dd3eb2..929f2c7d6506 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -93,30 +93,30 @@ namespace OUString sColor; const SfxPoolItem* pItem = nullptr; - if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pItem)) - { - sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); + if (SfxItemState::SET != pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pItem)) + return; - if (sColor == "transparent") - aColor = COL_TRANSPARENT; - else - aColor = Color(sColor.toInt32(16)); + sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); + + if (sColor == "transparent") + aColor = COL_TRANSPARENT; + else + aColor = Color(sColor.toInt32(16)); - switch (nSlot) + switch (nSlot) + { + case SID_ATTR_CHAR_COLOR: { - case SID_ATTR_CHAR_COLOR: - { - SvxColorItem aColorItem(aColor, EE_CHAR_COLOR); - pArgs->Put(aColorItem); - break; - } + SvxColorItem aColorItem(aColor, EE_CHAR_COLOR); + pArgs->Put(aColorItem); + break; + } - case SID_ATTR_CHAR_BACK_COLOR: - { - SvxBackgroundColorItem pBackgroundItem(aColor, EE_CHAR_BKGCOLOR); - pArgs->Put(pBackgroundItem); - break; - } + case SID_ATTR_CHAR_BACK_COLOR: + { + SvxBackgroundColorItem pBackgroundItem(aColor, EE_CHAR_BKGCOLOR); + pArgs->Put(pBackgroundItem); + break; } } } diff --git a/sw/source/uibase/shells/drwtxtsh.cxx b/sw/source/uibase/shells/drwtxtsh.cxx index b8d79ebb9816..4b72415e4aaa 100644 --- a/sw/source/uibase/shells/drwtxtsh.cxx +++ b/sw/source/uibase/shells/drwtxtsh.cxx @@ -202,23 +202,23 @@ void SwDrawTextShell::ExecFormText(SfxRequest const & rReq) const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); - if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) - { - const SfxItemSet& rSet = *rReq.GetArgs(); + if ( !(rMarkList.GetMarkCount() == 1 && rReq.GetArgs()) ) + return; - if ( pDrView->IsTextEdit() ) - { - //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and - // 'this' is not valid anymore - SwView& rTempView = GetView(); - pDrView->SdrEndTextEdit(true); - //this removes the current shell from the dispatcher stack!! - rTempView.AttrChangedNotify(nullptr); - } + const SfxItemSet& rSet = *rReq.GetArgs(); - pDrView->SetAttributes(rSet); + if ( pDrView->IsTextEdit() ) + { + //#111733# Sometimes SdrEndTextEdit() initiates the change in selection and + // 'this' is not valid anymore + SwView& rTempView = GetView(); + pDrView->SdrEndTextEdit(true); + //this removes the current shell from the dispatcher stack!! + rTempView.AttrChangedNotify(nullptr); } + pDrView->SetAttributes(rSet); + } // Return Status values back to FontWork @@ -264,88 +264,88 @@ void SwDrawTextShell::ExecDrawLingu(SfxRequest const &rReq) { SwWrtShell &rSh = GetShell(); OutlinerView* pOutlinerView = pSdrView->GetTextEditOutlinerView(); - if( rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() ) + if( !rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() ) + return; + + switch(rReq.GetSlot()) { - switch(rReq.GetSlot()) - { - case SID_THESAURUS: - pOutlinerView->StartThesaurus(); - break; + case SID_THESAURUS: + pOutlinerView->StartThesaurus(); + break; - case SID_HANGUL_HANJA_CONVERSION: - pOutlinerView->StartTextConversion(LANGUAGE_KOREAN, LANGUAGE_KOREAN, nullptr, - i18n::TextConversionOption::CHARACTER_BY_CHARACTER, true, false); - break; + case SID_HANGUL_HANJA_CONVERSION: + pOutlinerView->StartTextConversion(LANGUAGE_KOREAN, LANGUAGE_KOREAN, nullptr, + i18n::TextConversionOption::CHARACTER_BY_CHARACTER, true, false); + break; - case SID_CHINESE_CONVERSION: - { - //open ChineseTranslationDialog - Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); - if (!xContext.is()) - return; + case SID_CHINESE_CONVERSION: + { + //open ChineseTranslationDialog + Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); + if (!xContext.is()) + return; - Reference<lang::XMultiComponentFactory> xMCF(xContext->getServiceManager()); - if (!xMCF.is()) - return; + Reference<lang::XMultiComponentFactory> xMCF(xContext->getServiceManager()); + if (!xMCF.is()) + return; - Reference<ui::dialogs::XExecutableDialog> xDialog( - xMCF->createInstanceWithContext("com.sun.star.linguistic2.ChineseTranslationDialog", xContext), UNO_QUERY); + Reference<ui::dialogs::XExecutableDialog> xDialog( + xMCF->createInstanceWithContext("com.sun.star.linguistic2.ChineseTranslationDialog", xContext), UNO_QUERY); - Reference<lang::XInitialization> xInit(xDialog, UNO_QUERY); + Reference<lang::XInitialization> xInit(xDialog, UNO_QUERY); - if (!xInit.is()) - return; + if (!xInit.is()) + return; - // initialize dialog - uno::Sequence<uno::Any> aSequence(comphelper::InitAnyPropertySequence( - { - {"ParentWindow", uno::Any(Reference<awt::XWindow>())} - })); - xInit->initialize( aSequence ); + // initialize dialog + uno::Sequence<uno::Any> aSequence(comphelper::InitAnyPropertySequence( + { + {"ParentWindow", uno::Any(Reference<awt::XWindow>())} + })); + xInit->initialize( aSequence ); - //execute dialog - sal_Int16 nDialogRet = xDialog->execute(); - if(RET_OK == nDialogRet) + //execute dialog + sal_Int16 nDialogRet = xDialog->execute(); + if(RET_OK == nDialogRet) + { + //get some parameters from the dialog + bool bToSimplified = true; + bool bUseVariants = true; + bool bCommonTerms = true; + Reference<beans::XPropertySet> xPropertySet(xDialog, UNO_QUERY); + if (xPropertySet.is()) { - //get some parameters from the dialog - bool bToSimplified = true; - bool bUseVariants = true; - bool bCommonTerms = true; - Reference<beans::XPropertySet> xPropertySet(xDialog, UNO_QUERY); - if (xPropertySet.is()) + try { - try - { - xPropertySet->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified; - xPropertySet->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants; - xPropertySet->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms; - } - catch (const Exception&) - { - } + xPropertySet->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified; + xPropertySet->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants; + xPropertySet->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms; } + catch (const Exception&) + { + } + } - //execute translation - LanguageType nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; - LanguageType nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; - sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; - if(!bCommonTerms) - nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; - - vcl::Font aTargetFont = OutputDevice::GetDefaultFont(DefaultFontType::CJK_TEXT, nTargetLang, GetDefaultFontFlags::OnlyOne); + //execute translation + LanguageType nSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED; + LanguageType nTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL; + sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; + if(!bCommonTerms) + nOptions = nOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER; - pOutlinerView->StartTextConversion(nSourceLang, nTargetLang, &aTargetFont, nOptions, false, false); - } + vcl::Font aTargetFont = OutputDevice::GetDefaultFont(DefaultFontType::CJK_TEXT, nTargetLang, GetDefaultFontFlags::OnlyOne); - Reference<lang::XComponent> xComponent(xDialog, UNO_QUERY); - if (xComponent.is()) - xComponent->dispose(); + pOutlinerView->StartTextConversion(nSourceLang, nTargetLang, &aTargetFont, nOptions, false, false); } - break; - default: - OSL_ENSURE(false, "unexpected slot-id"); + Reference<lang::XComponent> xComponent(xDialog, UNO_QUERY); + if (xComponent.is()) + xComponent->dispose(); } + break; + + default: + OSL_ENSURE(false, "unexpected slot-id"); } } @@ -489,43 +489,43 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq) void SwDrawTextShell::ExecUndo(SfxRequest &rReq) { - if( IsTextEdit() ) + if( !IsTextEdit() ) + return; + + bool bCallBase = true; + const SfxItemSet* pArgs = rReq.GetArgs(); + if( pArgs ) { - bool bCallBase = true; - const SfxItemSet* pArgs = rReq.GetArgs(); - if( pArgs ) + sal_uInt16 nId = rReq.GetSlot(), nCnt = 1; + const SfxPoolItem* pItem; + switch( nId ) { - sal_uInt16 nId = rReq.GetSlot(), nCnt = 1; - const SfxPoolItem* pItem; - switch( nId ) + case SID_UNDO: + case SID_REDO: + if( SfxItemState::SET == pArgs->GetItemState( nId, false, &pItem ) && + 1 < (nCnt = static_cast<const SfxUInt16Item*>(pItem)->GetValue()) ) { - case SID_UNDO: - case SID_REDO: - if( SfxItemState::SET == pArgs->GetItemState( nId, false, &pItem ) && - 1 < (nCnt = static_cast<const SfxUInt16Item*>(pItem)->GetValue()) ) + // then we make by ourself. + SfxUndoManager* pUndoManager = GetUndoManager(); + if( pUndoManager ) { - // then we make by ourself. - SfxUndoManager* pUndoManager = GetUndoManager(); - if( pUndoManager ) - { - if( SID_UNDO == nId ) - while( nCnt-- ) - pUndoManager->Undo(); - else - while( nCnt-- ) - pUndoManager->Redo(); - } - bCallBase = false; - GetView().GetViewFrame()->GetBindings().InvalidateAll(false); + if( SID_UNDO == nId ) + while( nCnt-- ) + pUndoManager->Undo(); + else + while( nCnt-- ) + pUndoManager->Redo(); } - break; + bCallBase = false; + GetView().GetViewFrame()->GetBindings().InvalidateAll(false); } + break; } - if( bCallBase ) - { - SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame(); - pSfxViewFrame->ExecuteSlot(rReq, pSfxViewFrame->GetInterface()); - } + } + if( bCallBase ) + { + SfxViewFrame *pSfxViewFrame = GetView().GetViewFrame(); + pSfxViewFrame->ExecuteSlot(rReq, pSfxViewFrame->GetInterface()); } } diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx index 08b6ff047234..c203ace11024 100644 --- a/sw/source/uibase/shells/frmsh.cxx +++ b/sw/source/uibase/shells/frmsh.cxx @@ -734,333 +734,333 @@ void SwFrameShell::GetState(SfxItemSet& rSet) { SwWrtShell &rSh = GetShell(); bool bHtmlMode = 0 != ::GetHtmlMode(rSh.GetView().GetDocShell()); - if (rSh.IsFrameSelected()) - { - SfxItemSet aSet( - rSh.GetAttrPool(), - svl::Items< - RES_LR_SPACE, RES_UL_SPACE, - RES_PRINT, RES_HORI_ORIENT>{}); - rSh.GetFlyFrameAttr( aSet ); + if (!rSh.IsFrameSelected()) + return; - bool bProtect = rSh.IsSelObjProtected(FlyProtectFlags::Pos) != FlyProtectFlags::NONE; - bool bParentCntProt = rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; + SfxItemSet aSet( + rSh.GetAttrPool(), + svl::Items< + RES_LR_SPACE, RES_UL_SPACE, + RES_PRINT, RES_HORI_ORIENT>{}); + rSh.GetFlyFrameAttr( aSet ); + + bool bProtect = rSh.IsSelObjProtected(FlyProtectFlags::Pos) != FlyProtectFlags::NONE; + bool bParentCntProt = rSh.IsSelObjProtected( FlyProtectFlags::Content|FlyProtectFlags::Parent ) != FlyProtectFlags::NONE; - bProtect |= bParentCntProt; + bProtect |= bParentCntProt; - const FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true); - SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); + const FrameTypeFlags eFrameType = rSh.GetFrameType(nullptr,true); + SwFlyFrameAttrMgr aMgr( false, &rSh, Frmmgr_Type::NONE, nullptr ); - SfxWhichIter aIter( rSet ); - sal_uInt16 nWhich = aIter.FirstWhich(); - while ( nWhich ) + SfxWhichIter aIter( rSet ); + sal_uInt16 nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + switch ( nWhich ) { - switch ( nWhich ) + case RES_FRM_SIZE: { - case RES_FRM_SIZE: - { - const SwFormatFrameSize& aSz(aMgr.GetFrameSize()); - rSet.Put(aSz); - } - break; - case RES_VERT_ORIENT: - case RES_HORI_ORIENT: - case SID_ATTR_ULSPACE: - case SID_ATTR_LRSPACE: - case RES_LR_SPACE: - case RES_UL_SPACE: - case RES_PROTECT: - case RES_OPAQUE: - case RES_PRINT: - case RES_SURROUND: + const SwFormatFrameSize& aSz(aMgr.GetFrameSize()); + rSet.Put(aSz); + } + break; + case RES_VERT_ORIENT: + case RES_HORI_ORIENT: + case SID_ATTR_ULSPACE: + case SID_ATTR_LRSPACE: + case RES_LR_SPACE: + case RES_UL_SPACE: + case RES_PROTECT: + case RES_OPAQUE: + case RES_PRINT: + case RES_SURROUND: + { + rSet.Put(aSet.Get(GetPool().GetWhich(nWhich))); + } + break; + case SID_OBJECT_ALIGN: + { + if ( bProtect ) + rSet.DisableItem( nWhich ); + } + break; + case SID_OBJECT_ALIGN_LEFT : + case SID_OBJECT_ALIGN_CENTER : + case SID_OBJECT_ALIGN_RIGHT : + case FN_FRAME_ALIGN_HORZ_CENTER: + case FN_FRAME_ALIGN_HORZ_RIGHT: + case FN_FRAME_ALIGN_HORZ_LEFT: + if ( (eFrameType & FrameTypeFlags::FLY_INCNT) || + bProtect || + ((nWhich == FN_FRAME_ALIGN_HORZ_CENTER || nWhich == SID_OBJECT_ALIGN_CENTER) && + bHtmlMode )) { - rSet.Put(aSet.Get(GetPool().GetWhich(nWhich))); + rSet.DisableItem( nWhich ); } - break; - case SID_OBJECT_ALIGN: + else { - if ( bProtect ) - rSet.DisableItem( nWhich ); - } - break; - case SID_OBJECT_ALIGN_LEFT : - case SID_OBJECT_ALIGN_CENTER : - case SID_OBJECT_ALIGN_RIGHT : - case FN_FRAME_ALIGN_HORZ_CENTER: - case FN_FRAME_ALIGN_HORZ_RIGHT: - case FN_FRAME_ALIGN_HORZ_LEFT: - if ( (eFrameType & FrameTypeFlags::FLY_INCNT) || - bProtect || - ((nWhich == FN_FRAME_ALIGN_HORZ_CENTER || nWhich == SID_OBJECT_ALIGN_CENTER) && - bHtmlMode )) + sal_Int16 nHoriOrient = -1; + switch(nWhich) { - rSet.DisableItem( nWhich ); + case SID_OBJECT_ALIGN_LEFT: + nHoriOrient = text::HoriOrientation::LEFT; + break; + case SID_OBJECT_ALIGN_CENTER: + nHoriOrient = text::HoriOrientation::CENTER; + break; + case SID_OBJECT_ALIGN_RIGHT: + nHoriOrient = text::HoriOrientation::RIGHT; + break; + default: + break; } - else + SwFormatHoriOrient aHOrient(aMgr.GetHoriOrient()); + if (nHoriOrient != -1) + rSet.Put(SfxBoolItem(nWhich, nHoriOrient == aHOrient.GetHoriOrient())); + } + break; + case FN_FRAME_ALIGN_VERT_ROW_TOP: + case FN_FRAME_ALIGN_VERT_ROW_CENTER: + case FN_FRAME_ALIGN_VERT_ROW_BOTTOM: + case FN_FRAME_ALIGN_VERT_CHAR_TOP: + case FN_FRAME_ALIGN_VERT_CHAR_CENTER: + case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM: + if ( !(eFrameType & FrameTypeFlags::FLY_INCNT) || bProtect + || (bHtmlMode && FN_FRAME_ALIGN_VERT_CHAR_BOTTOM == nWhich) ) + rSet.DisableItem( nWhich ); + break; + + case SID_OBJECT_ALIGN_UP : + case SID_OBJECT_ALIGN_MIDDLE : + case SID_OBJECT_ALIGN_DOWN : + + case FN_FRAME_ALIGN_VERT_TOP: + case FN_FRAME_ALIGN_VERT_CENTER: + case FN_FRAME_ALIGN_VERT_BOTTOM: + if ( bProtect || (bHtmlMode && eFrameType & FrameTypeFlags::FLY_ATCNT)) + rSet.DisableItem( nWhich ); + else + { + // These slots need different labels depending on whether they are anchored in a character + // or on a paragraph/page etc. + OUString sNewLabel; + if (eFrameType & FrameTypeFlags::FLY_INCNT) { - sal_Int16 nHoriOrient = -1; - switch(nWhich) + switch (nWhich) { - case SID_OBJECT_ALIGN_LEFT: - nHoriOrient = text::HoriOrientation::LEFT; - break; - case SID_OBJECT_ALIGN_CENTER: - nHoriOrient = text::HoriOrientation::CENTER; + case SID_OBJECT_ALIGN_UP : + case FN_FRAME_ALIGN_VERT_TOP: + sNewLabel = SwResId(STR_FRMUI_TOP_BASE); break; - case SID_OBJECT_ALIGN_RIGHT: - nHoriOrient = text::HoriOrientation::RIGHT; - break; - default: + case SID_OBJECT_ALIGN_MIDDLE : + case FN_FRAME_ALIGN_VERT_CENTER: + sNewLabel = SwResId(STR_FRMUI_CENTER_BASE); break; + case SID_OBJECT_ALIGN_DOWN : + case FN_FRAME_ALIGN_VERT_BOTTOM: + if(!bHtmlMode) + sNewLabel = SwResId(STR_FRMUI_BOTTOM_BASE); + else + rSet.DisableItem( nWhich ); + break; } - SwFormatHoriOrient aHOrient(aMgr.GetHoriOrient()); - if (nHoriOrient != -1) - rSet.Put(SfxBoolItem(nWhich, nHoriOrient == aHOrient.GetHoriOrient())); } - break; - case FN_FRAME_ALIGN_VERT_ROW_TOP: - case FN_FRAME_ALIGN_VERT_ROW_CENTER: - case FN_FRAME_ALIGN_VERT_ROW_BOTTOM: - case FN_FRAME_ALIGN_VERT_CHAR_TOP: - case FN_FRAME_ALIGN_VERT_CHAR_CENTER: - case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM: - if ( !(eFrameType & FrameTypeFlags::FLY_INCNT) || bProtect - || (bHtmlMode && FN_FRAME_ALIGN_VERT_CHAR_BOTTOM == nWhich) ) - rSet.DisableItem( nWhich ); - break; - - case SID_OBJECT_ALIGN_UP : - case SID_OBJECT_ALIGN_MIDDLE : - case SID_OBJECT_ALIGN_DOWN : - - case FN_FRAME_ALIGN_VERT_TOP: - case FN_FRAME_ALIGN_VERT_CENTER: - case FN_FRAME_ALIGN_VERT_BOTTOM: - if ( bProtect || (bHtmlMode && eFrameType & FrameTypeFlags::FLY_ATCNT)) - rSet.DisableItem( nWhich ); else { - // These slots need different labels depending on whether they are anchored in a character - // or on a paragraph/page etc. - OUString sNewLabel; - if (eFrameType & FrameTypeFlags::FLY_INCNT) + if (nWhich != FN_FRAME_ALIGN_VERT_TOP && + nWhich != SID_OBJECT_ALIGN_UP ) { - switch (nWhich) + if (aMgr.GetAnchor() == RndStdIds::FLY_AT_FLY) { - case SID_OBJECT_ALIGN_UP : - case FN_FRAME_ALIGN_VERT_TOP: - sNewLabel = SwResId(STR_FRMUI_TOP_BASE); - break; - case SID_OBJECT_ALIGN_MIDDLE : - case FN_FRAME_ALIGN_VERT_CENTER: - sNewLabel = SwResId(STR_FRMUI_CENTER_BASE); - break; - case SID_OBJECT_ALIGN_DOWN : - case FN_FRAME_ALIGN_VERT_BOTTOM: - if(!bHtmlMode) - sNewLabel = SwResId(STR_FRMUI_BOTTOM_BASE); - else + const SwFrameFormat* pFormat = rSh.IsFlyInFly(); + if (pFormat) + { + const SwFormatFrameSize& rFrameSz = pFormat->GetFrameSize(); + if (rFrameSz.GetHeightSizeType() != SwFrameSize::Fixed) + { rSet.DisableItem( nWhich ); - break; + break; + } + } } } - else + OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(GetFrame()->GetFrame().GetFrameInterface())); + switch (nWhich) { - if (nWhich != FN_FRAME_ALIGN_VERT_TOP && - nWhich != SID_OBJECT_ALIGN_UP ) + case SID_OBJECT_ALIGN_UP : + case FN_FRAME_ALIGN_VERT_TOP: { - if (aMgr.GetAnchor() == RndStdIds::FLY_AT_FLY) - { - const SwFrameFormat* pFormat = rSh.IsFlyInFly(); - if (pFormat) - { - const SwFormatFrameSize& rFrameSz = pFormat->GetFrameSize(); - if (rFrameSz.GetHeightSizeType() != SwFrameSize::Fixed) - { - rSet.DisableItem( nWhich ); - break; - } - } - } + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignTop", aModuleName); + sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties); + break; } - OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(GetFrame()->GetFrame().GetFrameInterface())); - switch (nWhich) + case SID_OBJECT_ALIGN_MIDDLE: + case FN_FRAME_ALIGN_VERT_CENTER: { - case SID_OBJECT_ALIGN_UP : - case FN_FRAME_ALIGN_VERT_TOP: - { - auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignTop", aModuleName); - sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties); - break; - } - case SID_OBJECT_ALIGN_MIDDLE: - case FN_FRAME_ALIGN_VERT_CENTER: - { - auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignVerticalCenter", aModuleName); - sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties); - break; - } - case SID_OBJECT_ALIGN_DOWN: - case FN_FRAME_ALIGN_VERT_BOTTOM: - { - auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignBottom", aModuleName); - sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties); - break; - } + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignVerticalCenter", aModuleName); + sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties); + break; + } + case SID_OBJECT_ALIGN_DOWN: + case FN_FRAME_ALIGN_VERT_BOTTOM: + { + auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:AlignBottom", aModuleName); + sNewLabel = vcl::CommandInfoProvider::GetLabelForCommand(aProperties); + break; } } - if ( !sNewLabel.isEmpty() ) - rSet.Put( SfxStringItem( nWhich, sNewLabel )); } - break; - case SID_HYPERLINK_GETLINK: - { - SvxHyperlinkItem aHLinkItem; - const SfxPoolItem* pItem; + if ( !sNewLabel.isEmpty() ) + rSet.Put( SfxStringItem( nWhich, sNewLabel )); + } + break; + case SID_HYPERLINK_GETLINK: + { + SvxHyperlinkItem aHLinkItem; + const SfxPoolItem* pItem; - SfxItemSet aURLSet(GetPool(), svl::Items<RES_URL, RES_URL>{}); - rSh.GetFlyFrameAttr( aURLSet ); + SfxItemSet aURLSet(GetPool(), svl::Items<RES_URL, RES_URL>{}); + rSh.GetFlyFrameAttr( aURLSet ); - if(SfxItemState::SET == aURLSet.GetItemState(RES_URL, true, &pItem)) - { - const SwFormatURL* pFormatURL = static_cast<const SwFormatURL*>(pItem); - aHLinkItem.SetURL(pFormatURL->GetURL()); - aHLinkItem.SetTargetFrame(pFormatURL->GetTargetFrameName()); - aHLinkItem.SetName(rSh.GetFlyName()); - } + if(SfxItemState::SET == aURLSet.GetItemState(RES_URL, true, &pItem)) + { + const SwFormatURL* pFormatURL = static_cast<const SwFormatURL*>(pItem); + aHLinkItem.SetURL(pFormatURL->GetURL()); + aHLinkItem.SetTargetFrame(pFormatURL->GetTargetFrameName()); + aHLinkItem.SetName(rSh.GetFlyName()); + } - aHLinkItem.SetInsertMode(static_cast<SvxLinkInsertMode>(aHLinkItem.GetInsertMode() | - (bHtmlMode ? HLINK_HTMLMODE : 0))); + aHLinkItem.SetInsertMode(static_cast<SvxLinkInsertMode>(aHLinkItem.GetInsertMode() | + (bHtmlMode ? HLINK_HTMLMODE : 0))); - rSet.Put(aHLinkItem); - } - break; + rSet.Put(aHLinkItem); + } + break; - case FN_FRAME_CHAIN: + case FN_FRAME_CHAIN: + { + const SelectionType nSel = rSh.GetSelectionType(); + if (nSel & SelectionType::Graphic || nSel & SelectionType::Ole) + rSet.DisableItem( FN_FRAME_CHAIN ); + else { - const SelectionType nSel = rSh.GetSelectionType(); - if (nSel & SelectionType::Graphic || nSel & SelectionType::Ole) + const SwFrameFormat *pFormat = rSh.GetFlyFrameFormat(); + if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() || + !pFormat || pFormat->GetChain().GetNext() ) + { rSet.DisableItem( FN_FRAME_CHAIN ); + } else { - const SwFrameFormat *pFormat = rSh.GetFlyFrameFormat(); - if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() || - !pFormat || pFormat->GetChain().GetNext() ) - { - rSet.DisableItem( FN_FRAME_CHAIN ); - } - else - { - bool bChainMode = rSh.GetView().GetEditWin().IsChainMode(); - rSet.Put( SfxBoolItem( FN_FRAME_CHAIN, bChainMode ) ); - } + bool bChainMode = rSh.GetView().GetEditWin().IsChainMode(); + rSet.Put( SfxBoolItem( FN_FRAME_CHAIN, bChainMode ) ); } } - break; - case FN_FRAME_UNCHAIN: + } + break; + case FN_FRAME_UNCHAIN: + { + const SelectionType nSel = rSh.GetSelectionType(); + if (nSel & SelectionType::Graphic || nSel & SelectionType::Ole) + rSet.DisableItem( FN_FRAME_UNCHAIN ); + else { - const SelectionType nSel = rSh.GetSelectionType(); - if (nSel & SelectionType::Graphic || nSel & SelectionType::Ole) - rSet.DisableItem( FN_FRAME_UNCHAIN ); - else + const SwFrameFormat *pFormat = rSh.GetFlyFrameFormat(); + if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() || + !pFormat || !pFormat->GetChain().GetNext() ) { - const SwFrameFormat *pFormat = rSh.GetFlyFrameFormat(); - if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() || - !pFormat || !pFormat->GetChain().GetNext() ) - { - rSet.DisableItem( FN_FRAME_UNCHAIN ); - } + rSet.DisableItem( FN_FRAME_UNCHAIN ); } } - break; - case SID_FRAME_TO_TOP: - case SID_FRAME_TO_BOTTOM: - case FN_FRAME_UP: - case FN_FRAME_DOWN: - if ( bParentCntProt ) - rSet.DisableItem( nWhich ); - break; - - case SID_ATTR_TRANSFORM: - { + } + break; + case SID_FRAME_TO_TOP: + case SID_FRAME_TO_BOTTOM: + case FN_FRAME_UP: + case FN_FRAME_DOWN: + if ( bParentCntProt ) rSet.DisableItem( nWhich ); - } - break; + break; - case SID_ATTR_TRANSFORM_PROTECT_SIZE: - { - const FlyProtectFlags eProtection = rSh.IsSelObjProtected( FlyProtectFlags::Size ); - if ( ( eProtection & FlyProtectFlags::Content ) || - ( eProtection & FlyProtectFlags::Size ) ) - { - rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, true ) ); - } - else - { - rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, false ) ); - } - } - break; + case SID_ATTR_TRANSFORM: + { + rSet.DisableItem( nWhich ); + } + break; - case SID_ATTR_TRANSFORM_WIDTH: + case SID_ATTR_TRANSFORM_PROTECT_SIZE: + { + const FlyProtectFlags eProtection = rSh.IsSelObjProtected( FlyProtectFlags::Size ); + if ( ( eProtection & FlyProtectFlags::Content ) || + ( eProtection & FlyProtectFlags::Size ) ) { - rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, aMgr.GetSize().getWidth() ) ); + rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, true ) ); } - break; - - case SID_ATTR_TRANSFORM_HEIGHT: + else { - rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, aMgr.GetSize().getHeight() ) ); + rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, false ) ); } - break; + } + break; - case FN_FORMAT_FRAME_DLG: - { - const SelectionType nSel = rSh.GetSelectionType(); - if ( bParentCntProt || nSel & SelectionType::Graphic) - rSet.DisableItem( nWhich ); - } - break; - // #i73249# - case FN_TITLE_DESCRIPTION_SHAPE: - case FN_NAME_SHAPE: + case SID_ATTR_TRANSFORM_WIDTH: + { + rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, aMgr.GetSize().getWidth() ) ); + } + break; + + case SID_ATTR_TRANSFORM_HEIGHT: + { + rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, aMgr.GetSize().getHeight() ) ); + } + break; + + case FN_FORMAT_FRAME_DLG: + { + const SelectionType nSel = rSh.GetSelectionType(); + if ( bParentCntProt || nSel & SelectionType::Graphic) + rSet.DisableItem( nWhich ); + } + break; + // #i73249# + case FN_TITLE_DESCRIPTION_SHAPE: + case FN_NAME_SHAPE: + { + SwWrtShell &rWrtSh = GetShell(); + SdrView* pSdrView = rWrtSh.GetDrawViewWithValidMarkList(); + if ( !pSdrView || + pSdrView->GetMarkedObjectCount() != 1 ) { - SwWrtShell &rWrtSh = GetShell(); - SdrView* pSdrView = rWrtSh.GetDrawViewWithValidMarkList(); - if ( !pSdrView || - pSdrView->GetMarkedObjectCount() != 1 ) - { - rSet.DisableItem( nWhich ); - } + rSet.DisableItem( nWhich ); } - break; + } + break; - case FN_POSTIT: + case FN_POSTIT: + { + SwFlyFrame* pFly = rSh.GetSelectedFlyFrame(); + if (pFly) { - SwFlyFrame* pFly = rSh.GetSelectedFlyFrame(); - if (pFly) + SwFrameFormat* pFormat = pFly->GetFormat(); + if (pFormat) { - SwFrameFormat* pFormat = pFly->GetFormat(); - if (pFormat) + RndStdIds eAnchorId = pFormat->GetAnchor().GetAnchorId(); + // SwWrtShell::InsertPostIt() only works on as-char and at-char anchored + // images. + if (eAnchorId != RndStdIds::FLY_AS_CHAR && eAnchorId != RndStdIds::FLY_AT_CHAR) { - RndStdIds eAnchorId = pFormat->GetAnchor().GetAnchorId(); - // SwWrtShell::InsertPostIt() only works on as-char and at-char anchored - // images. - if (eAnchorId != RndStdIds::FLY_AS_CHAR && eAnchorId != RndStdIds::FLY_AT_CHAR) - { - rSet.DisableItem(nWhich); - } + rSet.DisableItem(nWhich); } } } - break; - - default: - /* do nothing */; - break; } - nWhich = aIter.NextWhich(); + break; + + default: + /* do nothing */; + break; } + nWhich = aIter.NextWhich(); } } diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx index 3287de6cb653..df942d4bda64 100644 --- a/sw/source/uibase/shells/grfsh.cxx +++ b/sw/source/uibase/shells/grfsh.cxx @@ -926,25 +926,25 @@ void SwGrfShell::ExecuteRotation(SfxRequest const &rReq) aRotation = 1800; } - if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RESET || 0 != aRotation) + if (rReq.GetSlot() != SID_ROTATE_GRAPHIC_RESET && 0 == aRotation) + return; + + SwWrtShell& rShell = GetShell(); + SfxItemSet aSet( rShell.GetAttrPool(), svl::Items<RES_GRFATR_ROTATION, RES_GRFATR_ROTATION>{} ); + rShell.GetCurAttr( aSet ); + const SwRotationGrf& rRotation = aSet.Get(RES_GRFATR_ROTATION); + SwFlyFrameAttrMgr aMgr(false, &rShell, rShell.IsFrameSelected() ? Frmmgr_Type::NONE : Frmmgr_Type::GRF, nullptr); + + // RotGrfFlyFrame: Possible rotation change here, SwFlyFrameAttrMgr aMgr is available + if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RESET) { - SwWrtShell& rShell = GetShell(); - SfxItemSet aSet( rShell.GetAttrPool(), svl::Items<RES_GRFATR_ROTATION, RES_GRFATR_ROTATION>{} ); - rShell.GetCurAttr( aSet ); - const SwRotationGrf& rRotation = aSet.Get(RES_GRFATR_ROTATION); - SwFlyFrameAttrMgr aMgr(false, &rShell, rShell.IsFrameSelected() ? Frmmgr_Type::NONE : Frmmgr_Type::GRF, nullptr); - - // RotGrfFlyFrame: Possible rotation change here, SwFlyFrameAttrMgr aMgr is available - if (rReq.GetSlot() == SID_ROTATE_GRAPHIC_RESET) - { - aMgr.SetRotation(rRotation.GetValue(), 0, rRotation.GetUnrotatedSize()); - } - else if(0 != aRotation) - { - const sal_uInt16 aNewRotation((aRotation + rRotation.GetValue()) % 3600); + aMgr.SetRotation(rRotation.GetValue(), 0, rRotation.GetUnrotatedSize()); + } + else if(0 != aRotation) + { + const sal_uInt16 aNewRotation((aRotation + rRotation.GetValue()) % 3600); - aMgr.SetRotation(rRotation.GetValue(), aNewRotation, rRotation.GetUnrotatedSize()); - } + aMgr.SetRotation(rRotation.GetValue(), aNewRotation, rRotation.GetUnrotatedSize()); } } diff --git a/sw/source/uibase/shells/langhelper.cxx b/sw/source/uibase/shells/langhelper.cxx index 90904b37dcdc..bff1dc05530f 100644 --- a/sw/source/uibase/shells/langhelper.cxx +++ b/sw/source/uibase/shells/langhelper.cxx @@ -225,77 +225,77 @@ namespace SwLangHelper void SetLanguage( SwWrtShell &rWrtSh, OutlinerView const * pOLV, const ESelection& rSelection, const OUString &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet ) { const LanguageType nLang = SvtLanguageTable::GetLanguageType( rLangText ); - if (nLang != LANGUAGE_DONTKNOW) + if (nLang == LANGUAGE_DONTKNOW) + return; + + EditEngine* pEditEngine = pOLV ? pOLV->GetEditView().GetEditEngine() : nullptr; + OSL_ENSURE( !pOLV || pEditEngine, "OutlinerView without EditEngine???" ); + + //get ScriptType + sal_uInt16 nLangWhichId = 0; + bool bIsSingleScriptType = true; + switch (SvtLanguageOptions::GetScriptTypeOfLanguage( nLang )) { - EditEngine* pEditEngine = pOLV ? pOLV->GetEditView().GetEditEngine() : nullptr; - OSL_ENSURE( !pOLV || pEditEngine, "OutlinerView without EditEngine???" ); + case SvtScriptType::LATIN : nLangWhichId = pEditEngine ? sal_uInt16(EE_CHAR_LANGUAGE) : sal_uInt16(RES_CHRATR_LANGUAGE); break; + case SvtScriptType::ASIAN : nLangWhichId = pEditEngine ? sal_uInt16(EE_CHAR_LANGUAGE_CJK) : sal_uInt16(RES_CHRATR_CJK_LANGUAGE); break; + case SvtScriptType::COMPLEX : nLangWhichId = pEditEngine ? sal_uInt16(EE_CHAR_LANGUAGE_CTL) : sal_uInt16(RES_CHRATR_CTL_LANGUAGE); break; + default: + bIsSingleScriptType = false; + OSL_FAIL("unexpected case" ); + } + if (!bIsSingleScriptType) + return; - //get ScriptType - sal_uInt16 nLangWhichId = 0; - bool bIsSingleScriptType = true; - switch (SvtLanguageOptions::GetScriptTypeOfLanguage( nLang )) + // change language for selection or paragraph + // (for paragraph is handled by previously having set the selection to the + // whole paragraph) + if (bIsForSelection) + { + // apply language to current selection + if (pEditEngine) { - case SvtScriptType::LATIN : nLangWhichId = pEditEngine ? sal_uInt16(EE_CHAR_LANGUAGE) : sal_uInt16(RES_CHRATR_LANGUAGE); break; - case SvtScriptType::ASIAN : nLangWhichId = pEditEngine ? sal_uInt16(EE_CHAR_LANGUAGE_CJK) : sal_uInt16(RES_CHRATR_CJK_LANGUAGE); break; - case SvtScriptType::COMPLEX : nLangWhichId = pEditEngine ? sal_uInt16(EE_CHAR_LANGUAGE_CTL) : sal_uInt16(RES_CHRATR_CTL_LANGUAGE); break; - default: - bIsSingleScriptType = false; - OSL_FAIL("unexpected case" ); + rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId )); + pEditEngine->QuickSetAttribs(rCoreSet, rSelection); } - if (bIsSingleScriptType) + else { - // change language for selection or paragraph - // (for paragraph is handled by previously having set the selection to the - // whole paragraph) - if (bIsForSelection) - { - // apply language to current selection - if (pEditEngine) - { - rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId )); - pEditEngine->QuickSetAttribs(rCoreSet, rSelection); - } - else - { - rWrtSh.GetCurAttr( rCoreSet ); - rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId )); - rWrtSh.SetAttrSet( rCoreSet ); - } - } - else // change language for all text - { - // set document default language - switch (nLangWhichId) - { - case EE_CHAR_LANGUAGE : nLangWhichId = RES_CHRATR_LANGUAGE; break; - case EE_CHAR_LANGUAGE_CJK : nLangWhichId = RES_CHRATR_CJK_LANGUAGE; break; - case EE_CHAR_LANGUAGE_CTL : nLangWhichId = RES_CHRATR_CTL_LANGUAGE; break; - } - //Set the default document language - rWrtSh.SetDefault( SvxLanguageItem( nLang, nLangWhichId ) ); - - //Resolves: fdo#35282 Clear the language from all Text Styles, and - //fallback to default document language - const SwTextFormatColls *pColls = rWrtSh.GetDoc()->GetTextFormatColls(); - for(size_t i = 0, nCount = pColls->size(); i < nCount; ++i) - { - SwTextFormatColl &rTextColl = *(*pColls)[ i ]; - rTextColl.ResetFormatAttr(nLangWhichId); - } - //Resolves: fdo#35282 Clear the language from all Character Styles, - //and fallback to default document language - const SwCharFormats *pCharFormats = rWrtSh.GetDoc()->GetCharFormats(); - for(size_t i = 0, nCount = pCharFormats->size(); i < nCount; ++i) - { - SwCharFormat &rCharFormat = *(*pCharFormats)[ i ]; - rCharFormat.ResetFormatAttr(nLangWhichId); - } - - // #i102191: hard set respective language attribute in text document - // (for all text in the document - which should be selected by now...) - rWrtSh.SetAttrItem( SvxLanguageItem( nLang, nLangWhichId ) ); - } + rWrtSh.GetCurAttr( rCoreSet ); + rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId )); + rWrtSh.SetAttrSet( rCoreSet ); + } + } + else // change language for all text + { + // set document default language + switch (nLangWhichId) + { + case EE_CHAR_LANGUAGE : nLangWhichId = RES_CHRATR_LANGUAGE; break; + case EE_CHAR_LANGUAGE_CJK : nLangWhichId = RES_CHRATR_CJK_LANGUAGE; break; + case EE_CHAR_LANGUAGE_CTL : nLangWhichId = RES_CHRATR_CTL_LANGUAGE; break; + } + //Set the default document language + rWrtSh.SetDefault( SvxLanguageItem( nLang, nLangWhichId ) ); + + //Resolves: fdo#35282 Clear the language from all Text Styles, and + //fallback to default document language + const SwTextFormatColls *pColls = rWrtSh.GetDoc()->GetTextFormatColls(); + for(size_t i = 0, nCount = pColls->size(); i < nCount; ++i) + { + SwTextFormatColl &rTextColl = *(*pColls)[ i ]; + rTextColl.ResetFormatAttr(nLangWhichId); } + //Resolves: fdo#35282 Clear the language from all Character Styles, + //and fallback to default document language + const SwCharFormats *pCharFormats = rWrtSh.GetDoc()->GetCharFormats(); + for(size_t i = 0, nCount = pCharFormats->size(); i < nCount; ++i) + { + SwCharFormat &rCharFormat = *(*pCharFormats)[ i ]; + rCharFormat.ResetFormatAttr(nLangWhichId); + } + + // #i102191: hard set respective language attribute in text document + // (for all text in the document - which should be selected by now...) + rWrtSh.SetAttrItem( SvxLanguageItem( nLang, nLangWhichId ) ); } } diff --git a/sw/source/uibase/shells/listsh.cxx b/sw/source/uibase/shells/listsh.cxx index a8d7eb91f8c7..8220f6cd4ef1 100644 --- a/sw/source/uibase/shells/listsh.cxx +++ b/sw/source/uibase/shells/listsh.cxx @@ -51,76 +51,76 @@ void SwListShell::InitInterface_Impl() static void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bUp ) { const SwOutlineNodes::size_type nActPos = rSh.GetOutlinePos(); - if ( nActPos < SwOutlineNodes::npos && rSh.IsOutlineMovable( nActPos ) ) + if ( !(nActPos < SwOutlineNodes::npos && rSh.IsOutlineMovable( nActPos )) ) + return; + + rSh.Push(); + rSh.MakeOutlineSel( nActPos, nActPos, true ); + + if ( bMove ) { - rSh.Push(); - rSh.MakeOutlineSel( nActPos, nActPos, true ); + const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() ); + const int nActLevel = pIDoc->getOutlineLevel( nActPos ); + SwOutlineNodes::difference_type nDir = 0; - if ( bMove ) + if ( !bUp ) { - const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() ); - const int nActLevel = pIDoc->getOutlineLevel( nActPos ); - SwOutlineNodes::difference_type nDir = 0; + // Move down with subpoints: + SwOutlineNodes::size_type nActEndPos = nActPos + 1; + while ( nActEndPos < pIDoc->getOutlineNodesCount() && + (!pIDoc->isOutlineInLayout(nActEndPos, *rSh.GetLayout()) + || nActLevel < pIDoc->getOutlineLevel(nActEndPos))) + { + ++nActEndPos; + } - if ( !bUp ) + if ( nActEndPos < pIDoc->getOutlineNodesCount() ) { - // Move down with subpoints: - SwOutlineNodes::size_type nActEndPos = nActPos + 1; - while ( nActEndPos < pIDoc->getOutlineNodesCount() && - (!pIDoc->isOutlineInLayout(nActEndPos, *rSh.GetLayout()) - || nActLevel < pIDoc->getOutlineLevel(nActEndPos))) + // The current subpoint which should be moved + // starts at nActPos and ends at nActEndPos - 1 + --nActEndPos; + SwOutlineNodes::size_type nDest = nActEndPos + 2; + while ( nDest < pIDoc->getOutlineNodesCount() && + (!pIDoc->isOutlineInLayout(nDest, *rSh.GetLayout()) + || nActLevel < pIDoc->getOutlineLevel(nDest))) { - ++nActEndPos; + ++nDest; } - if ( nActEndPos < pIDoc->getOutlineNodesCount() ) - { - // The current subpoint which should be moved - // starts at nActPos and ends at nActEndPos - 1 - --nActEndPos; - SwOutlineNodes::size_type nDest = nActEndPos + 2; - while ( nDest < pIDoc->getOutlineNodesCount() && - (!pIDoc->isOutlineInLayout(nDest, *rSh.GetLayout()) - || nActLevel < pIDoc->getOutlineLevel(nDest))) - { - ++nDest; - } - - nDir = nDest - 1 - nActEndPos; - } + nDir = nDest - 1 - nActEndPos; } - else + } + else + { + // Move up with subpoints: + if ( nActPos > 0 ) { - // Move up with subpoints: - if ( nActPos > 0 ) + SwOutlineNodes::size_type nDest = nActPos - 1; + while (nDest > 0 && + (!pIDoc->isOutlineInLayout(nDest, *rSh.GetLayout()) + || nActLevel < pIDoc->getOutlineLevel(nDest))) { - SwOutlineNodes::size_type nDest = nActPos - 1; - while (nDest > 0 && - (!pIDoc->isOutlineInLayout(nDest, *rSh.GetLayout()) - || nActLevel < pIDoc->getOutlineLevel(nDest))) - { - --nDest; - } - - nDir = nDest - nActPos; + --nDest; } - } - if ( nDir ) - { - rSh.MoveOutlinePara( nDir ); - rSh.GotoOutline( nActPos + nDir ); + nDir = nDest - nActPos; } } - else + + if ( nDir ) { - // Up/down with subpoints: - rSh.OutlineUpDown( bUp ? -1 : 1 ); + rSh.MoveOutlinePara( nDir ); + rSh.GotoOutline( nActPos + nDir ); } - - rSh.ClearMark(); - rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); } + else + { + // Up/down with subpoints: + rSh.OutlineUpDown( bUp ? -1 : 1 ); + } + + rSh.ClearMark(); + rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); } void SwListShell::Execute(SfxRequest &rReq) diff --git a/sw/source/uibase/shells/mediash.cxx b/sw/source/uibase/shells/mediash.cxx index 932b2feb6529..7aaabc817c08 100644 --- a/sw/source/uibase/shells/mediash.cxx +++ b/sw/source/uibase/shells/mediash.cxx @@ -50,67 +50,67 @@ void SwMediaShell::ExecMedia(SfxRequest const &rReq) SwWrtShell* pSh = &GetShell(); SdrView* pSdrView = pSh->GetDrawView(); - if( pSdrView ) - { - const SfxItemSet* pArgs = rReq.GetArgs(); - bool bChanged = pSdrView->GetModel()->IsChanged(); + if( !pSdrView ) + return; + + const SfxItemSet* pArgs = rReq.GetArgs(); + bool bChanged = pSdrView->GetModel()->IsChanged(); - pSdrView->GetModel()->SetChanged( false ); + pSdrView->GetModel()->SetChanged( false ); - switch( rReq.GetSlot() ) + switch( rReq.GetSlot() ) + { + case SID_DELETE: { - case SID_DELETE: + if( pSh->IsObjSelected() ) { - if( pSh->IsObjSelected() ) - { - pSh->SetModified(); - pSh->DelSelectedObj(); + pSh->SetModified(); + pSh->DelSelectedObj(); - if( pSh->IsSelFrameMode() ) - pSh->LeaveSelFrameMode(); + if( pSh->IsSelFrameMode() ) + pSh->LeaveSelFrameMode(); - GetView().AttrChangedNotify(nullptr); - } + GetView().AttrChangedNotify(nullptr); } - break; + } + break; - case SID_AVMEDIA_TOOLBOX: + case SID_AVMEDIA_TOOLBOX: + { + if( pSh->IsObjSelected() ) { - if( pSh->IsObjSelected() ) - { - const SfxPoolItem* pItem; + const SfxPoolItem* pItem; + + if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) ) + pItem = nullptr; - if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) ) - pItem = nullptr; + if( pItem ) + { + std::unique_ptr<SdrMarkList> pMarkList(new SdrMarkList( pSdrView->GetMarkedObjectList() )); - if( pItem ) + if( 1 == pMarkList->GetMarkCount() ) { - std::unique_ptr<SdrMarkList> pMarkList(new SdrMarkList( pSdrView->GetMarkedObjectList() )); + SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); - if( 1 == pMarkList->GetMarkCount() ) + if( dynamic_cast< const SdrMediaObj *>( pObj ) ) { - SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); - - if( dynamic_cast< const SdrMediaObj *>( pObj ) ) - { - static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem( - static_cast< const ::avmedia::MediaItem& >( *pItem ) ); - } + static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem( + static_cast< const ::avmedia::MediaItem& >( *pItem ) ); } } } } - break; - - default: - break; } + break; - if( pSdrView->GetModel()->IsChanged() ) - GetShell().SetModified(); - else if( bChanged ) - pSdrView->GetModel()->SetChanged(); + default: + break; } + + if( pSdrView->GetModel()->IsChanged() ) + GetShell().SetModified(); + else if( bChanged ) + pSdrView->GetModel()->SetChanged(); } void SwMediaShell::GetMediaState(SfxItemSet &rSet) diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 6d4c784c40d5..cd38b92d1adf 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -1489,27 +1489,29 @@ void SwTableShell::ExecTableStyle(SfxRequest& rReq) { SwWrtShell &rSh = GetShell(); const SfxItemSet *pArgs = rReq.GetArgs(); - if(pArgs) - switch ( rReq.GetSlot() ) - { - case SID_FRAME_LINESTYLE: - case SID_FRAME_LINECOLOR: - if ( rReq.GetSlot() == SID_FRAME_LINESTYLE ) - { - const SvxLineItem &rLineItem = pArgs->Get( SID_FRAME_LINESTYLE ); - const SvxBorderLine* pBorderLine = rLineItem.GetLine(); - rSh.SetTabLineStyle( nullptr, true, pBorderLine); - } - else - { - const SvxColorItem &rNewColorItem = pArgs->Get( SID_FRAME_LINECOLOR ); - rSh.SetTabLineStyle( &rNewColorItem.GetValue() ); - } + if(!pArgs) + return; + + switch ( rReq.GetSlot() ) + { + case SID_FRAME_LINESTYLE: + case SID_FRAME_LINECOLOR: + if ( rReq.GetSlot() == SID_FRAME_LINESTYLE ) + { + const SvxLineItem &rLineItem = pArgs->Get( SID_FRAME_LINESTYLE ); + const SvxBorderLine* pBorderLine = rLineItem.GetLine(); + rSh.SetTabLineStyle( nullptr, true, pBorderLine); + } + else + { + const SvxColorItem &rNewColorItem = pArgs->Get( SID_FRAME_LINECOLOR ); + rSh.SetTabLineStyle( &rNewColorItem.GetValue() ); + } - rReq.Done(); + rReq.Done(); - break; - } + break; + } } void SwTableShell::GetLineStyleState(SfxItemSet &rSet) diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 9b7d3b10a4fd..f08c01f2c5fc 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -196,559 +196,559 @@ void SwTextShell::ExecField(SfxRequest &rReq) default: bMore = true; } - if(bMore) + if(!bMore) + return; + + // Here come the slots with FieldMgr. + SwFieldMgr aFieldMgr(GetShellPtr()); + switch(nSlot) { - // Here come the slots with FieldMgr. - SwFieldMgr aFieldMgr(GetShellPtr()); - switch(nSlot) + case FN_INSERT_DBFIELD: { - case FN_INSERT_DBFIELD: + bool bRes = false; + if( pItem ) { - bool bRes = false; - if( pItem ) + sal_uInt32 nFormat = 0; + SwFieldTypesEnum nType = SwFieldTypesEnum::Date; + OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue(); + OUString aPar2; + sal_Int32 nCommand = 0; + + if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, + false, &pItem )) + nType = static_cast<SwFieldTypesEnum>(static_cast<const SfxUInt16Item *>(pItem)->GetValue()); + aPar1 += OUStringChar(DB_DELIM); + if( SfxItemState::SET == pArgs->GetItemState( + FN_PARAM_1, false, &pItem )) { - sal_uInt32 nFormat = 0; - SwFieldTypesEnum nType = SwFieldTypesEnum::Date; - OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue(); - OUString aPar2; - sal_Int32 nCommand = 0; - - if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, - false, &pItem )) - nType = static_cast<SwFieldTypesEnum>(static_cast<const SfxUInt16Item *>(pItem)->GetValue()); - aPar1 += OUStringChar(DB_DELIM); - if( SfxItemState::SET == pArgs->GetItemState( - FN_PARAM_1, false, &pItem )) - { - aPar1 += static_cast<const SfxStringItem *>(pItem)->GetValue(); - } - if( SfxItemState::SET == pArgs->GetItemState( - FN_PARAM_3, false, &pItem )) - nCommand = static_cast<const SfxInt32Item*>(pItem)->GetValue(); - aPar1 += OUStringChar(DB_DELIM) - + OUString::number(nCommand) - + OUStringChar(DB_DELIM); - if( SfxItemState::SET == pArgs->GetItemState( - FN_PARAM_2, false, &pItem )) - { - aPar1 += static_cast<const SfxStringItem *>(pItem)->GetValue(); - } - if( SfxItemState::SET == pArgs->GetItemState( - FN_PARAM_FIELD_CONTENT, false, &pItem )) - aPar2 = static_cast<const SfxStringItem *>(pItem)->GetValue(); - if( SfxItemState::SET == pArgs->GetItemState( - FN_PARAM_FIELD_FORMAT, false, &pItem )) - nFormat = static_cast<const SfxUInt32Item *>(pItem)->GetValue(); - OSL_FAIL("Command is not yet used"); - SwInsertField_Data aData(nType, 0, aPar1, aPar2, nFormat, GetShellPtr(), ' '/*separator*/ ); - bRes = aFieldMgr.InsertField(aData); + aPar1 += static_cast<const SfxStringItem *>(pItem)->GetValue(); } - rReq.SetReturnValue(SfxBoolItem( nSlot, bRes )); - } - break; - case FN_INSERT_FIELD_CTRL: - case FN_INSERT_FIELD: - { - bool bRes = false; - if( pItem && nSlot != FN_INSERT_FIELD_CTRL) + if( SfxItemState::SET == pArgs->GetItemState( + FN_PARAM_3, false, &pItem )) + nCommand = static_cast<const SfxInt32Item*>(pItem)->GetValue(); + aPar1 += OUStringChar(DB_DELIM) + + OUString::number(nCommand) + + OUStringChar(DB_DELIM); + if( SfxItemState::SET == pArgs->GetItemState( + FN_PARAM_2, false, &pItem )) { - sal_uInt32 nFormat = 0; - SwFieldTypesEnum nType = SwFieldTypesEnum::Date; - sal_uInt16 nSubType = 0; - OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue(); - OUString aPar2; - sal_Unicode cSeparator = ' '; - - if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, - false, &pItem )) - nType = static_cast<SwFieldTypesEnum>(static_cast<const SfxUInt16Item *>(pItem)->GetValue()); - if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_SUBTYPE, - false, &pItem )) - nSubType = static_cast<const SfxUInt16Item *>(pItem)->GetValue(); - if( SfxItemState::SET == pArgs->GetItemState( - FN_PARAM_FIELD_CONTENT, false, &pItem )) - aPar2 = static_cast<const SfxStringItem *>(pItem)->GetValue(); - if( SfxItemState::SET == pArgs->GetItemState( - FN_PARAM_FIELD_FORMAT, false, &pItem )) - nFormat = static_cast<const SfxUInt32Item *>(pItem)->GetValue(); - if( SfxItemState::SET == pArgs->GetItemState( - FN_PARAM_3, false, &pItem )) - { - OUString sTmp = static_cast<const SfxStringItem *>(pItem)->GetValue(); - if(!sTmp.isEmpty()) - cSeparator = sTmp[0]; - } - SwInsertField_Data aData(nType, nSubType, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator ); - bRes = aFieldMgr.InsertField( aData ); + aPar1 += static_cast<const SfxStringItem *>(pItem)->GetValue(); } - else - { - //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active - if(!GetView().GetViewFrame()->IsInModalMode()) - { - SfxViewFrame* pVFrame = GetView().GetViewFrame(); - pVFrame->ToggleChildWindow(FN_INSERT_FIELD); - bRes = pVFrame->GetChildWindow( nSlot ) != nullptr; - Invalidate(rReq.GetSlot()); - Invalidate(FN_INSERT_FIELD_CTRL); - rReq.Ignore(); - } - } - rReq.SetReturnValue(SfxBoolItem( nSlot, bRes )); + if( SfxItemState::SET == pArgs->GetItemState( + FN_PARAM_FIELD_CONTENT, false, &pItem )) + aPar2 = static_cast<const SfxStringItem *>(pItem)->GetValue(); + if( SfxItemState::SET == pArgs->GetItemState( + FN_PARAM_FIELD_FORMAT, false, &pItem )) + nFormat = static_cast<const SfxUInt32Item *>(pItem)->GetValue(); + OSL_FAIL("Command is not yet used"); + SwInsertField_Data aData(nType, 0, aPar1, aPar2, nFormat, GetShellPtr(), ' '/*separator*/ ); + bRes = aFieldMgr.InsertField(aData); } - break; - - case FN_INSERT_REF_FIELD: - { - SfxViewFrame* pVFrame = GetView().GetViewFrame(); - if (!pVFrame->HasChildWindow(FN_INSERT_FIELD)) - pVFrame->ToggleChildWindow(FN_INSERT_FIELD); // Show dialog - - // Switch Fielddlg at a new TabPage - sal_uInt16 nId = SwFieldDlgWrapper::GetChildWindowId(); - SwFieldDlgWrapper *pWrp = static_cast<SwFieldDlgWrapper*>(pVFrame->GetChildWindow(nId)); - if (pWrp) - pWrp->ShowReferencePage(); - rReq.Ignore(); - } - break; - case FN_DELETE_COMMENT: + rReq.SetReturnValue(SfxBoolItem( nSlot, bRes )); + } + break; + case FN_INSERT_FIELD_CTRL: + case FN_INSERT_FIELD: + { + bool bRes = false; + if( pItem && nSlot != FN_INSERT_FIELD_CTRL) { - const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); - if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr()) + sal_uInt32 nFormat = 0; + SwFieldTypesEnum nType = SwFieldTypesEnum::Date; + sal_uInt16 nSubType = 0; + OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue(); + OUString aPar2; + sal_Unicode cSeparator = ' '; + + if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_TYPE, + false, &pItem )) + nType = static_cast<SwFieldTypesEnum>(static_cast<const SfxUInt16Item *>(pItem)->GetValue()); + if( SfxItemState::SET == pArgs->GetItemState( FN_PARAM_FIELD_SUBTYPE, + false, &pItem )) + nSubType = static_cast<const SfxUInt16Item *>(pItem)->GetValue(); + if( SfxItemState::SET == pArgs->GetItemState( + FN_PARAM_FIELD_CONTENT, false, &pItem )) + aPar2 = static_cast<const SfxStringItem *>(pItem)->GetValue(); + if( SfxItemState::SET == pArgs->GetItemState( + FN_PARAM_FIELD_FORMAT, false, &pItem )) + nFormat = static_cast<const SfxUInt32Item *>(pItem)->GetValue(); + if( SfxItemState::SET == pArgs->GetItemState( + FN_PARAM_3, false, &pItem )) { - GetView().GetPostItMgr()->Delete(pIdItem->GetValue().toUInt32()); - } - else if ( GetView().GetPostItMgr() && - GetView().GetPostItMgr()->HasActiveSidebarWin() ) - { - GetView().GetPostItMgr()->DeleteActiveSidebarWin(); + OUString sTmp = static_cast<const SfxStringItem *>(pItem)->GetValue(); + if(!sTmp.isEmpty()) + cSeparator = sTmp[0]; } + SwInsertField_Data aData(nType, nSubType, aPar1, aPar2, nFormat, GetShellPtr(), cSeparator ); + bRes = aFieldMgr.InsertField( aData ); } - break; - case FN_RESOLVE_NOTE: + else { - const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); - if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr()) + //#i5788# prevent closing of the field dialog while a modal dialog ( Input field dialog ) is active + if(!GetView().GetViewFrame()->IsInModalMode()) { - GetView().GetPostItMgr()->ToggleResolvedForThread(pIdItem->GetValue().toUInt32()); + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + pVFrame->ToggleChildWindow(FN_INSERT_FIELD); + bRes = pVFrame->GetChildWindow( nSlot ) != nullptr; + Invalidate(rReq.GetSlot()); + Invalidate(FN_INSERT_FIELD_CTRL); + rReq.Ignore(); } } - break; - case FN_DELETE_ALL_NOTES: - if ( GetView().GetPostItMgr() ) - GetView().GetPostItMgr()->Delete(); - break; - case FN_FORMAT_ALL_NOTES: + rReq.SetReturnValue(SfxBoolItem( nSlot, bRes )); + } + break; + + case FN_INSERT_REF_FIELD: + { + SfxViewFrame* pVFrame = GetView().GetViewFrame(); + if (!pVFrame->HasChildWindow(FN_INSERT_FIELD)) + pVFrame->ToggleChildWindow(FN_INSERT_FIELD); // Show dialog + + // Switch Fielddlg at a new TabPage + sal_uInt16 nId = SwFieldDlgWrapper::GetChildWindowId(); + SwFieldDlgWrapper *pWrp = static_cast<SwFieldDlgWrapper*>(pVFrame->GetChildWindow(nId)); + if (pWrp) + pWrp->ShowReferencePage(); + rReq.Ignore(); + } + break; + case FN_DELETE_COMMENT: + { + const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); + if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr()) { - SwPostItMgr* pPostItMgr = GetView().GetPostItMgr(); - if (pPostItMgr) - pPostItMgr->ExecuteFormatAllDialog(GetView()); + GetView().GetPostItMgr()->Delete(pIdItem->GetValue().toUInt32()); } - break; - case FN_DELETE_NOTE_AUTHOR: + else if ( GetView().GetPostItMgr() && + GetView().GetPostItMgr()->HasActiveSidebarWin() ) { - const SfxStringItem* pNoteItem = rReq.GetArg<SfxStringItem>(nSlot); - if ( pNoteItem && GetView().GetPostItMgr() ) - GetView().GetPostItMgr()->Delete( pNoteItem->GetValue() ); + GetView().GetPostItMgr()->DeleteActiveSidebarWin(); } - break; - case FN_HIDE_NOTE: - if ( GetView().GetPostItMgr() && - GetView().GetPostItMgr()->HasActiveSidebarWin() ) - { - GetView().GetPostItMgr()->HideActiveSidebarWin(); - } - break; - case FN_HIDE_ALL_NOTES: - if ( GetView().GetPostItMgr() ) - GetView().GetPostItMgr()->Hide(); - break; - case FN_HIDE_NOTE_AUTHOR: + } + break; + case FN_RESOLVE_NOTE: + { + const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); + if (pIdItem && !pIdItem->GetValue().isEmpty() && GetView().GetPostItMgr()) { - const SfxStringItem* pNoteItem = rReq.GetArg<SfxStringItem>(nSlot); - if ( pNoteItem && GetView().GetPostItMgr() ) - GetView().GetPostItMgr()->Hide( pNoteItem->GetValue() ); + GetView().GetPostItMgr()->ToggleResolvedForThread(pIdItem->GetValue().toUInt32()); } - break; - case FN_REPLY: + } + break; + case FN_DELETE_ALL_NOTES: + if ( GetView().GetPostItMgr() ) + GetView().GetPostItMgr()->Delete(); + break; + case FN_FORMAT_ALL_NOTES: + { + SwPostItMgr* pPostItMgr = GetView().GetPostItMgr(); + if (pPostItMgr) + pPostItMgr->ExecuteFormatAllDialog(GetView()); + } + break; + case FN_DELETE_NOTE_AUTHOR: + { + const SfxStringItem* pNoteItem = rReq.GetArg<SfxStringItem>(nSlot); + if ( pNoteItem && GetView().GetPostItMgr() ) + GetView().GetPostItMgr()->Delete( pNoteItem->GetValue() ); + } + break; + case FN_HIDE_NOTE: + if ( GetView().GetPostItMgr() && + GetView().GetPostItMgr()->HasActiveSidebarWin() ) { - const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); - if (pIdItem && !pIdItem->GetValue().isEmpty()) + GetView().GetPostItMgr()->HideActiveSidebarWin(); + } + break; + case FN_HIDE_ALL_NOTES: + if ( GetView().GetPostItMgr() ) + GetView().GetPostItMgr()->Hide(); + break; + case FN_HIDE_NOTE_AUTHOR: + { + const SfxStringItem* pNoteItem = rReq.GetArg<SfxStringItem>(nSlot); + if ( pNoteItem && GetView().GetPostItMgr() ) + GetView().GetPostItMgr()->Hide( pNoteItem->GetValue() ); + } + break; + case FN_REPLY: + { + const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); + if (pIdItem && !pIdItem->GetValue().isEmpty()) + { + SwFieldType* pType = rSh.GetDoc()->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Postit, OUString(), false); + if(pType->FindFormatForPostItId(pIdItem->GetValue().toUInt32())) { - SwFieldType* pType = rSh.GetDoc()->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::Postit, OUString(), false); - if(pType->FindFormatForPostItId(pIdItem->GetValue().toUInt32())) + auto pMgr = GetView().GetPostItMgr(); + auto pWin = pMgr->GetAnnotationWin(pIdItem->GetValue().toUInt32()); + if(pWin) { - auto pMgr = GetView().GetPostItMgr(); - auto pWin = pMgr->GetAnnotationWin(pIdItem->GetValue().toUInt32()); - if(pWin) - { - OUString sText; - if(const auto pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT)) - sText = pTextItem->GetValue(); - pMgr->RegisterAnswerText(sText); - pWin->ExecuteCommand(nSlot); - } + OUString sText; + if(const auto pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT)) + sText = pTextItem->GetValue(); + pMgr->RegisterAnswerText(sText); + pWin->ExecuteCommand(nSlot); } } } - break; - case FN_POSTIT: - { - rSh.InsertPostIt(aFieldMgr, rReq); - } - break; - case SID_EDIT_POSTIT: + } + break; + case FN_POSTIT: + { + rSh.InsertPostIt(aFieldMgr, rReq); + } + break; + case SID_EDIT_POSTIT: + { + const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); + if (pIdItem && !pIdItem->GetValue().isEmpty()) { - const SvxPostItIdItem* pIdItem = rReq.GetArg<SvxPostItIdItem>(SID_ATTR_POSTIT_ID); - if (pIdItem && !pIdItem->GetValue().isEmpty()) - { - const SvxPostItTextItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT); - OUString sText; - if ( pTextItem ) - sText = pTextItem->GetValue(); + const SvxPostItTextItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT); + OUString sText; + if ( pTextItem ) + sText = pTextItem->GetValue(); - sw::annotation::SwAnnotationWin* pAnnotationWin = GetView().GetPostItMgr()->GetAnnotationWin(pIdItem->GetValue().toUInt32()); - if (pAnnotationWin) - { - pAnnotationWin->UpdateText(sText); + sw::annotation::SwAnnotationWin* pAnnotationWin = GetView().GetPostItMgr()->GetAnnotationWin(pIdItem->GetValue().toUInt32()); + if (pAnnotationWin) + { + pAnnotationWin->UpdateText(sText); - // explicit state update to get the Undo state right - GetView().AttrChangedNotify(nullptr); - } + // explicit state update to get the Undo state right + GetView().AttrChangedNotify(nullptr); } } - break; - case FN_REDLINE_COMMENT: + } + break; + case FN_REDLINE_COMMENT: + { + /* this code can be used once we want redline comments in the margin, all other stuff can + then be deleted + String sComment; + const SwRangeRedline *pRedline = rSh.GetCurrRedline(); + + if (pRedline) { - /* this code can be used once we want redline comments in the margin, all other stuff can - then be deleted - String sComment; - const SwRangeRedline *pRedline = rSh.GetCurrRedline(); + sComment = pRedline->GetComment(); + if ( !sComment.Len() ) + GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED)); + const_cast<SwRangeRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView())); + } + */ - if (pRedline) + const SwRangeRedline *pRedline = rSh.GetCurrRedline(); + SwDoc *pDoc = rSh.GetDoc(); + // If index is specified, goto and select the appropriate redline + if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET) + { + const sal_uInt32 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue(); + const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); + for (SwRedlineTable::size_type nRedline = 0; nRedline < rRedlineTable.size(); ++nRedline) { - sComment = pRedline->GetComment(); - if ( !sComment.Len() ) - GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED)); - const_cast<SwRangeRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView())); + if (nChangeId == rRedlineTable[nRedline]->GetId()) + pRedline = rSh.GotoRedline(nRedline, true); } - */ + } - const SwRangeRedline *pRedline = rSh.GetCurrRedline(); - SwDoc *pDoc = rSh.GetDoc(); - // If index is specified, goto and select the appropriate redline - if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET) + OUString sCommentText; + const SfxStringItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT); + if (pTextItem) + sCommentText = pTextItem->GetValue(); + + if (pRedline) + { + // In case of LOK and comment text is already provided, skip + // dialog creation and just change the redline comment directly + if (comphelper::LibreOfficeKit::isActive() && !sCommentText.isEmpty()) { - const sal_uInt32 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue(); - const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); - for (SwRedlineTable::size_type nRedline = 0; nRedline < rRedlineTable.size(); ++nRedline) - { - if (nChangeId == rRedlineTable[nRedline]->GetId()) - pRedline = rSh.GotoRedline(nRedline, true); - } + rSh.SetRedlineComment(sCommentText); + GetView().AttrChangedNotify(nullptr); + MaybeNotifyRedlineModification(const_cast<SwRangeRedline*>(pRedline), pRedline->GetDoc()); + break; } - OUString sCommentText; - const SfxStringItem* pTextItem = rReq.GetArg<SvxPostItTextItem>(SID_ATTR_POSTIT_TEXT); - if (pTextItem) - sCommentText = pTextItem->GetValue(); + OUString sComment = convertLineEnd(pRedline->GetComment(), GetSystemLineEnd()); - if (pRedline) - { - // In case of LOK and comment text is already provided, skip - // dialog creation and just change the redline comment directly - if (comphelper::LibreOfficeKit::isActive() && !sCommentText.isEmpty()) - { - rSh.SetRedlineComment(sCommentText); - GetView().AttrChangedNotify(nullptr); - MaybeNotifyRedlineModification(const_cast<SwRangeRedline*>(pRedline), pRedline->GetDoc()); - break; - } - - OUString sComment = convertLineEnd(pRedline->GetComment(), GetSystemLineEnd()); + bool bTravel = false; - bool bTravel = false; + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc(); + SfxItemSet aSet(GetPool(), fnGetRange()); + aSet.Put(SvxPostItTextItem(sComment, SID_ATTR_POSTIT_TEXT)); + aSet.Put(SvxPostItAuthorItem(pRedline->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ::DialogGetRanges fnGetRange = pFact->GetDialogGetRangesFunc(); - SfxItemSet aSet(GetPool(), fnGetRange()); - aSet.Put(SvxPostItTextItem(sComment, SID_ATTR_POSTIT_TEXT)); - aSet.Put(SvxPostItAuthorItem(pRedline->GetAuthorString(), SID_ATTR_POSTIT_AUTHOR)); + aSet.Put( SvxPostItDateItem( GetAppLangDateTimeString( + pRedline->GetRedlineData().GetTimeStamp() ), + SID_ATTR_POSTIT_DATE )); - aSet.Put( SvxPostItDateItem( GetAppLangDateTimeString( - pRedline->GetRedlineData().GetTimeStamp() ), - SID_ATTR_POSTIT_DATE )); + // Traveling only if more than one field. + rSh.StartAction(); - // Traveling only if more than one field. - rSh.StartAction(); + rSh.Push(); + const SwRangeRedline *pActRed = rSh.SelPrevRedline(); + if (pActRed == pRedline) + { // New cursor is at the beginning of the current redlines. + rSh.Pop(); // Throw old cursor away rSh.Push(); - const SwRangeRedline *pActRed = rSh.SelPrevRedline(); - - if (pActRed == pRedline) - { // New cursor is at the beginning of the current redlines. - rSh.Pop(); // Throw old cursor away - rSh.Push(); - pActRed = rSh.SelPrevRedline(); - } - - bool bPrev = pActRed != nullptr; - rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); - rSh.EndAction(); + pActRed = rSh.SelPrevRedline(); + } - rSh.ClearMark(); - // Select current redline. - pActRed = rSh.SelNextRedline(); - if (pActRed != pRedline) - rSh.SelPrevRedline(); + bool bPrev = pActRed != nullptr; + rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); + rSh.EndAction(); - rSh.StartAction(); - rSh.Push(); - pActRed = rSh.SelNextRedline(); - bool bNext = pActRed != nullptr; - rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore cursor position + rSh.ClearMark(); + // Select current redline. + pActRed = rSh.SelNextRedline(); + if (pActRed != pRedline) + rSh.SelPrevRedline(); - if( rSh.IsCursorPtAtEnd() ) - rSh.SwapPam(); + rSh.StartAction(); + rSh.Push(); + pActRed = rSh.SelNextRedline(); + bool bNext = pActRed != nullptr; + rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); // Restore cursor position - rSh.EndAction(); + if( rSh.IsCursorPtAtEnd() ) + rSh.SwapPam(); - bTravel |= bNext || bPrev; + rSh.EndAction(); - SvxAbstractDialogFactory* pFact2 = SvxAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSvxPostItDialog> pDlg(pFact2->CreateSvxPostItDialog(GetView().GetFrameWeld(), aSet, bTravel)); - pDlg->HideAuthor(); + bTravel |= bNext || bPrev; - pDlg->SetText(lcl_BuildTitleWithRedline(pRedline)); + SvxAbstractDialogFactory* pFact2 = SvxAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractSvxPostItDialog> pDlg(pFact2->CreateSvxPostItDialog(GetView().GetFrameWeld(), aSet, bTravel)); + pDlg->HideAuthor(); - if (bTravel) - { - pDlg->EnableTravel(bNext, bPrev); - pDlg->SetPrevHdl(LINK(this, SwTextShell, RedlinePrevHdl)); - pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl)); - } + pDlg->SetText(lcl_BuildTitleWithRedline(pRedline)); - SwViewShell::SetCareDialog(pDlg->GetDialog()); - g_bNoInterrupt = true; + if (bTravel) + { + pDlg->EnableTravel(bNext, bPrev); + pDlg->SetPrevHdl(LINK(this, SwTextShell, RedlinePrevHdl)); + pDlg->SetNextHdl(LINK(this, SwTextShell, RedlineNextHdl)); + } - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); - OUString sMsg(pOutSet->Get(SID_ATTR_POSTIT_TEXT).GetValue()); + SwViewShell::SetCareDialog(pDlg->GetDialog()); + g_bNoInterrupt = true; - // Insert or change a comment - rSh.SetRedlineComment(sMsg); - } + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + OUString sMsg(pOutSet->Get(SID_ATTR_POSTIT_TEXT).GetValue()); - SwViewShell::SetCareDialog(nullptr); - pDlg.disposeAndClear(); - g_bNoInterrupt = false; - rSh.ClearMark(); - GetView().AttrChangedNotify(nullptr); + // Insert or change a comment + rSh.SetRedlineComment(sMsg); } + + SwViewShell::SetCareDialog(nullptr); + pDlg.disposeAndClear(); + g_bNoInterrupt = false; + rSh.ClearMark(); + GetView().AttrChangedNotify(nullptr); } - break; + } + break; - case FN_JAVAEDIT: + case FN_JAVAEDIT: + { + OUString aType, aText; + bool bIsUrl=false; + bool bNew=false; + bool bUpdate = false; + SwFieldMgr aMgr; + if ( pItem ) { - OUString aType, aText; - bool bIsUrl=false; - bool bNew=false; - bool bUpdate = false; - SwFieldMgr aMgr; - if ( pItem ) - { - aText = static_cast<const SfxStringItem*>(pItem)->GetValue(); - const SfxStringItem* pType = rReq.GetArg<SfxStringItem>(FN_PARAM_2); - const SfxBoolItem* pIsUrl = rReq.GetArg<SfxBoolItem>(FN_PARAM_1); - if ( pType ) - aType = pType->GetValue(); - if ( pIsUrl ) - bIsUrl = pIsUrl->GetValue(); - - SwScriptField* pField = static_cast<SwScriptField*>(aMgr.GetCurField()); - bNew = !pField || (pField->GetTyp()->Which() != SwFieldIds::Script); - bUpdate = pField && ( bIsUrl != static_cast<bool>(pField->GetFormat()) || pField->GetPar2() != aType || pField->GetPar1() != aText ); - } - else - { - SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractJavaEditDialog> pDlg(pFact->CreateJavaEditDialog(GetView().GetFrameWeld(), &rSh)); - if ( pDlg->Execute() ) - { - aType = pDlg->GetScriptType(); - aText = pDlg->GetScriptText(); - bIsUrl = pDlg->IsUrl(); - bNew = pDlg->IsNew(); - bUpdate = pDlg->IsUpdate(); - rReq.AppendItem( SfxStringItem( FN_JAVAEDIT, aText ) ); - rReq.AppendItem( SfxStringItem( FN_PARAM_2, aType ) ); - rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bIsUrl ) ); - } - } - - if( bNew ) - { - SwInsertField_Data aData(SwFieldTypesEnum::Script, 0, aType, aText, bIsUrl ? 1 : 0); - aMgr.InsertField(aData); - rReq.Done(); - } - else if( bUpdate ) - { - aMgr.UpdateCurField( bIsUrl ? 1 : 0, aType, aText ); - rSh.SetUndoNoResetModified(); - rReq.Done(); - } - else - rReq.Ignore(); + aText = static_cast<const SfxStringItem*>(pItem)->GetValue(); + const SfxStringItem* pType = rReq.GetArg<SfxStringItem>(FN_PARAM_2); + const SfxBoolItem* pIsUrl = rReq.GetArg<SfxBoolItem>(FN_PARAM_1); + if ( pType ) + aType = pType->GetValue(); + if ( pIsUrl ) + bIsUrl = pIsUrl->GetValue(); + + SwScriptField* pField = static_cast<SwScriptField*>(aMgr.GetCurField()); + bNew = !pField || (pField->GetTyp()->Which() != SwFieldIds::Script); + bUpdate = pField && ( bIsUrl != static_cast<bool>(pField->GetFormat()) || pField->GetPar2() != aType || pField->GetPar1() != aText ); } - break; - - case FN_INSERT_FLD_DATE : + else { - nInsertType = SwFieldTypesEnum::Date; - bIsText = false; - // use long date format for Hungarian - SwPaM* pCursorPos = rSh.GetCursor(); - if( pCursorPos ) + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractJavaEditDialog> pDlg(pFact->CreateJavaEditDialog(GetView().GetFrameWeld(), &rSh)); + if ( pDlg->Execute() ) { - LanguageType nLang = pCursorPos->GetPoint()->nNode.GetNode().GetTextNode()->GetLang(pCursorPos->GetPoint()->nContent.GetIndex()); - if (nLang == LANGUAGE_HUNGARIAN) - nInsertFormat = rSh.GetNumberFormatter()->GetFormatIndex(NF_DATE_SYSTEM_LONG, nLang); + aType = pDlg->GetScriptType(); + aText = pDlg->GetScriptText(); + bIsUrl = pDlg->IsUrl(); + bNew = pDlg->IsNew(); + bUpdate = pDlg->IsUpdate(); + rReq.AppendItem( SfxStringItem( FN_JAVAEDIT, aText ) ); + rReq.AppendItem( SfxStringItem( FN_PARAM_2, aType ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bIsUrl ) ); } - goto FIELD_INSERT; } - case FN_INSERT_FLD_TIME : - nInsertType = SwFieldTypesEnum::Time; - bIsText = false; - goto FIELD_INSERT; - case FN_INSERT_FLD_PGNUMBER: - nInsertType = SwFieldTypesEnum::PageNumber; - nInsertFormat = SVX_NUM_PAGEDESC; // Like page template - bIsText = false; - goto FIELD_INSERT; - case FN_INSERT_FLD_PGCOUNT : - nInsertType = SwFieldTypesEnum::DocumentStatistics; - nInsertSubType = 0; - bIsText = false; - nInsertFormat = SVX_NUM_PAGEDESC; - goto FIELD_INSERT; - case FN_INSERT_FLD_TOPIC : - nInsertType = SwFieldTypesEnum::DocumentInfo; - nInsertSubType = DI_SUBJECT; - goto FIELD_INSERT; - case FN_INSERT_FLD_TITLE : - nInsertType = SwFieldTypesEnum::DocumentInfo; - nInsertSubType = DI_TITLE; - goto FIELD_INSERT; - case FN_INSERT_FLD_AUTHOR : - nInsertType = SwFieldTypesEnum::DocumentInfo; - nInsertSubType = DI_CREATE|DI_SUB_AUTHOR; -FIELD_INSERT: + if( bNew ) { - //format conversion should only be done for number formatter formats - if(!nInsertFormat) - nInsertFormat = aFieldMgr.GetDefaultFormat(nInsertType, bIsText, rSh.GetNumberFormatter()); - SwInsertField_Data aData(nInsertType, nInsertSubType, - OUString(), OUString(), nInsertFormat); - aFieldMgr.InsertField(aData); + SwInsertField_Data aData(SwFieldTypesEnum::Script, 0, aType, aText, bIsUrl ? 1 : 0); + aMgr.InsertField(aData); rReq.Done(); } - break; - - case FN_INSERT_TEXT_FORMFIELD: + else if( bUpdate ) { - rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); - - SwPaM* pCursorPos = rSh.GetCursor(); - if(pCursorPos) - { - // Insert five En Space into the text field so the field has extent - static const sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; - bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH)); - if(bSuccess) - { - IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); - SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex() - ODF_FORMFIELD_DEFAULT_LENGTH, - pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex()); - pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMTEXT, - aFieldPam.Start()); - } - } - - rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); - rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); + aMgr.UpdateCurField( bIsUrl ? 1 : 0, aType, aText ); + rSh.SetUndoNoResetModified(); + rReq.Done(); } - break; - case FN_INSERT_CHECKBOX_FORMFIELD: - { - rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); - - SwPaM* pCursorPos = rSh.GetCursor(); - if(pCursorPos) - { - IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); - pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMCHECKBOX); - } + else + rReq.Ignore(); + } + break; - rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); - rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); - } - break; - case FN_INSERT_DROPDOWN_FORMFIELD: + case FN_INSERT_FLD_DATE : + { + nInsertType = SwFieldTypesEnum::Date; + bIsText = false; + // use long date format for Hungarian + SwPaM* pCursorPos = rSh.GetCursor(); + if( pCursorPos ) { - rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + LanguageType nLang = pCursorPos->GetPoint()->nNode.GetNode().GetTextNode()->GetLang(pCursorPos->GetPoint()->nContent.GetIndex()); + if (nLang == LANGUAGE_HUNGARIAN) + nInsertFormat = rSh.GetNumberFormatter()->GetFormatIndex(NF_DATE_SYSTEM_LONG, nLang); + } + goto FIELD_INSERT; + } + case FN_INSERT_FLD_TIME : + nInsertType = SwFieldTypesEnum::Time; + bIsText = false; + goto FIELD_INSERT; + case FN_INSERT_FLD_PGNUMBER: + nInsertType = SwFieldTypesEnum::PageNumber; + nInsertFormat = SVX_NUM_PAGEDESC; // Like page template + bIsText = false; + goto FIELD_INSERT; + case FN_INSERT_FLD_PGCOUNT : + nInsertType = SwFieldTypesEnum::DocumentStatistics; + nInsertSubType = 0; + bIsText = false; + nInsertFormat = SVX_NUM_PAGEDESC; + goto FIELD_INSERT; + case FN_INSERT_FLD_TOPIC : + nInsertType = SwFieldTypesEnum::DocumentInfo; + nInsertSubType = DI_SUBJECT; + goto FIELD_INSERT; + case FN_INSERT_FLD_TITLE : + nInsertType = SwFieldTypesEnum::DocumentInfo; + nInsertSubType = DI_TITLE; + goto FIELD_INSERT; + case FN_INSERT_FLD_AUTHOR : + nInsertType = SwFieldTypesEnum::DocumentInfo; + nInsertSubType = DI_CREATE|DI_SUB_AUTHOR; - SwPaM* pCursorPos = rSh.GetCursor(); - if(pCursorPos) - { - IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); - pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMDROPDOWN); - } +FIELD_INSERT: + { + //format conversion should only be done for number formatter formats + if(!nInsertFormat) + nInsertFormat = aFieldMgr.GetDefaultFormat(nInsertType, bIsText, rSh.GetNumberFormatter()); + SwInsertField_Data aData(nInsertType, nInsertSubType, + OUString(), OUString(), nInsertFormat); + aFieldMgr.InsertField(aData); + rReq.Done(); + } + break; - rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); - rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); - } - break; - case FN_INSERT_DATE_FORMFIELD: + case FN_INSERT_TEXT_FORMFIELD: { rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); SwPaM* pCursorPos = rSh.GetCursor(); if(pCursorPos) { - // Insert five enspaces into the text field so the field has extent - sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; + // Insert five En Space into the text field so the field has extent + static const sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH)); if(bSuccess) { IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex() - ODF_FORMFIELD_DEFAULT_LENGTH, pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex()); - sw::mark::IFieldmark* pFieldBM = pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMDATE, - aFieldPam.Start()); + pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMTEXT, + aFieldPam.Start()); + } + } - // Use a default date format and language - sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldBM->GetParameters(); - SvNumberFormatter* pFormatter = rSh.GetDoc()->GetNumberFormatter(); - sal_uInt32 nStandardFormat = pFormatter->GetStandardFormat(SvNumFormatType::DATE); - const SvNumberformat* pFormat = pFormatter->GetEntry(nStandardFormat); + rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); + } + break; + case FN_INSERT_CHECKBOX_FORMFIELD: + { + rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); - (*pParameters)[ODF_FORMDATE_DATEFORMAT] <<= pFormat->GetFormatstring(); - (*pParameters)[ODF_FORMDATE_DATEFORMAT_LANGUAGE] <<= LanguageTag(pFormat->GetLanguage()).getBcp47(); - } + SwPaM* pCursorPos = rSh.GetCursor(); + if(pCursorPos) + { + IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); + pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMCHECKBOX); } rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); } break; - default: - OSL_FAIL("wrong dispatcher"); - return; + case FN_INSERT_DROPDOWN_FORMFIELD: + { + rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + + SwPaM* pCursorPos = rSh.GetCursor(); + if(pCursorPos) + { + IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); + pMarksAccess->makeNoTextFieldBookmark(*pCursorPos, OUString(), ODF_FORMDROPDOWN); + } + + rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); } + break; + case FN_INSERT_DATE_FORMFIELD: + { + rSh.GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + + SwPaM* pCursorPos = rSh.GetCursor(); + if(pCursorPos) + { + // Insert five enspaces into the text field so the field has extent + sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; + bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH)); + if(bSuccess) + { + IDocumentMarkAccess* pMarksAccess = rSh.GetDoc()->getIDocumentMarkAccess(); + SwPaM aFieldPam(pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex() - ODF_FORMFIELD_DEFAULT_LENGTH, + pCursorPos->GetPoint()->nNode, pCursorPos->GetPoint()->nContent.GetIndex()); + sw::mark::IFieldmark* pFieldBM = pMarksAccess->makeFieldBookmark(aFieldPam, OUString(), ODF_FORMDATE, + aFieldPam.Start()); + + // Use a default date format and language + sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldBM->GetParameters(); + SvNumberFormatter* pFormatter = rSh.GetDoc()->GetNumberFormatter(); + sal_uInt32 nStandardFormat = pFormatter->GetStandardFormat(SvNumFormatType::DATE); + const SvNumberformat* pFormat = pFormatter->GetEntry(nStandardFormat); + + (*pParameters)[ODF_FORMDATE_DATEFORMAT] <<= pFormat->GetFormatstring(); + (*pParameters)[ODF_FORMDATE_DATEFORMAT_LANGUAGE] <<= LanguageTag(pFormat->GetLanguage()).getBcp47(); + } + } + + rSh.GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT_FORM_FIELD, nullptr); + rSh.GetView().GetViewFrame()->GetBindings().Invalidate( SID_UNDO ); + } + break; + default: + OSL_FAIL("wrong dispatcher"); + return; } } @@ -954,53 +954,53 @@ void SwTextShell::InsertHyperlink(const SvxHyperlinkItem& rHlnkItem) SwWrtShell& rSh = GetShell(); - if( rSh.GetSelectionType() & SelectionType::Text ) - { - rSh.StartAction(); - SfxItemSet aSet(GetPool(), svl::Items<RES_TXTATR_INETFMT, RES_TXTATR_INETFMT>{}); - rSh.GetCurAttr( aSet ); + if( !(rSh.GetSelectionType() & SelectionType::Text) ) + return; - const SfxPoolItem* pItem; - if(SfxItemState::SET == aSet.GetItemState(RES_TXTATR_INETFMT, false, &pItem)) - { - // Select links - rSh.SwCursorShell::SelectTextAttr(RES_TXTATR_INETFMT, false); - } - switch (nType) + rSh.StartAction(); + SfxItemSet aSet(GetPool(), svl::Items<RES_TXTATR_INETFMT, RES_TXTATR_INETFMT>{}); + rSh.GetCurAttr( aSet ); + + const SfxPoolItem* pItem; + if(SfxItemState::SET == aSet.GetItemState(RES_TXTATR_INETFMT, false, &pItem)) + { + // Select links + rSh.SwCursorShell::SelectTextAttr(RES_TXTATR_INETFMT, false); + } + switch (nType) + { + case HLINK_DEFAULT: + case HLINK_FIELD: { - case HLINK_DEFAULT: - case HLINK_FIELD: + SwFormatINetFormat aINetFormat( rURL, rTarget ); + aINetFormat.SetName(rHlnkItem.GetIntName()); + if(pMacroTable) { - SwFormatINetFormat aINetFormat( rURL, rTarget ); - aINetFormat.SetName(rHlnkItem.GetIntName()); - if(pMacroTable) - { - const SvxMacro *pMacro = pMacroTable->Get( SvMacroItemId::OnMouseOver ); - if( pMacro ) - aINetFormat.SetMacro(SvMacroItemId::OnMouseOver, *pMacro); - pMacro = pMacroTable->Get( SvMacroItemId::OnClick ); - if( pMacro ) - aINetFormat.SetMacro(SvMacroItemId::OnClick, *pMacro); - pMacro = pMacroTable->Get( SvMacroItemId::OnMouseOut ); - if( pMacro ) - aINetFormat.SetMacro(SvMacroItemId::OnMouseOut, *pMacro); - } - rSh.SttSelect(); - rSh.InsertURL( aINetFormat, rName, true ); - rSh.EndSelect(); + const SvxMacro *pMacro = pMacroTable->Get( SvMacroItemId::OnMouseOver ); + if( pMacro ) + aINetFormat.SetMacro(SvMacroItemId::OnMouseOver, *pMacro); + pMacro = pMacroTable->Get( SvMacroItemId::OnClick ); + if( pMacro ) + aINetFormat.SetMacro(SvMacroItemId::OnClick, *pMacro); + pMacro = pMacroTable->Get( SvMacroItemId::OnMouseOut ); + if( pMacro ) + aINetFormat.SetMacro(SvMacroItemId::OnMouseOut, *pMacro); } - break; - - case HLINK_BUTTON: - bool bSel = rSh.HasSelection(); - if(bSel) - rSh.DelRight(); - InsertURLButton( rURL, rTarget, rName ); - rSh.EnterStdMode(); - break; + rSh.SttSelect(); + rSh.InsertURL( aINetFormat, rName, true ); + rSh.EndSelect(); } - rSh.EndAction(); + break; + + case HLINK_BUTTON: + bool bSel = rSh.HasSelection(); + if(bSel) + rSh.DelRight(); + InsertURLButton( rURL, rTarget, rName ); + rSh.EnterStdMode(); + break; } + rSh.EndAction(); } IMPL_LINK( SwTextShell, RedlineNextHdl, AbstractSvxPostItDialog&, rDlg, void ) diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index 85831dc92488..daa913816a63 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -946,103 +946,103 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) return; } - if( !aChars.isEmpty() ) - { - rSh.StartAllAction(); + if( aChars.isEmpty() ) + return; + + rSh.StartAllAction(); + + // Delete selected content. + SwRewriter aRewriter; + aRewriter.AddRule(UndoArg1, SwResId(STR_SPECIALCHAR)); - // Delete selected content. - SwRewriter aRewriter; - aRewriter.AddRule(UndoArg1, SwResId(STR_SPECIALCHAR)); + rSh.StartUndo( SwUndoId::INSERT, &aRewriter ); + if ( rSh.HasSelection() ) + { + rSh.DelRight(); + aSet.ClearItem(); + rSh.GetCurAttr( aSet ); - rSh.StartUndo( SwUndoId::INSERT, &aRewriter ); - if ( rSh.HasSelection() ) + SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); + aSetItem.GetItemSet().Put( aSet, false ); + const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); + if( pI ) { - rSh.DelRight(); - aSet.ClearItem(); - rSh.GetCurAttr( aSet ); - - SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, *aSet.GetPool() ); - aSetItem.GetItemSet().Put( aSet, false ); - const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript ); - if( pI ) - { - aFont.reset(static_cast<SvxFontItem*>(pI->Clone())); - } - else - { - aFont.reset(static_cast<SvxFontItem*>(aSet.Get( GetWhichOfScript( - RES_CHRATR_FONT, - SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone())); - } + aFont.reset(static_cast<SvxFontItem*>(pI->Clone())); } + else + { + aFont.reset(static_cast<SvxFontItem*>(aSet.Get( GetWhichOfScript( + RES_CHRATR_FONT, + SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone())); + } + } - // Insert character. - rSh.Insert( aChars ); + // Insert character. + rSh.Insert( aChars ); - // #108876# a font attribute has to be set always due to a guessed script type - if( !aNewFont.GetFamilyName().isEmpty() ) + // #108876# a font attribute has to be set always due to a guessed script type + if( !aNewFont.GetFamilyName().isEmpty() ) + { + std::unique_ptr<SvxFontItem> aNewFontItem(aFont->Clone()); + aNewFontItem->SetFamilyName( aNewFont.GetFamilyName() ); + aNewFontItem->SetFamily( aNewFont.GetFamilyType()); + aNewFontItem->SetPitch( aNewFont.GetPitch()); + aNewFontItem->SetCharSet( aNewFont.GetCharSet() ); + + SfxItemSet aRestoreSet( GetPool(), svl::Items<RES_CHRATR_FONT, RES_CHRATR_FONT, + RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT, + RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT>{} ); + + nScript = g_pBreakIt->GetAllScriptsOfText( aChars ); + if( SvtScriptType::LATIN & nScript ) { - std::unique_ptr<SvxFontItem> aNewFontItem(aFont->Clone()); - aNewFontItem->SetFamilyName( aNewFont.GetFamilyName() ); - aNewFontItem->SetFamily( aNewFont.GetFamilyType()); - aNewFontItem->SetPitch( aNewFont.GetPitch()); - aNewFontItem->SetCharSet( aNewFont.GetCharSet() ); - - SfxItemSet aRestoreSet( GetPool(), svl::Items<RES_CHRATR_FONT, RES_CHRATR_FONT, - RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT, - RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT>{} ); - - nScript = g_pBreakIt->GetAllScriptsOfText( aChars ); - if( SvtScriptType::LATIN & nScript ) - { - aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT ) ); - aNewFontItem->SetWhich(RES_CHRATR_FONT); - aSet.Put( *aNewFontItem ); - } - if( SvtScriptType::ASIAN & nScript ) - { - aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT ) ); - aNewFontItem->SetWhich(RES_CHRATR_CJK_FONT); - aSet.Put( *aNewFontItem ); - } - if( SvtScriptType::COMPLEX & nScript ) - { - aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT ) ); - aNewFontItem->SetWhich(RES_CHRATR_CTL_FONT); - aSet.Put( *aNewFontItem ); - } + aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT ) ); + aNewFontItem->SetWhich(RES_CHRATR_FONT); + aSet.Put( *aNewFontItem ); + } + if( SvtScriptType::ASIAN & nScript ) + { + aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT ) ); + aNewFontItem->SetWhich(RES_CHRATR_CJK_FONT); + aSet.Put( *aNewFontItem ); + } + if( SvtScriptType::COMPLEX & nScript ) + { + aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT ) ); + aNewFontItem->SetWhich(RES_CHRATR_CTL_FONT); + aSet.Put( *aNewFontItem ); + } - rSh.SetMark(); - rSh.ExtendSelection( false, aChars.getLength() ); - rSh.SetAttrSet( aSet, SetAttrMode::DONTEXPAND | SetAttrMode::NOFORMATATTR ); - if( !rSh.IsCursorPtAtEnd() ) - rSh.SwapPam(); + rSh.SetMark(); + rSh.ExtendSelection( false, aChars.getLength() ); + rSh.SetAttrSet( aSet, SetAttrMode::DONTEXPAND | SetAttrMode::NOFORMATATTR ); + if( !rSh.IsCursorPtAtEnd() ) + rSh.SwapPam(); - rSh.ClearMark(); + rSh.ClearMark(); - // #i75891# - // SETATTR_DONTEXPAND does not work if there are already hard attributes. - // Therefore we have to restore the font attributes. - rSh.SetMark(); - rSh.SetAttrSet( aRestoreSet ); - rSh.ClearMark(); + // #i75891# + // SETATTR_DONTEXPAND does not work if there are already hard attributes. + // Therefore we have to restore the font attributes. + rSh.SetMark(); + rSh.SetAttrSet( aRestoreSet ); + rSh.ClearMark(); - rSh.UpdateAttr(); + rSh.UpdateAttr(); - // Why was this done? aFont is not used anymore below, we are not - // in a loop and it's a local variable...? - // aFont = aNewFontItem; - } + // Why was this done? aFont is not used anymore below, we are not + // in a loop and it's a local variable...? + // aFont = aNewFontItem; + } - rSh.EndAllAction(); - rSh.EndUndo(); + rSh.EndAllAction(); + rSh.EndUndo(); - if ( !aChars.isEmpty() ) - { - rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) ); - rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetFamilyName() ) ); - rReq.Done(); - } + if ( !aChars.isEmpty() ) + { + rReq.AppendItem( SfxStringItem( GetPool().GetWhich(SID_CHARMAP), aChars ) ); + rReq.AppendItem( SfxStringItem( SID_ATTR_SPECIALCHAR, aNewFont.GetFamilyName() ) ); + rReq.Done(); } } |