cui/source/options/dbregister.cxx | 26 extensions/source/bibliography/general.cxx | 23 framework/source/uielement/toolbarmanager.cxx | 60 - i18npool/source/calendar/calendar_gregorian.cxx | 23 oox/source/export/drawingml.cxx | 36 oox/source/vml/vmlshapecontext.cxx | 74 - salhelper/source/timer.cxx | 36 sc/source/core/data/column2.cxx | 28 sc/source/filter/oox/autofilterbuffer.cxx | 42 sc/source/ui/app/inputhdl.cxx | 50 sc/source/ui/app/inputwin.cxx | 32 sc/source/ui/dbgui/filtdlg.cxx | 26 sc/source/ui/view/gridwin.cxx | 30 sc/source/ui/view/gridwin4.cxx | 74 - sc/source/ui/view/output2.cxx | 52 sc/source/ui/view/viewdata.cxx | 30 sd/source/filter/eppt/pptx-epptooxml.cxx | 182 +-- sd/source/ui/unoidl/UnoDocumentSettings.cxx | 5 sfx2/source/appl/workwin.cxx | 36 sfx2/source/commandpopup/CommandPopup.cxx | 46 sfx2/source/dialog/StyleList.cxx | 130 +- sfx2/source/doc/templatedlg.cxx | 68 - sfx2/source/view/ipclient.cxx | 24 sfx2/source/view/viewfrm.cxx | 27 starmath/source/mathml/import.cxx | 30 svx/source/sdr/properties/defaultproperties.cxx | 48 svx/source/unodraw/SvxXTextColumns.cxx | 38 sw/source/core/crsr/swcrsr.cxx | 62 - sw/source/core/doc/DocumentContentOperationsManager.cxx | 74 - sw/source/core/doc/DocumentRedlineManager.cxx | 48 sw/source/core/doc/docnum.cxx | 52 sw/source/core/doc/textboxhelper.cxx | 20 sw/source/core/layout/atrfrm.cxx | 30 sw/source/core/text/porlay.cxx | 98 - sw/source/core/text/porrst.cxx | 42 sw/source/core/txtnode/atrfld.cxx | 46 sw/source/core/unocore/unoframe.cxx | 5 sw/source/filter/html/htmlflywriter.cxx | 52 sw/source/filter/indexing/IndexingExport.cxx | 34 sw/source/filter/ww8/ww8par3.cxx | 38 sw/source/uibase/dbui/mmconfigitem.cxx | 24 sw/source/uibase/docvw/SidebarTxtControl.cxx | 34 sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx | 47 sw/source/uibase/utlui/content.cxx | 136 +- sw/source/uibase/utlui/gotodlg.cxx | 22 unoidl/source/unoidl-read.cxx | 858 ++++++++-------- unotools/source/config/historyoptions.cxx | 26 unotools/source/config/moduleoptions.cxx | 20 unotools/source/ucbhelper/tempfile.cxx | 26 vcl/jsdialog/jsdialogbuilder.cxx | 64 - vcl/skia/gdiimpl.cxx | 62 - vcl/source/app/scheduler.cxx | 164 +-- vcl/source/bitmap/impvect.cxx | 116 +- vcl/source/control/wizardmachine.cxx | 38 vcl/source/filter/ipdf/pdfdocument.cxx | 28 vcl/source/outdev/background.cxx | 48 vcl/source/outdev/bitmap.cxx | 30 vcl/source/treelist/svimpbox.cxx | 68 - vcl/source/window/bubblewindow.cxx | 26 vcl/source/window/layout.cxx | 34 vcl/source/window/toolbox2.cxx | 70 - vcl/source/window/window2.cxx | 38 vcl/unx/gtk3/gtkframe.cxx | 140 +- vcl/unx/gtk3/gtkinst.cxx | 94 - vcl/unx/gtk3/gtkobject.cxx | 56 - vcl/unx/gtk3/gtksalmenu.cxx | 62 - vcl/unx/gtk3/salnativewidgets-gtk.cxx | 38 writerfilter/source/dmapper/GraphicImport.cxx | 28 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 29 xmloff/source/core/xmlexp.cxx | 48 xmloff/source/style/PageMasterImportPropMapper.cxx | 94 - xmloff/source/style/XMLPageExport.cxx | 34 xmloff/source/style/xmlnumfi.cxx | 104 - xmloff/source/text/XMLIndexTOCContext.cxx | 34 xmloff/source/text/txtimp.cxx | 228 ++-- xmlsecurity/source/helper/ooxmlsecparser.cxx | 40 xmlsecurity/source/helper/xsecparser.cxx | 41 77 files changed, 2465 insertions(+), 2461 deletions(-)
New commits: commit 29489b33b435683021b72cb2bce27aba8cb7a430 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Oct 21 12:31:03 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Oct 21 14:58:51 2021 +0200 loplugin:flatten Change-Id: I3b4226a9d089ec9aedab95d96e50a068f57a76c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123991 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx index 889691422346..ba61527cdeca 100644 --- a/cui/source/options/dbregister.cxx +++ b/cui/source/options/dbregister.cxx @@ -168,20 +168,20 @@ void DbRegistrationOptionsPage::Reset( const SfxItemSet* rSet ) } OUString aUserData = GetUserData(); - if ( !aUserData.isEmpty() ) + if ( aUserData.isEmpty() ) + return; + + sal_Int32 nIdx {0}; + // restore column width + std::vector<int> aWidths { - sal_Int32 nIdx {0}; - // restore column width - std::vector<int> aWidths - { - aUserData.getToken(0, ';', nIdx).toInt32() - }; - m_xPathBox->set_column_fixed_widths(aWidths); - // restore sort direction - bool bUp = aUserData.getToken(0, ';', nIdx).toInt32() != 0; - m_xPathBox->set_sort_order(bUp); - m_xPathBox->set_sort_indicator(bUp ? TRISTATE_TRUE : TRISTATE_FALSE, COL_TYPE); - } + aUserData.getToken(0, ';', nIdx).toInt32() + }; + m_xPathBox->set_column_fixed_widths(aWidths); + // restore sort direction + bool bUp = aUserData.getToken(0, ';', nIdx).toInt32() != 0; + m_xPathBox->set_sort_order(bUp); + m_xPathBox->set_sort_indicator(bUp ? TRISTATE_TRUE : TRISTATE_FALSE, COL_TYPE); } void DbRegistrationOptionsPage::FillUserData() diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx index daa32e562343..ad3a8c957b66 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -431,20 +431,19 @@ void BibGeneralPage::SaveChanges() Any aModified = xProps->getPropertyValue( "IsModified" ); bool bFlag = false; - if ( ( aModified >>= bFlag ) && bFlag ) - { + if ( !( aModified >>= bFlag ) || !bFlag ) + return; - try - { - Any aNew = xProps->getPropertyValue( "IsNew" ); - aNew >>= bFlag; - if ( bFlag ) - xResUpd->insertRow(); - else - xResUpd->updateRow(); - } - catch( const uno::Exception&) {} + try + { + Any aNew = xProps->getPropertyValue( "IsNew" ); + aNew >>= bFlag; + if ( bFlag ) + xResUpd->insertRow(); + else + xResUpd->updateRow(); } + catch( const uno::Exception&) {} } IMPL_LINK(BibGeneralPage, LastElementKeyInputHdl, const KeyEvent&, rKeyEvent, bool) diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 857d797bd542..ddec6fb528d7 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -1758,26 +1758,26 @@ void ToolBarManager::HandleClick(ClickAction eClickAction) ToolBoxItemId nId( m_pImpl->GetCurItemId() ); ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId ); - if ( pIter != m_aControllerMap.end() ) - { - Reference< XToolbarController > xController( pIter->second, UNO_QUERY ); + if ( pIter == m_aControllerMap.end() ) + return; - if ( xController.is() ) + Reference< XToolbarController > xController( pIter->second, UNO_QUERY ); + + if ( xController.is() ) + { + switch (eClickAction) { - switch (eClickAction) - { - case ClickAction::Click: - xController->click(); - break; + case ClickAction::Click: + xController->click(); + break; - case ClickAction::DblClick: - xController->doubleClick(); - break; + case ClickAction::DblClick: + xController->doubleClick(); + break; - case ClickAction::Execute: - xController->execute(0); - break; - } + case ClickAction::Execute: + xController->execute(0); + break; } } } @@ -1804,22 +1804,22 @@ void ToolBarManager::OnDropdownClick(bool bCreatePopupWindow) ToolBoxItemId nId( m_pImpl->GetCurItemId() ); ToolBarControllerMap::const_iterator pIter = m_aControllerMap.find( nId ); - if ( pIter != m_aControllerMap.end() ) - { - Reference< XToolbarController > xController( pIter->second, UNO_QUERY ); + if ( pIter == m_aControllerMap.end() ) + return; - if ( xController.is() ) + Reference< XToolbarController > xController( pIter->second, UNO_QUERY ); + + if ( xController.is() ) + { + if (bCreatePopupWindow) { - if (bCreatePopupWindow) - { - Reference< XWindow > xWin = xController->createPopupWindow(); - if ( xWin.is() ) - xWin->setFocus(); - } - else - { - xController->click(); - } + Reference< XWindow > xWin = xController->createPopupWindow(); + if ( xWin.is() ) + xWin->setFocus(); + } + else + { + xController->click(); } } } diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx index df998b3c6cf3..53fe9b1c70bd 100644 --- a/i18npool/source/calendar/calendar_gregorian.cxx +++ b/i18npool/source/calendar/calendar_gregorian.cxx @@ -452,18 +452,19 @@ void Calendar_gregorian::mapFromGregorian() // By using eraArray, it can take care Japanese and Taiwan ROC calendar. void Calendar_gregorian::mapToGregorian() { - if (eraArray && (fieldSet & FIELDS)) { - sal_Int16 e = fieldValue[CalendarFieldIndex::ERA]; - sal_Int32 y; - if (e == 0) - y = eraArray[0].year - cast16To32(fieldValue[CalendarFieldIndex::YEAR]); - else - y = eraArray[e-1].year + cast16To32(fieldValue[CalendarFieldIndex::YEAR] - 1); + if (!eraArray || !(fieldSet & FIELDS)) + return; - fieldSetValue[CalendarFieldIndex::ERA] = y <= 0 ? 0 : 1; - fieldSetValue[CalendarFieldIndex::YEAR] = cast32To16(y <= 0 ? 1 - y : y); - fieldSet |= FIELDS; - } + sal_Int16 e = fieldValue[CalendarFieldIndex::ERA]; + sal_Int32 y; + if (e == 0) + y = eraArray[0].year - cast16To32(fieldValue[CalendarFieldIndex::YEAR]); + else + y = eraArray[e-1].year + cast16To32(fieldValue[CalendarFieldIndex::YEAR] - 1); + + fieldSetValue[CalendarFieldIndex::ERA] = y <= 0 ? 0 : 1; + fieldSetValue[CalendarFieldIndex::YEAR] = cast32To16(y <= 0 ? 1 - y : y); + fieldSet |= FIELDS; } /// @throws RuntimeException diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 6b05b15546cc..d9dd073fbaf7 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2965,27 +2965,27 @@ void DrawingML::WriteLstStyles(const css::uno::Reference<css::text::XTextContent Reference<XTextRange> rRun; - if (xEnumeration->hasMoreElements()) + if (!xEnumeration->hasMoreElements()) + return; + + Any aAny(xEnumeration->nextElement()); + if (aAny >>= rRun) { - Any aAny(xEnumeration->nextElement()); - if (aAny >>= rRun) - { - float fFirstCharHeight = rnCharHeight / 1000.; - Reference<XPropertySet> xFirstRunPropSet(rRun, UNO_QUERY); - Reference<XPropertySetInfo> xFirstRunPropSetInfo - = xFirstRunPropSet->getPropertySetInfo(); + float fFirstCharHeight = rnCharHeight / 1000.; + Reference<XPropertySet> xFirstRunPropSet(rRun, UNO_QUERY); + Reference<XPropertySetInfo> xFirstRunPropSetInfo + = xFirstRunPropSet->getPropertySetInfo(); - if (xFirstRunPropSetInfo->hasPropertyByName("CharHeight")) - fFirstCharHeight = xFirstRunPropSet->getPropertyValue("CharHeight").get<float>(); + if (xFirstRunPropSetInfo->hasPropertyByName("CharHeight")) + fFirstCharHeight = xFirstRunPropSet->getPropertyValue("CharHeight").get<float>(); - mpFS->startElementNS(XML_a, XML_lstStyle); - if( !WriteParagraphProperties(rParagraph, fFirstCharHeight, XML_lvl1pPr) ) - mpFS->startElementNS(XML_a, XML_lvl1pPr); - WriteRunProperties(xFirstRunPropSet, false, XML_defRPr, true, rbOverridingCharHeight, - rnCharHeight, GetScriptType(rRun->getString()), rXShapePropSet); - mpFS->endElementNS(XML_a, XML_lvl1pPr); - mpFS->endElementNS(XML_a, XML_lstStyle); - } + mpFS->startElementNS(XML_a, XML_lstStyle); + if( !WriteParagraphProperties(rParagraph, fFirstCharHeight, XML_lvl1pPr) ) + mpFS->startElementNS(XML_a, XML_lvl1pPr); + WriteRunProperties(xFirstRunPropSet, false, XML_defRPr, true, rbOverridingCharHeight, + rnCharHeight, GetScriptType(rRun->getString()), rXShapePropSet); + mpFS->endElementNS(XML_a, XML_lvl1pPr); + mpFS->endElementNS(XML_a, XML_lstStyle); } } diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index d6051356ff14..e9284747774b 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -579,46 +579,46 @@ void ShapeContext::setPoints(const OUString& rPoints) } // VML polyline has no size in its style attribute. Word writes the size to attribute // coordsize with values in twip but without unit. For others we get size from points. - if (mrShape.getTypeModel().maWidth.isEmpty() && mrShape.getTypeModel().maHeight.isEmpty()) + if (!mrShape.getTypeModel().maWidth.isEmpty() || !mrShape.getTypeModel().maHeight.isEmpty()) + return; + + if (mrShape.getTypeModel().moCoordSize.has()) { - if (mrShape.getTypeModel().moCoordSize.has()) - { - double fWidth = mrShape.getTypeModel().moCoordSize.get().first; - fWidth = o3tl::convert(fWidth, o3tl::Length::twip, o3tl::Length::pt); - double fHeight = mrShape.getTypeModel().moCoordSize.get().second; - fHeight = o3tl::convert(fHeight, o3tl::Length::twip, o3tl::Length::pt); - mrShape.getTypeModel().maWidth = OUString::number(fWidth) + "pt"; - mrShape.getTypeModel().maHeight = OUString::number(fHeight) + "pt"; - } - else if (mrShapeModel.maPoints.size()) + double fWidth = mrShape.getTypeModel().moCoordSize.get().first; + fWidth = o3tl::convert(fWidth, o3tl::Length::twip, o3tl::Length::pt); + double fHeight = mrShape.getTypeModel().moCoordSize.get().second; + fHeight = o3tl::convert(fHeight, o3tl::Length::twip, o3tl::Length::pt); + mrShape.getTypeModel().maWidth = OUString::number(fWidth) + "pt"; + mrShape.getTypeModel().maHeight = OUString::number(fHeight) + "pt"; + } + else if (mrShapeModel.maPoints.size()) + { + double fMinX = mrShapeModel.maPoints[0].X; + double fMaxX = mrShapeModel.maPoints[0].X; + double fMinY = mrShapeModel.maPoints[0].Y; + double fMaxY = mrShapeModel.maPoints[0].Y; + for (const auto& rPoint : mrShapeModel.maPoints) { - double fMinX = mrShapeModel.maPoints[0].X; - double fMaxX = mrShapeModel.maPoints[0].X; - double fMinY = mrShapeModel.maPoints[0].Y; - double fMaxY = mrShapeModel.maPoints[0].Y; - for (const auto& rPoint : mrShapeModel.maPoints) - { - if (rPoint.X < fMinX) - fMinX = rPoint.X; - else if (rPoint.X > fMaxX) - fMaxX = rPoint.X; - if (rPoint.Y < fMinY) - fMinY = rPoint.Y; - else if (rPoint.Y > fMaxY) - fMaxY = rPoint.Y; - } - mrShape.getTypeModel().maWidth - = OUString::number( - o3tl::convert(fMaxX - fMinX, o3tl::Length::twip, o3tl::Length::pt)) - + "pt"; - mrShape.getTypeModel().maHeight - = OUString::number( - o3tl::convert(fMaxY - fMinY, o3tl::Length::twip, o3tl::Length::pt)) - + "pt"; - // Set moCoordSize, otherwise default (1000,1000) is used. - mrShape.getTypeModel().moCoordSize.set( - Int32Pair(basegfx::fround(fMaxX - fMinX), basegfx::fround(fMaxY - fMinY))); + if (rPoint.X < fMinX) + fMinX = rPoint.X; + else if (rPoint.X > fMaxX) + fMaxX = rPoint.X; + if (rPoint.Y < fMinY) + fMinY = rPoint.Y; + else if (rPoint.Y > fMaxY) + fMaxY = rPoint.Y; } + mrShape.getTypeModel().maWidth + = OUString::number( + o3tl::convert(fMaxX - fMinX, o3tl::Length::twip, o3tl::Length::pt)) + + "pt"; + mrShape.getTypeModel().maHeight + = OUString::number( + o3tl::convert(fMaxY - fMinY, o3tl::Length::twip, o3tl::Length::pt)) + + "pt"; + // Set moCoordSize, otherwise default (1000,1000) is used. + mrShape.getTypeModel().moCoordSize.set( + Int32Pair(basegfx::fround(fMaxX - fMinX), basegfx::fround(fMaxY - fMinY))); } } diff --git a/salhelper/source/timer.cxx b/salhelper/source/timer.cxx index 999eaa80abbd..430cdfe9138c 100644 --- a/salhelper/source/timer.cxx +++ b/salhelper/source/timer.cxx @@ -299,33 +299,33 @@ void TimerManager::checkForTimeout() Timer* pTimer = m_pHead; - if (pTimer->isExpired()) - { - // remove expired timer - m_pHead = pTimer->m_pNext; + if (!pTimer->isExpired()) + return; - pTimer->acquire(); + // remove expired timer + m_pHead = pTimer->m_pNext; - aLock.unlock(); + pTimer->acquire(); - pTimer->onShot(); + aLock.unlock(); - // restart timer if specified - if (!pTimer->m_aRepeatDelta.isEmpty()) - { - TTimeValue Now; + pTimer->onShot(); - osl_getSystemTime(&Now); + // restart timer if specified + if (!pTimer->m_aRepeatDelta.isEmpty()) + { + TTimeValue Now; - Now.Seconds += pTimer->m_aRepeatDelta.Seconds; - Now.Nanosec += pTimer->m_aRepeatDelta.Nanosec; + osl_getSystemTime(&Now); - pTimer->m_aExpired = Now; + Now.Seconds += pTimer->m_aRepeatDelta.Seconds; + Now.Nanosec += pTimer->m_aRepeatDelta.Nanosec; - registerTimer(pTimer); - } - pTimer->release(); + pTimer->m_aExpired = Now; + + registerTimer(pTimer); } + pTimer->release(); } void TimerManager::run() diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 86460ac576cc..b86da08c6a38 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -661,21 +661,21 @@ class MaxStrLenFinder ScCellFormat::GetString( rCell, mnFormat, aValStr, &pColor, *mrDoc.GetFormatTable(), mrDoc); - if (aValStr.getLength() > mnMaxLen) + if (aValStr.getLength() <= mnMaxLen) + return; + + switch (rCell.meType) { - switch (rCell.meType) - { - case CELLTYPE_NONE: - case CELLTYPE_VALUE: - mnMaxLen = aValStr.getLength(); - maMaxLenStr = aValStr; - break; - case CELLTYPE_EDIT: - case CELLTYPE_STRING: - case CELLTYPE_FORMULA: - default: - checkLineBreak(aValStr); - } + case CELLTYPE_NONE: + case CELLTYPE_VALUE: + mnMaxLen = aValStr.getLength(); + maMaxLenStr = aValStr; + break; + case CELLTYPE_EDIT: + case CELLTYPE_STRING: + case CELLTYPE_FORMULA: + default: + checkLineBreak(aValStr); } } diff --git a/sc/source/filter/oox/autofilterbuffer.cxx b/sc/source/filter/oox/autofilterbuffer.cxx index 951347b62fcd..211511e52367 100644 --- a/sc/source/filter/oox/autofilterbuffer.cxx +++ b/sc/source/filter/oox/autofilterbuffer.cxx @@ -820,30 +820,30 @@ void AutoFilter::finalizeImport( const Reference< XDatabaseRange >& rxDatabaseRa } // set sort parameter if we have detected it - if (aParam.bUserDef) - { - SCCOLROW nStartPos = aParam.bByRow ? maRange.aStart.Col() : maRange.aStart.Row(); - if (rSorConditionLoaded.mbDescending) - { - // descending sort - need to enable 1st SortParam slot - assert(aParam.GetSortKeyCount() == DEFSORT); - - aParam.maKeyState[0].bDoSort = true; - aParam.maKeyState[0].bAscending = false; - aParam.maKeyState[0].nField += nStartPos; - } + if (!aParam.bUserDef) + return; - ScDocument& rDoc = getScDocument(); - ScDBData* pDBData = rDoc.GetDBAtArea( - nSheet, - maRange.aStart.Col(), maRange.aStart.Row(), - maRange.aEnd.Col(), maRange.aEnd.Row()); + SCCOLROW nStartPos = aParam.bByRow ? maRange.aStart.Col() : maRange.aStart.Row(); + if (rSorConditionLoaded.mbDescending) + { + // descending sort - need to enable 1st SortParam slot + assert(aParam.GetSortKeyCount() == DEFSORT); - if (pDBData) - pDBData->SetSortParam(aParam); - else - OSL_FAIL("AutoFilter::finalizeImport(): cannot find matching DBData"); + aParam.maKeyState[0].bDoSort = true; + aParam.maKeyState[0].bAscending = false; + aParam.maKeyState[0].nField += nStartPos; } + + ScDocument& rDoc = getScDocument(); + ScDBData* pDBData = rDoc.GetDBAtArea( + nSheet, + maRange.aStart.Col(), maRange.aStart.Row(), + maRange.aEnd.Col(), maRange.aEnd.Row()); + + if (pDBData) + pDBData->SetSortParam(aParam); + else + OSL_FAIL("AutoFilter::finalizeImport(): cannot find matching DBData"); } AutoFilterBuffer::AutoFilterBuffer( const WorkbookHelper& rHelper ) : diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 97c86b34b00d..01f2b9e9d1d6 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1735,36 +1735,36 @@ void ScInputHandler::LOKPasteFunctionData(const OUString& rFunctionName) EditView* pEditView = pTopView ? pTopView : pTableView; - if (pActiveViewSh && pEditView) + if (!pActiveViewSh || !pEditView) + return; + + bool bEdit = false; + OUString aFormula; + const EditEngine* pEditEngine = pEditView->GetEditEngine(); + if (pEditEngine) { - bool bEdit = false; - OUString aFormula; - const EditEngine* pEditEngine = pEditView->GetEditEngine(); - if (pEditEngine) - { - aFormula = pEditEngine->GetText(0); - bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] == '+' || aFormula[0] == '-'); - } + aFormula = pEditEngine->GetText(0); + bEdit = aFormula.getLength() > 1 && (aFormula[0] == '=' || aFormula[0] == '+' || aFormula[0] == '-'); + } - if ( !bEdit ) - { - OUString aNewFormula('='); - if ( aFormula.startsWith("=") ) - aNewFormula = aFormula; + if ( !bEdit ) + { + OUString aNewFormula('='); + if ( aFormula.startsWith("=") ) + aNewFormula = aFormula; - InputReplaceSelection( aNewFormula ); - } + InputReplaceSelection( aNewFormula ); + } - if (pFormulaData) - { - OUString aNew; - ScTypedCaseStrSet::const_iterator aPos = findText(*pFormulaData, pFormulaData->begin(), rFunctionName, aNew, /* backward = */false); + if (pFormulaData) + { + OUString aNew; + ScTypedCaseStrSet::const_iterator aPos = findText(*pFormulaData, pFormulaData->begin(), rFunctionName, aNew, /* backward = */false); - if (aPos != pFormulaData->end()) - { - miAutoPosFormula = aPos; - PasteFunctionData(); - } + if (aPos != pFormulaData->end()) + { + miAutoPosFormula = aPos; + PasteFunctionData(); } } } diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 1747639c611a..32412c39b1be 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1314,25 +1314,25 @@ void ScTextWnd::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangl else WeldEditView::Paint(rRenderContext, rRect); - if (comphelper::LibreOfficeKit::isActive()) + if (!comphelper::LibreOfficeKit::isActive()) + return; + + bool bIsFocused = false; + if (HasFocus()) { - bool bIsFocused = false; - if (HasFocus()) - { - vcl::Cursor* pCursor = m_xEditView->GetCursor(); - if (pCursor) - bIsFocused = true; - } + vcl::Cursor* pCursor = m_xEditView->GetCursor(); + if (pCursor) + bIsFocused = true; + } - VclPtr<vcl::Window> pParent = mrGroupBar.GetVclParent().GetParentWithLOKNotifier(); - if (!pParent) - return; + VclPtr<vcl::Window> pParent = mrGroupBar.GetVclParent().GetParentWithLOKNotifier(); + if (!pParent) + return; - const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier(); - std::vector<vcl::LOKPayloadItem> aItems; - aItems.emplace_back("visible", bIsFocused ? "true" : "false"); - pNotifier->notifyWindow(pParent->GetLOKWindowId(), "cursor_visible", aItems); - } + const vcl::ILibreOfficeKitNotifier* pNotifier = pParent->GetLOKNotifier(); + std::vector<vcl::LOKPayloadItem> aItems; + aItems.emplace_back("visible", bIsFocused ? "true" : "false"); + pNotifier->notifyWindow(pParent->GetLOKWindowId(), "cursor_visible", aItems); } EditView* ScTextWnd::GetEditView() const diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index 06df4ae300f2..525e74c4a915 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -1224,19 +1224,19 @@ IMPL_LINK( ScFilterDlg, CheckBoxHdl, weld::Toggleable&, rBox, void ) UpdateHdrInValueList( 4 ); } - if ( &rBox == m_xBtnCase.get() ) // Complete value list - { - m_EntryLists.clear(); - UpdateValueList( 1 ); // current text is recorded - UpdateValueList( 2 ); - UpdateValueList( 3 ); - UpdateValueList( 4 ); - - UpdateColorList( 1 ); - UpdateColorList( 2 ); - UpdateColorList( 3 ); - UpdateColorList( 4 ); - } + if ( &rBox != m_xBtnCase.get() ) // Complete value list + return; + + m_EntryLists.clear(); + UpdateValueList( 1 ); // current text is recorded + UpdateValueList( 2 ); + UpdateValueList( 3 ); + UpdateValueList( 4 ); + + UpdateColorList( 1 ); + UpdateColorList( 2 ); + UpdateColorList( 3 ); + UpdateColorList( 4 ); } IMPL_LINK( ScFilterDlg, ValModifyHdl, weld::ComboBox&, rEd, void ) diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 311a59d8dbcd..9282acef724d 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3132,23 +3132,23 @@ void ScGridWindow::Command( const CommandEvent& rCEvt ) } } - if (!bDone) - { - // tdf#140361 at this context menu popup time get what the - // DisableEditHyperlink would be for this position - bool bShouldDisableEditHyperlink = mrViewData.GetViewShell()->ShouldDisableEditHyperlink(); + if (bDone) + return; - SfxDispatcher::ExecutePopup( this, &aMenuPos ); + // tdf#140361 at this context menu popup time get what the + // DisableEditHyperlink would be for this position + bool bShouldDisableEditHyperlink = mrViewData.GetViewShell()->ShouldDisableEditHyperlink(); - if (!bShouldDisableEditHyperlink) - { - SfxBindings& rBindings = mrViewData.GetBindings(); - // tdf#140361 set what the menu popup state for this was - mrViewData.GetViewShell()->EnableEditHyperlink(); - // ensure moAtContextMenu_DisableEditHyperlink will be cleared - // in the case that EditHyperlink is not dispatched by the menu - rBindings.Invalidate(SID_EDIT_HYPERLINK); - } + SfxDispatcher::ExecutePopup( this, &aMenuPos ); + + if (!bShouldDisableEditHyperlink) + { + SfxBindings& rBindings = mrViewData.GetBindings(); + // tdf#140361 set what the menu popup state for this was + mrViewData.GetViewShell()->EnableEditHyperlink(); + // ensure moAtContextMenu_DisableEditHyperlink will be cleared + // in the case that EditHyperlink is not dispatched by the menu + rBindings.Invalidate(SID_EDIT_HYPERLINK); } } diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 9ee886d1ad50..07b73255c5eb 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -2398,44 +2398,44 @@ void ScGridWindow::initiatePageBreaks() IMPL_LINK(ScGridWindow, InitiatePageBreaksTimer, Timer*, pTimer, void) { - if (pTimer == &maShowPageBreaksTimer) - { - const ScViewOptions& rOpts = mrViewData.GetOptions(); - const bool bPage = rOpts.GetOption(VOPT_PAGEBREAKS); - // tdf#124983, if option LibreOfficeDev Calc/View/Visual Aids/Page - // breaks is enabled, breaks should be visible. If the document is - // opened the first time or a tab is activated the first time, the - // breaks are not calculated yet, so this initialization is done here. - if (bPage) + if (pTimer != &maShowPageBreaksTimer) + return; + + const ScViewOptions& rOpts = mrViewData.GetOptions(); + const bool bPage = rOpts.GetOption(VOPT_PAGEBREAKS); + // tdf#124983, if option LibreOfficeDev Calc/View/Visual Aids/Page + // breaks is enabled, breaks should be visible. If the document is + // opened the first time or a tab is activated the first time, the + // breaks are not calculated yet, so this initialization is done here. + if (bPage) + { + const SCTAB nCurrentTab = mrViewData.GetTabNo(); + ScDocument& rDoc = mrViewData.GetDocument(); + const Size aPageSize = rDoc.GetPageSize(nCurrentTab); + // Do not attempt to calculate a page size here if it is empty if + // that involves counting pages. + // An earlier implementation did + // ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nCurrentTab); + // rDoc.SetPageSize(nCurrentTab, rDoc.GetPageSize(nCurrentTab)); + // which resulted in tremendous waiting times after having loaded + // larger documents i.e. imported from CSV, in which UI is entirely + // blocked. All time is spent under ScPrintFunc::CountPages() in + // ScTable::ExtendPrintArea() in the loop that calls + // MaybeAddExtraColumn() to do stuff for each text string content + // cell (each row in each column). Maybe that can be optimized, or + // obtaining page size without that overhead would be possible, but + // as is calling that from here is a no-no so this is a quick + // disable things. + if (!aPageSize.IsEmpty()) { - const SCTAB nCurrentTab = mrViewData.GetTabNo(); - ScDocument& rDoc = mrViewData.GetDocument(); - const Size aPageSize = rDoc.GetPageSize(nCurrentTab); - // Do not attempt to calculate a page size here if it is empty if - // that involves counting pages. - // An earlier implementation did - // ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nCurrentTab); - // rDoc.SetPageSize(nCurrentTab, rDoc.GetPageSize(nCurrentTab)); - // which resulted in tremendous waiting times after having loaded - // larger documents i.e. imported from CSV, in which UI is entirely - // blocked. All time is spent under ScPrintFunc::CountPages() in - // ScTable::ExtendPrintArea() in the loop that calls - // MaybeAddExtraColumn() to do stuff for each text string content - // cell (each row in each column). Maybe that can be optimized, or - // obtaining page size without that overhead would be possible, but - // as is calling that from here is a no-no so this is a quick - // disable things. - if (!aPageSize.IsEmpty()) - { - ScDocShell* pDocSh = mrViewData.GetDocShell(); - const bool bModified = pDocSh->IsModified(); - // Even setting the same size sets page size valid, so - // UpdatePageBreaks() actually does something. - rDoc.SetPageSize( nCurrentTab, aPageSize); - rDoc.UpdatePageBreaks(nCurrentTab); - pDocSh->PostPaint(0, 0, nCurrentTab, rDoc.MaxCol(), rDoc.MaxRow(), nCurrentTab, PaintPartFlags::Grid); - pDocSh->SetModified(bModified); - } + ScDocShell* pDocSh = mrViewData.GetDocShell(); + const bool bModified = pDocSh->IsModified(); + // Even setting the same size sets page size valid, so + // UpdatePageBreaks() actually does something. + rDoc.SetPageSize( nCurrentTab, aPageSize); + rDoc.UpdatePageBreaks(nCurrentTab); + pDocSh->PostPaint(0, 0, nCurrentTab, rDoc.MaxCol(), rDoc.MaxRow(), nCurrentTab, PaintPartFlags::Grid); + pDocSh->SetModified(bModified); } } } diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index d1238009fa89..098d66048e91 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -3226,34 +3226,34 @@ void ScOutputData::ShowClipMarks( DrawEditParam& rParam, tools::Long nEngineWidt // with the default right position of the text. // Only with automatic line breaks, to avoid having to find // the cells with the horizontal end of the text again. - if (nEngineWidth - aCellSize.Width() > 100 && rParam.mbBreak && bMarkClipped - && (rParam.mpEngine->GetParagraphCount() > 1 || rParam.mpEngine->GetLineCount(0) > 1)) + if (nEngineWidth - aCellSize.Width() <= 100 || !rParam.mbBreak || !bMarkClipped + || (rParam.mpEngine->GetParagraphCount() <= 1 && rParam.mpEngine->GetLineCount(0) <= 1)) + return; + + CellInfo* pClipMarkCell = nullptr; + if (bMerged) { - CellInfo* pClipMarkCell = nullptr; - if (bMerged) - { - // anywhere in the merged area... - SCCOL nClipX = (rParam.mnX < nX1) ? nX1 : rParam.mnX; - pClipMarkCell = &pRowInfo[(rParam.mnArrY != 0) ? rParam.mnArrY : 1].pCellInfo[nClipX + 1]; - } - else - pClipMarkCell = &rParam.mpThisRowInfo->pCellInfo[rParam.mnX + 1]; + // anywhere in the merged area... + SCCOL nClipX = (rParam.mnX < nX1) ? nX1 : rParam.mnX; + pClipMarkCell = &pRowInfo[(rParam.mnArrY != 0) ? rParam.mnArrY : 1].pCellInfo[nClipX + 1]; + } + else + pClipMarkCell = &rParam.mpThisRowInfo->pCellInfo[rParam.mnX + 1]; - bAnyClipped = true; - bVertical = true; - const tools::Long nMarkPixel = static_cast<tools::Long>(SC_CLIPMARK_SIZE * mnPPTX); - if (bTop) - { - pClipMarkCell->nClipMark |= ScClipMark::Top; - if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) - aAreaParam.maClipRect.AdjustTop(+nMarkPixel); - } - else - { - pClipMarkCell->nClipMark |= ScClipMark::Bottom; - if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) - aAreaParam.maClipRect.AdjustBottom(-nMarkPixel); - } + bAnyClipped = true; + bVertical = true; + const tools::Long nMarkPixel = static_cast<tools::Long>(SC_CLIPMARK_SIZE * mnPPTX); + if (bTop) + { + pClipMarkCell->nClipMark |= ScClipMark::Top; + if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) + aAreaParam.maClipRect.AdjustTop(+nMarkPixel); + } + else + { + pClipMarkCell->nClipMark |= ScClipMark::Bottom; + if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) + aAreaParam.maClipRect.AdjustBottom(-nMarkPixel); } } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index cf43eee2403a..60cd39fd03fd 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -3205,24 +3205,24 @@ void ScViewData::CalcPPT() } } - if (comphelper::LibreOfficeKit::isActive()) + if (!comphelper::LibreOfficeKit::isActive()) + return; + + SCTAB nTabCount = maTabData.size(); + bool bResetWidths = (nPPTX != nOldPPTX); + bool bResetHeights = (nPPTY != nOldPPTY); + for (SCTAB nTabIdx = 0; nTabIdx < nTabCount; ++nTabIdx) { - SCTAB nTabCount = maTabData.size(); - bool bResetWidths = (nPPTX != nOldPPTX); - bool bResetHeights = (nPPTY != nOldPPTY); - for (SCTAB nTabIdx = 0; nTabIdx < nTabCount; ++nTabIdx) - { - if (!maTabData[nTabIdx]) - continue; + if (!maTabData[nTabIdx]) + continue; - if (bResetWidths) - if (auto* pWHelper = GetLOKWidthHelper(nTabIdx)) - pWHelper->invalidateByPosition(0L); + if (bResetWidths) + if (auto* pWHelper = GetLOKWidthHelper(nTabIdx)) + pWHelper->invalidateByPosition(0L); - if (bResetHeights) - if (auto* pHHelper = GetLOKHeightHelper(nTabIdx)) - pHHelper->invalidateByPosition(0L); - } + if (bResetHeights) + if (auto* pHHelper = GetLOKHeightHelper(nTabIdx)) + pHHelper->invalidateByPosition(0L); } } diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index c06c109cd0d4..fbf7525217ff 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -510,59 +510,59 @@ bool PowerPointExport::exportDocument() void PowerPointExport::WriteCustomSlideShow() { Reference<XCustomPresentationSupplier> aXCPSup(mXModel, css::uno::UNO_QUERY); - if (aXCPSup.is() && aXCPSup->getCustomPresentations()->hasElements()) - { - mPresentationFS->startElementNS(XML_p, XML_custShowLst); + if (!aXCPSup.is() || !aXCPSup->getCustomPresentations()->hasElements()) + return; + + mPresentationFS->startElementNS(XML_p, XML_custShowLst); + + Reference<XDrawPagesSupplier> xDPS(getModel(), uno::UNO_QUERY_THROW); + Reference<XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW); + Reference<XNameContainer> aXNameCont(aXCPSup->getCustomPresentations()); + const Sequence<OUString> aNameSeq(aXNameCont->getElementNames()); - Reference<XDrawPagesSupplier> xDPS(getModel(), uno::UNO_QUERY_THROW); - Reference<XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW); - Reference<XNameContainer> aXNameCont(aXCPSup->getCustomPresentations()); - const Sequence<OUString> aNameSeq(aXNameCont->getElementNames()); + OUString sRelId; + sal_uInt32 nCustomShowIndex = 0; + sal_Int32 nSlideCount = xDrawPages->getCount(); - OUString sRelId; - sal_uInt32 nCustomShowIndex = 0; - sal_Int32 nSlideCount = xDrawPages->getCount(); + for (OUString const& customShowName : aNameSeq) + { + mPresentationFS->startElementNS(XML_p, XML_custShow, XML_name, customShowName, XML_id, + OUString::number(nCustomShowIndex++)); - for (OUString const& customShowName : aNameSeq) + mAny = aXNameCont->getByName(customShowName); + Reference<XIndexContainer> aXIContainer; + if (mAny >>= aXIContainer) { - mPresentationFS->startElementNS(XML_p, XML_custShow, XML_name, customShowName, XML_id, - OUString::number(nCustomShowIndex++)); + mPresentationFS->startElementNS(XML_p, XML_sldLst); - mAny = aXNameCont->getByName(customShowName); - Reference<XIndexContainer> aXIContainer; - if (mAny >>= aXIContainer) + sal_Int32 nCustomShowSlideCount = aXIContainer->getCount(); + for (sal_Int32 i = 0; i < nCustomShowSlideCount; ++i) { - mPresentationFS->startElementNS(XML_p, XML_sldLst); + Reference<XDrawPage> aXCustomShowDrawPage; + aXIContainer->getByIndex(i) >>= aXCustomShowDrawPage; + Reference<XNamed> aXName(aXCustomShowDrawPage, UNO_QUERY_THROW); + OUString sCustomShowSlideName = aXName->getName(); - sal_Int32 nCustomShowSlideCount = aXIContainer->getCount(); - for (sal_Int32 i = 0; i < nCustomShowSlideCount; ++i) + for (sal_Int32 j = 0; j < nSlideCount; ++j) { - Reference<XDrawPage> aXCustomShowDrawPage; - aXIContainer->getByIndex(i) >>= aXCustomShowDrawPage; - Reference<XNamed> aXName(aXCustomShowDrawPage, UNO_QUERY_THROW); - OUString sCustomShowSlideName = aXName->getName(); + Reference<XDrawPage> xDrawPage; + xDrawPages->getByIndex(j) >>= xDrawPage; + Reference<XNamed> xNamed(xDrawPage, UNO_QUERY_THROW); + OUString sSlideName = xNamed->getName(); - for (sal_Int32 j = 0; j < nSlideCount; ++j) + if (sCustomShowSlideName == sSlideName) { - Reference<XDrawPage> xDrawPage; - xDrawPages->getByIndex(j) >>= xDrawPage; - Reference<XNamed> xNamed(xDrawPage, UNO_QUERY_THROW); - OUString sSlideName = xNamed->getName(); - - if (sCustomShowSlideName == sSlideName) - { - sRelId = maRelId[j]; - break; - } + sRelId = maRelId[j]; + break; } - mPresentationFS->singleElementNS(XML_p, XML_sld, FSNS(XML_r, XML_id), sRelId); } - mPresentationFS->endElementNS(XML_p, XML_sldLst); + mPresentationFS->singleElementNS(XML_p, XML_sld, FSNS(XML_r, XML_id), sRelId); } - mPresentationFS->endElementNS(XML_p, XML_custShow); + mPresentationFS->endElementNS(XML_p, XML_sldLst); } - mPresentationFS->endElementNS(XML_p, XML_custShowLst); + mPresentationFS->endElementNS(XML_p, XML_custShow); } + mPresentationFS->endElementNS(XML_p, XML_custShowLst); } void PowerPointExport::ImplWriteBackground(const FSHelperPtr& pFS, const Reference< XPropertySet >& rXPropSet) @@ -1098,75 +1098,75 @@ sal_Int32 PowerPointExport::GetAuthorIdAndLastIndex(const OUString& sAuthor, sal void PowerPointExport::WritePresentationProps() { Reference<XPresentationSupplier> xPresentationSupplier(mXModel, uno::UNO_QUERY); - if (xPresentationSupplier.is()) - { - Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(), - uno::UNO_QUERY); - bool bEndlessVal = xPresentationProps->getPropertyValue("IsEndless").get<bool>(); - bool bChangeManually = xPresentationProps->getPropertyValue("IsAutomatic").get<bool>(); - OUString sFirstPage = xPresentationProps->getPropertyValue("FirstPage").get<OUString>(); - OUString sCustomShow = xPresentationProps->getPropertyValue("CustomShow").get<OUString>(); + if (!xPresentationSupplier.is()) + return; - FSHelperPtr pFS = openFragmentStreamWithSerializer( - "ppt/presProps.xml", - "application/vnd.openxmlformats-officedocument.presentationml.presProps+xml"); + Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(), + uno::UNO_QUERY); + bool bEndlessVal = xPresentationProps->getPropertyValue("IsEndless").get<bool>(); + bool bChangeManually = xPresentationProps->getPropertyValue("IsAutomatic").get<bool>(); + OUString sFirstPage = xPresentationProps->getPropertyValue("FirstPage").get<OUString>(); + OUString sCustomShow = xPresentationProps->getPropertyValue("CustomShow").get<OUString>(); - addRelation(mPresentationFS->getOutputStream(), - oox::getRelationship(Relationship::PRESPROPS), u"presProps.xml"); + FSHelperPtr pFS = openFragmentStreamWithSerializer( + "ppt/presProps.xml", + "application/vnd.openxmlformats-officedocument.presentationml.presProps+xml"); - pFS->startElementNS(XML_p, XML_presentationPr, PPRNMSS); + addRelation(mPresentationFS->getOutputStream(), + oox::getRelationship(Relationship::PRESPROPS), u"presProps.xml"); + + pFS->startElementNS(XML_p, XML_presentationPr, PPRNMSS); - pFS->startElementNS(XML_p, XML_showPr, XML_loop, sax_fastparser::UseIf("1", bEndlessVal), - XML_useTimings, sax_fastparser::UseIf("0", bChangeManually), - XML_showNarration, "1"); + pFS->startElementNS(XML_p, XML_showPr, XML_loop, sax_fastparser::UseIf("1", bEndlessVal), + XML_useTimings, sax_fastparser::UseIf("0", bChangeManually), + XML_showNarration, "1"); - Reference<drawing::XDrawPagesSupplier> xDPS(mXModel, uno::UNO_QUERY_THROW); - Reference<drawing::XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW); - if (!sFirstPage.isEmpty()) + Reference<drawing::XDrawPagesSupplier> xDPS(mXModel, uno::UNO_QUERY_THROW); + Reference<drawing::XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW); + if (!sFirstPage.isEmpty()) + { + sal_Int32 nStartSlide = 1; + sal_Int32 nEndSlide = xDrawPages->getCount(); + for (sal_Int32 i = 0; i < nEndSlide; i++) { - sal_Int32 nStartSlide = 1; - sal_Int32 nEndSlide = xDrawPages->getCount(); - for (sal_Int32 i = 0; i < nEndSlide; i++) + Reference<drawing::XDrawPage> xDrawPage; + xDrawPages->getByIndex(i) >>= xDrawPage; + Reference<container::XNamed> xNamed(xDrawPage, uno::UNO_QUERY_THROW); + if (xNamed->getName() == sFirstPage) { - Reference<drawing::XDrawPage> xDrawPage; - xDrawPages->getByIndex(i) >>= xDrawPage; - Reference<container::XNamed> xNamed(xDrawPage, uno::UNO_QUERY_THROW); - if (xNamed->getName() == sFirstPage) - { - nStartSlide = i + 1; - break; - } + nStartSlide = i + 1; + break; } - - pFS->singleElementNS(XML_p, XML_sldRg, XML_st, OUString::number(nStartSlide), XML_end, - OUString::number(nEndSlide)); } - if (!sCustomShow.isEmpty()) + pFS->singleElementNS(XML_p, XML_sldRg, XML_st, OUString::number(nStartSlide), XML_end, + OUString::number(nEndSlide)); + } + + if (!sCustomShow.isEmpty()) + { + css::uno::Reference<css::presentation::XCustomPresentationSupplier> + XCustPresentationSupplier(mXModel, css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::container::XNameContainer> mxCustShows; + mxCustShows = XCustPresentationSupplier->getCustomPresentations(); + const css::uno::Sequence<OUString> aNameSeq(mxCustShows->getElementNames()); + + sal_Int32 nCustShowIndex = 0; + for (sal_Int32 i = 0; i < aNameSeq.getLength(); i++) { - css::uno::Reference<css::presentation::XCustomPresentationSupplier> - XCustPresentationSupplier(mXModel, css::uno::UNO_QUERY_THROW); - css::uno::Reference<css::container::XNameContainer> mxCustShows; - mxCustShows = XCustPresentationSupplier->getCustomPresentations(); - const css::uno::Sequence<OUString> aNameSeq(mxCustShows->getElementNames()); - - sal_Int32 nCustShowIndex = 0; - for (sal_Int32 i = 0; i < aNameSeq.getLength(); i++) + if (aNameSeq[i] == sCustomShow) { - if (aNameSeq[i] == sCustomShow) - { - nCustShowIndex = i; - break; - } + nCustShowIndex = i; + break; } - - pFS->singleElementNS(XML_p, XML_custShow, XML_id, OUString::number(nCustShowIndex)); } - pFS->endElementNS(XML_p, XML_showPr); - - pFS->endElementNS(XML_p, XML_presentationPr); + pFS->singleElementNS(XML_p, XML_custShow, XML_id, OUString::number(nCustShowIndex)); } + + pFS->endElementNS(XML_p, XML_showPr); + + pFS->endElementNS(XML_p, XML_presentationPr); } bool PowerPointExport::WriteComments(sal_uInt32 nPageNum) diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx index 5d13db6c4ecd..16d6557bca14 100644 --- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx +++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx @@ -951,8 +951,9 @@ DocumentSettings::_setPropertyValues(const PropertyMapEntry** ppEntries, if ( !pDocSh->SetModifyPasswordInfo( aInfo ) ) throw beans::PropertyVetoException( "The hash is not allowed to be changed now!" ); - else - bOk = true; + + bOk = true +; } break; diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index fadeeca7339a..4e44acf04908 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -2160,24 +2160,24 @@ void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl *pCW) return; pFact = pMod->GetChildWinFactoryById(pCW->nSaveId); - if ( pFact ) - { - pCW->aInfo = pFact->aInfo; - pCW->aInfo.aModule = sModule; - SfxChildWindow::InitializeChildWinFactory_Impl( - pCW->nSaveId, pCW->aInfo); - pCW->bCreate = pCW->aInfo.bVisible; - SfxChildWindowFlags nFlags = pFact->aInfo.nFlags; - if ( nFlags & SfxChildWindowFlags::TASK ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::TASK; - if ( nFlags & SfxChildWindowFlags::CANTGETFOCUS ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::CANTGETFOCUS; - if ( nFlags & SfxChildWindowFlags::FORCEDOCK ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::FORCEDOCK; - if ( nFlags & SfxChildWindowFlags::ALWAYSAVAILABLE ) - pCW->aInfo.nFlags |= SfxChildWindowFlags::ALWAYSAVAILABLE; - pFact->aInfo = pCW->aInfo; - } + if ( !pFact ) + return; + + pCW->aInfo = pFact->aInfo; + pCW->aInfo.aModule = sModule; + SfxChildWindow::InitializeChildWinFactory_Impl( + pCW->nSaveId, pCW->aInfo); + pCW->bCreate = pCW->aInfo.bVisible; + SfxChildWindowFlags nFlags = pFact->aInfo.nFlags; + if ( nFlags & SfxChildWindowFlags::TASK ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::TASK; + if ( nFlags & SfxChildWindowFlags::CANTGETFOCUS ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::CANTGETFOCUS; + if ( nFlags & SfxChildWindowFlags::FORCEDOCK ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::FORCEDOCK; + if ( nFlags & SfxChildWindowFlags::ALWAYSAVAILABLE ) + pCW->aInfo.nFlags |= SfxChildWindowFlags::ALWAYSAVAILABLE; + pFact->aInfo = pCW->aInfo; } SfxSplitWindow* SfxWorkWindow::GetSplitWindow_Impl( SfxChildAlignment eAlign ) diff --git a/sfx2/source/commandpopup/CommandPopup.cxx b/sfx2/source/commandpopup/CommandPopup.cxx index b13d474b975b..473155f89a00 100644 --- a/sfx2/source/commandpopup/CommandPopup.cxx +++ b/sfx2/source/commandpopup/CommandPopup.cxx @@ -152,31 +152,29 @@ void MenuContentHandler::addCommandIfPossible( util::URL aCommandURL; aCommandURL.Complete = sCommandURL; - if (m_xURLTransformer->parseStrict(aCommandURL)) - { - auto* pViewFrame = SfxViewFrame::Current(); + if (!m_xURLTransformer->parseStrict(aCommandURL)) + return; - SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool(pViewFrame); - const SfxSlot* pSlot = rSlotPool.GetUnoSlot(aCommandURL.Path); - if (pSlot) - { - std::unique_ptr<SfxPoolItem> pState; - SfxItemState eState = pViewFrame->GetBindings().QueryState(pSlot->GetSlotId(), pState); - - if (eState != SfxItemState::DISABLED) - { - auto xGraphic - = vcl::CommandInfoProvider::GetXGraphicForCommand(sCommandURL, m_xFrame); - rCommandList.emplace_back(sCommandURL, rMenuContent.m_aTooltip); - - auto pIter = rpCommandTreeView->make_iterator(); - rpCommandTreeView->insert(nullptr, -1, &rMenuContent.m_aFullLabelWithPath, nullptr, - nullptr, nullptr, false, pIter.get()); - rpCommandTreeView->set_image(*pIter, xGraphic); - m_aAdded.insert(rMenuContent.m_aFullLabelWithPath); - } - } - } + auto* pViewFrame = SfxViewFrame::Current(); + + SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool(pViewFrame); + const SfxSlot* pSlot = rSlotPool.GetUnoSlot(aCommandURL.Path); + if (!pSlot) + return; + + std::unique_ptr<SfxPoolItem> pState; + SfxItemState eState = pViewFrame->GetBindings().QueryState(pSlot->GetSlotId(), pState); + if (eState == SfxItemState::DISABLED) + return; + + auto xGraphic = vcl::CommandInfoProvider::GetXGraphicForCommand(sCommandURL, m_xFrame); + rCommandList.emplace_back(sCommandURL, rMenuContent.m_aTooltip); + + auto pIter = rpCommandTreeView->make_iterator(); + rpCommandTreeView->insert(nullptr, -1, &rMenuContent.m_aFullLabelWithPath, nullptr, nullptr, + nullptr, false, pIter.get()); + rpCommandTreeView->set_image(*pIter, xGraphic); + m_aAdded.insert(rMenuContent.m_aFullLabelWithPath); } OUString MenuContentHandler::toLower(OUString const& rString) diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx index 5d2b778ada92..691780df0863 100644 --- a/sfx2/source/dialog/StyleList.cxx +++ b/sfx2/source/dialog/StyleList.cxx @@ -530,28 +530,28 @@ IMPL_LINK(StyleList, ExecuteDrop, const ExecuteDropEvent&, rEvt, sal_Int8) IMPL_LINK_NOARG(StyleList, NewMenuExecuteAction, void*, void) { - if (m_pStyleSheetPool && m_nActFamily != 0xffff) - { - const SfxStyleFamily eFam = GetFamilyItem()->GetFamily(); - const SfxStyleFamilyItem* pItem = GetFamilyItem(); - SfxStyleSearchBits nFilter(SfxStyleSearchBits::Auto); - if (pItem && m_nActFilter != 0xffff) - nFilter = pItem->GetFilterList()[m_nActFilter].nFlags; - if (nFilter == SfxStyleSearchBits::Auto) // automatic - nFilter = m_nAppFilter; + if (!m_pStyleSheetPool || m_nActFamily == 0xffff) + return; - // why? : FloatingWindow must not be parent of a modal dialog - SfxNewStyleDlg aDlg(m_pContainer, *m_pStyleSheetPool, eFam); - auto nResult = aDlg.run(); - if (nResult == RET_OK) - { - const OUString aTemplName(aDlg.GetName()); - m_pParentDialog->Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE, aTemplName, "", - static_cast<sal_uInt16>(GetFamilyItem()->GetFamily()), - *this, nFilter); - UpdateFamily(); - m_aUpdateFamily.Call(*this); - } + const SfxStyleFamily eFam = GetFamilyItem()->GetFamily(); + const SfxStyleFamilyItem* pItem = GetFamilyItem(); + SfxStyleSearchBits nFilter(SfxStyleSearchBits::Auto); + if (pItem && m_nActFilter != 0xffff) + nFilter = pItem->GetFilterList()[m_nActFilter].nFlags; + if (nFilter == SfxStyleSearchBits::Auto) // automatic + nFilter = m_nAppFilter; + + // why? : FloatingWindow must not be parent of a modal dialog + SfxNewStyleDlg aDlg(m_pContainer, *m_pStyleSheetPool, eFam); + auto nResult = aDlg.run(); + if (nResult == RET_OK) + { + const OUString aTemplName(aDlg.GetName()); + m_pParentDialog->Execute_Impl(SID_STYLE_NEW_BY_EXAMPLE, aTemplName, "", + static_cast<sal_uInt16>(GetFamilyItem()->GetFamily()), *this, + nFilter); + UpdateFamily(); + m_aUpdateFamily.Call(*this); } } @@ -838,66 +838,66 @@ void StyleList::SelectStyle(const OUString& rStr, bool bIsCallback) m_pParentDialog->EnableShow(false, this); } - if (!bIsCallback) + if (bIsCallback) + return; + + if (m_xTreeBox->get_visible()) { - if (m_xTreeBox->get_visible()) + if (!rStr.isEmpty()) { - if (!rStr.isEmpty()) - { - std::unique_ptr<weld::TreeIter> xEntry = m_xTreeBox->make_iterator(); - bool bEntry = m_xTreeBox->get_iter_first(*xEntry); - while (bEntry) - { - if (m_xTreeBox->get_text(*xEntry) == rStr) - { - m_xTreeBox->scroll_to_row(*xEntry); - m_xTreeBox->select(*xEntry); - break; - } - bEntry = m_xTreeBox->iter_next(*xEntry); - } - } - else if (eFam == SfxStyleFamily::Pseudo) + std::unique_ptr<weld::TreeIter> xEntry = m_xTreeBox->make_iterator(); + bool bEntry = m_xTreeBox->get_iter_first(*xEntry); + while (bEntry) { - std::unique_ptr<weld::TreeIter> xEntry = m_xTreeBox->make_iterator(); - if (m_xTreeBox->get_iter_first(*xEntry)) + if (m_xTreeBox->get_text(*xEntry) == rStr) { m_xTreeBox->scroll_to_row(*xEntry); m_xTreeBox->select(*xEntry); + break; } + bEntry = m_xTreeBox->iter_next(*xEntry); + } + } + else if (eFam == SfxStyleFamily::Pseudo) + { + std::unique_ptr<weld::TreeIter> xEntry = m_xTreeBox->make_iterator(); + if (m_xTreeBox->get_iter_first(*xEntry)) + { + m_xTreeBox->scroll_to_row(*xEntry); + m_xTreeBox->select(*xEntry); } - else - m_xTreeBox->unselect_all(); } else + m_xTreeBox->unselect_all(); + } + else + { + bool bSelect = !rStr.isEmpty(); + if (bSelect) { - bool bSelect = !rStr.isEmpty(); - if (bSelect) + std::unique_ptr<weld::TreeIter> xEntry = m_xFmtLb->make_iterator(); + bool bEntry = m_xFmtLb->get_iter_first(*xEntry); + while (bEntry && m_xFmtLb->get_text(*xEntry) != rStr) + bEntry = m_xFmtLb->iter_next(*xEntry); + if (!bEntry) + bSelect = false; + else { - std::unique_ptr<weld::TreeIter> xEntry = m_xFmtLb->make_iterator(); - bool bEntry = m_xFmtLb->get_iter_first(*xEntry); - while (bEntry && m_xFmtLb->get_text(*xEntry) != rStr) - bEntry = m_xFmtLb->iter_next(*xEntry); - if (!bEntry) - bSelect = false; - else + if (!m_xFmtLb->is_selected(*xEntry)) { - if (!m_xFmtLb->is_selected(*xEntry)) - { - m_xFmtLb->unselect_all(); - m_xFmtLb->scroll_to_row(*xEntry); - m_xFmtLb->select(*xEntry); - } + m_xFmtLb->unselect_all(); + m_xFmtLb->scroll_to_row(*xEntry); + m_xFmtLb->select(*xEntry); } } + } - if (!bSelect) - { - m_xFmtLb->unselect_all(); - m_pParentDialog->EnableEdit(false, this); - m_pParentDialog->EnableHide(false, this); - m_pParentDialog->EnableShow(false, this); - } + if (!bSelect) + { + m_xFmtLb->unselect_all(); + m_pParentDialog->EnableEdit(false, this); + m_pParentDialog->EnableHide(false, this); + m_pParentDialog->EnableShow(false, this); } } } diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx index 6efb8d87f2e6..dcfd3e53753a 100644 --- a/sfx2/source/doc/templatedlg.cxx +++ b/sfx2/source/doc/templatedlg.cxx @@ -578,30 +578,30 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, MoveTemplateHdl, void*, void) size_t nItemId = 0; - if (aDlg.run() == RET_OK) - { - const OUString& sCategory = aDlg.GetSelectedCategory(); - bool bIsNewCategory = aDlg.IsNewCategoryCreated(); - if(bIsNewCategory) - { - if (!sCategory.isEmpty()) - { - nItemId = mxLocalView->createRegion(sCategory); - if(nItemId) - mxCBFolder->append_text(sCategory); - } - } - else - nItemId = mxLocalView->getRegionId(sCategory); + if (aDlg.run() != RET_OK) + return; - if(nItemId) + const OUString& sCategory = aDlg.GetSelectedCategory(); + bool bIsNewCategory = aDlg.IsNewCategoryCreated(); + if(bIsNewCategory) + { + if (!sCategory.isEmpty()) { - localMoveTo(nItemId); + nItemId = mxLocalView->createRegion(sCategory); + if(nItemId) + mxCBFolder->append_text(sCategory); } + } + else + nItemId = mxLocalView->getRegionId(sCategory); - mxLocalView->reload(); - SearchUpdate(); + if(nItemId) + { + localMoveTo(nItemId); } + + mxLocalView->reload(); + SearchUpdate(); } IMPL_LINK_NOARG(SfxTemplateManagerDlg, ExportTemplateHdl, void*, void) { @@ -689,21 +689,21 @@ IMPL_LINK(SfxTemplateManagerDlg, CreateContextMenuHdl, ThumbnailViewItem*, pItem } } - if (pViewItem) - { - bool bIsSingleSel = maSelTemplates.size() == 1; - OUString aDefaultImg; - INetURLObject aUrl(pViewItem->getPath()); - if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::WRITER, aUrl.getExtension())) - aDefaultImg = BMP_ACTION_DEFAULT_WRITER; - else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::CALC, aUrl.getExtension())) - aDefaultImg = BMP_ACTION_DEFAULT_CALC; - else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::IMPRESS, aUrl.getExtension())) - aDefaultImg = BMP_ACTION_DEFAULT_IMPRESS; - else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::DRAW, aUrl.getExtension())) - aDefaultImg = BMP_ACTION_DEFAULT_DRAW; - mxLocalView->createContextMenu(bIsDefault, bIsInternal, bIsSingleSel, aDefaultImg); - } + if (!pViewItem) + return; + + bool bIsSingleSel = maSelTemplates.size() == 1; + OUString aDefaultImg; + INetURLObject aUrl(pViewItem->getPath()); + if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::WRITER, aUrl.getExtension())) + aDefaultImg = BMP_ACTION_DEFAULT_WRITER; + else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::CALC, aUrl.getExtension())) + aDefaultImg = BMP_ACTION_DEFAULT_CALC; + else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::IMPRESS, aUrl.getExtension())) + aDefaultImg = BMP_ACTION_DEFAULT_IMPRESS; + else if (ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION::DRAW, aUrl.getExtension())) + aDefaultImg = BMP_ACTION_DEFAULT_DRAW; + mxLocalView->createContextMenu(bIsDefault, bIsInternal, bIsSingleSel, aDefaultImg); } IMPL_LINK(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem, void) diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 3b87e2be21bd..82b811bb94f5 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -333,21 +333,21 @@ void SAL_CALL SfxInPlaceClient_Impl::activatingInplace() if ( !m_pClient || !m_pClient->GetViewShell() ) throw uno::RuntimeException(); - if ( comphelper::LibreOfficeKit::isActive() ) - { - if ( SfxViewShell* pViewShell = m_pClient->GetViewShell() ) - { - tools::Rectangle aRect(m_pClient->GetObjArea()); + if ( !comphelper::LibreOfficeKit::isActive() ) + return; - if (m_pClient->GetEditWin()) - { - if (m_pClient->GetEditWin()->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) - aRect = o3tl::convert(aRect, o3tl::Length::mm100, o3tl::Length::twip); - } + if ( SfxViewShell* pViewShell = m_pClient->GetViewShell() ) + { + tools::Rectangle aRect(m_pClient->GetObjArea()); - OString str = aRect.toString() + ", \"INPLACE\""; - pViewShell->libreOfficeKitViewCallback( LOK_CALLBACK_GRAPHIC_SELECTION, str.getStr() ); + if (m_pClient->GetEditWin()) + { + if (m_pClient->GetEditWin()->GetMapMode().GetMapUnit() == MapUnit::Map100thMM) + aRect = o3tl::convert(aRect, o3tl::Length::mm100, o3tl::Length::twip); } + + OString str = aRect.toString() + ", \"INPLACE\""; + pViewShell->libreOfficeKitViewCallback( LOK_CALLBACK_GRAPHIC_SELECTION, str.getStr() ); } } diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 4ba5bc852834..b4924dc4474c 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1662,20 +1662,21 @@ IMPL_LINK(SfxViewFrame, HiddenTrackChangesHandler, weld::Button&, rButton, void) { // enable Track Changes toolbar, if it is disabled. // Otherwise disable the toolbar, and close the infobar - if (auto xLayoutManager = getLayoutManager(GetFrame())) + auto xLayoutManager = getLayoutManager(GetFrame()); + if (!xLayoutManager) + return; + + if (!xLayoutManager->getElement(CHANGES_STR).is()) { - if (!xLayoutManager->getElement(CHANGES_STR).is()) - { - xLayoutManager->createElement(CHANGES_STR); - xLayoutManager->showElement(CHANGES_STR); - rButton.set_label(SfxResId(STR_TRACK_CHANGES_BUTTON_HIDE)); - } - else - { - xLayoutManager->hideElement(CHANGES_STR); - xLayoutManager->destroyElement(CHANGES_STR); - RemoveInfoBar(u"hiddentrackchanges"); - } + xLayoutManager->createElement(CHANGES_STR); + xLayoutManager->showElement(CHANGES_STR); + rButton.set_label(SfxResId(STR_TRACK_CHANGES_BUTTON_HIDE)); + } + else + { + xLayoutManager->hideElement(CHANGES_STR); + xLayoutManager->destroyElement(CHANGES_STR); + RemoveInfoBar(u"hiddentrackchanges"); } } diff --git a/starmath/source/mathml/import.cxx b/starmath/source/mathml/import.cxx index 1da11b86fc76..a882e0b527cd 100644 --- a/starmath/source/mathml/import.cxx +++ b/starmath/source/mathml/import.cxx @@ -790,23 +790,23 @@ void SmMLImportContext::inheritStyleEnd() } // Mi: 1 char -> italic - if (m_pElement->getMlElementType() == SmMlElementType::MlMi) + if (m_pElement->getMlElementType() != SmMlElementType::MlMi) + return; + + // Inherit mathvariant + if (!m_pStyle->isAttributeSet(SmMlAttributeValueType::MlMathvariant)) { - // Inherit mathvariant - if (!m_pStyle->isAttributeSet(SmMlAttributeValueType::MlMathvariant)) + sal_Int32 nIndexUtf16 = 0; + // Check if there is only one code point + m_pElement->getText().iterateCodePoints(&nIndexUtf16, 1); + // Mathml says that 1 code point -> italic + if (nIndexUtf16 == m_pElement->getText().getLength()) { - sal_Int32 nIndexUtf16 = 0; - // Check if there is only one code point - m_pElement->getText().iterateCodePoints(&nIndexUtf16, 1); - // Mathml says that 1 code point -> italic - if (nIndexUtf16 == m_pElement->getText().getLength()) - { - SmMlAttribute aAttribute(SmMlAttributeValueType::MlMathvariant); - SmMlMathvariant aMathvariant = { SmMlAttributeValueMathvariant::italic }; - aAttribute.setMlMathvariant(&aMathvariant); - aAttribute.setSet(false); - m_pElement->setAttribute(aAttribute); - } + SmMlAttribute aAttribute(SmMlAttributeValueType::MlMathvariant); + SmMlMathvariant aMathvariant = { SmMlAttributeValueMathvariant::italic }; + aAttribute.setMlMathvariant(&aMathvariant); + aAttribute.setSet(false); + m_pElement->setAttribute(aAttribute); } } } diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx index fd27a9744d80..fadebf4c6dfd 100644 --- a/svx/source/sdr/properties/defaultproperties.cxx +++ b/svx/source/sdr/properties/defaultproperties.cxx @@ -110,20 +110,20 @@ namespace sdr::properties { const sal_uInt16 nWhichID(rItem.Which()); - if(AllowItemChange(nWhichID, &rItem)) - { - ItemChange(nWhichID, &rItem); - PostItemChange(nWhichID); + if(!AllowItemChange(nWhichID, &rItem)) + return; - if (WantItemSetInItemSetChanged()) - { - SfxItemSet aSet(GetSdrObject().GetObjectItemPool(), nWhichID, nWhichID); - aSet.Put(rItem); - ItemSetChanged(&aSet); - } - else - ItemSetChanged(nullptr); + ItemChange(nWhichID, &rItem); + PostItemChange(nWhichID); + + if (WantItemSetInItemSetChanged()) + { + SfxItemSet aSet(GetSdrObject().GetObjectItemPool(), nWhichID, nWhichID); + aSet.Put(rItem); + ItemSetChanged(&aSet); } + else + ItemSetChanged(nullptr); } void DefaultProperties::SetObjectItemDirect(const SfxPoolItem& rItem) @@ -138,21 +138,21 @@ namespace sdr::properties void DefaultProperties::ClearObjectItem(const sal_uInt16 nWhich) { - if(AllowItemChange(nWhich)) - { - ItemChange(nWhich); - PostItemChange(nWhich); + if(!AllowItemChange(nWhich)) + return; + + ItemChange(nWhich); + PostItemChange(nWhich); - if(nWhich) + if(nWhich) + { + if (WantItemSetInItemSetChanged()) { - if (WantItemSetInItemSetChanged()) - { - SfxItemSet aSet(GetSdrObject().GetObjectItemPool(), nWhich, nWhich); - ItemSetChanged(&aSet); - } - else - ItemSetChanged(nullptr); + SfxItemSet aSet(GetSdrObject().GetObjectItemPool(), nWhich, nWhich); + ItemSetChanged(&aSet); } + else + ItemSetChanged(nullptr); } } diff --git a/svx/source/unodraw/SvxXTextColumns.cxx b/svx/source/unodraw/SvxXTextColumns.cxx index ee0fa10fa1d4..00971bc7bc87 100644 --- a/svx/source/unodraw/SvxXTextColumns.cxx +++ b/svx/source/unodraw/SvxXTextColumns.cxx @@ -206,11 +206,13 @@ void SvxXTextColumns::setPropertyValue(const OUString& rPropertyName, const css: switch (pEntry->nWID) { case WID_TXTCOL_LINE_WIDTH: - if (sal_Int32 nTmp; !(aValue >>= nTmp) || nTmp < 0) + { + sal_Int32 nTmp; + if (!(aValue >>= nTmp) || nTmp < 0) throw css::lang::IllegalArgumentException(); - else - m_nSepLineWidth = o3tl::toTwips(nTmp, o3tl::Length::mm100); + m_nSepLineWidth = o3tl::toTwips(nTmp, o3tl::Length::mm100); break; + } case WID_TXTCOL_LINE_COLOR: if (!(aValue >>= m_nSepLineColor)) throw css::lang::IllegalArgumentException(); @@ -220,11 +222,13 @@ void SvxXTextColumns::setPropertyValue(const OUString& rPropertyName, const css: throw css::lang::IllegalArgumentException(); break; case WID_TXTCOL_LINE_REL_HGT: - if (sal_Int32 nTmp; !(aValue >>= nTmp) || nTmp < 0) + { + sal_Int32 nTmp; + if (!(aValue >>= nTmp) || nTmp < 0) throw css::lang::IllegalArgumentException(); - else - m_nSepLineHeightRelative = nTmp; + m_nSepLineHeightRelative = nTmp; break; + } case WID_TXTCOL_LINE_ALIGN: if (css::style::VerticalAlignment eAlign; aValue >>= eAlign) m_nSepLineVertAlign = eAlign; @@ -238,21 +242,21 @@ void SvxXTextColumns::setPropertyValue(const OUString& rPropertyName, const css: throw css::lang::IllegalArgumentException(); break; case WID_TXTCOL_AUTO_DISTANCE: - if (sal_Int32 nTmp; !(aValue >>= nTmp) || nTmp < 0 || nTmp >= m_nReference) + { + sal_Int32 nTmp; + if (!(aValue >>= nTmp) || nTmp < 0 || nTmp >= m_nReference) throw css::lang::IllegalArgumentException(); - else + m_nAutoDistance = nTmp; + sal_Int32 nColumns = m_aTextColumns.getLength(); + css::text::TextColumn* pCols = m_aTextColumns.getArray(); + sal_Int32 nDist = m_nAutoDistance / 2; + for (sal_Int32 i = 0; i < nColumns; i++) { - m_nAutoDistance = nTmp; - sal_Int32 nColumns = m_aTextColumns.getLength(); - css::text::TextColumn* pCols = m_aTextColumns.getArray(); - sal_Int32 nDist = m_nAutoDistance / 2; - for (sal_Int32 i = 0; i < nColumns; i++) - { - pCols[i].LeftMargin = i == 0 ? 0 : nDist; - pCols[i].RightMargin = i == nColumns - 1 ? 0 : nDist; - } + pCols[i].LeftMargin = i == 0 ? 0 : nDist; + pCols[i].RightMargin = i == nColumns - 1 ? 0 : nDist; } break; + } } } diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index a8adba16c10e..c799a0da3551 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1630,43 +1630,43 @@ void SwCursor::ExpandToSentenceBorders(SwRootFrame const*const pLayout) { SwTextNode* pStartNd = Start()->nNode.GetNode().GetTextNode(); SwTextNode* pEndNd = End()->nNode.GetNode().GetTextNode(); - if (pStartNd && pEndNd) - { - if (!HasMark()) - SetMark(); + if (!pStartNd || !pEndNd) + return; - OUString sStartText( lcl_MaskDeletedRedlines( pStartNd ) ); - OUString sEndText( pStartNd == pEndNd? sStartText : lcl_MaskDeletedRedlines( pEndNd ) ); + if (!HasMark()) + SetMark(); - SwCursorSaveState aSave( *this ); - sal_Int32 nStartPos = Start()->nContent.GetIndex(); - sal_Int32 nEndPos = End()->nContent.GetIndex(); + OUString sStartText( lcl_MaskDeletedRedlines( pStartNd ) ); + OUString sEndText( pStartNd == pEndNd? sStartText : lcl_MaskDeletedRedlines( pEndNd ) ); - { - HideWrapper w(pLayout, pStartNd, nStartPos, &sStartText); + SwCursorSaveState aSave( *this ); + sal_Int32 nStartPos = Start()->nContent.GetIndex(); + sal_Int32 nEndPos = End()->nContent.GetIndex(); - w.m_nPtIndex = g_pBreakIt->GetBreakIter()->beginOfSentence( - *w.m_pText, w.m_nPtIndex, - g_pBreakIt->GetLocale( pStartNd->GetLang( nStartPos ) ) ); - } - { - HideWrapper w(pLayout, pEndNd, nEndPos, &sEndText); + { + HideWrapper w(pLayout, pStartNd, nStartPos, &sStartText); - w.m_nPtIndex = g_pBreakIt->GetBreakIter()->endOfSentence( - *w.m_pText, w.m_nPtIndex, - g_pBreakIt->GetLocale( pEndNd->GetLang( nEndPos ) ) ); - } + w.m_nPtIndex = g_pBreakIt->GetBreakIter()->beginOfSentence( + *w.m_pText, w.m_nPtIndex, + g_pBreakIt->GetLocale( pStartNd->GetLang( nStartPos ) ) ); + } + { + HideWrapper w(pLayout, pEndNd, nEndPos, &sEndText); - // it is allowed to place the PaM just behind the last - // character in the text thus <= ...Len - if (nStartPos <= pStartNd->GetText().getLength() && nStartPos >= 0) - { - *GetMark() = SwPosition(*pStartNd, nStartPos); - } - if (nEndPos <= pEndNd->GetText().getLength() && nEndPos >= 0) - { - *GetPoint() = SwPosition(*pEndNd, nEndPos); - } + w.m_nPtIndex = g_pBreakIt->GetBreakIter()->endOfSentence( + *w.m_pText, w.m_nPtIndex, + g_pBreakIt->GetLocale( pEndNd->GetLang( nEndPos ) ) ); + } + + // it is allowed to place the PaM just behind the last + // character in the text thus <= ...Len + if (nStartPos <= pStartNd->GetText().getLength() && nStartPos >= 0) + { + *GetMark() = SwPosition(*pStartNd, nStartPos); + } + if (nEndPos <= pEndNd->GetText().getLength() && nEndPos >= 0) + { + *GetPoint() = SwPosition(*pEndNd, nEndPos); } } diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 4504b74bafd3..2f0ae4676697 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -1263,36 +1263,36 @@ namespace //local functions originally from docfmt.cxx SwRangeRedline * pRedline = new SwRangeRedline( RedlineType::Format, rRg ); auto const result(rDoc.getIDocumentRedlineAccess().AppendRedline( pRedline, true)); // store original text attributes to reject formatting change - if (IDocumentRedlineAccess::AppendResult::IGNORED != result) + if (IDocumentRedlineAccess::AppendResult::IGNORED == result) + return; + + // no existing format redline in the range + if (!xExtra) { - // no existing format redline in the range - if (!xExtra) - { - // Apply the first character's attributes to the ReplaceText - SfxItemSetFixed<RES_CHRATR_BEGIN, RES_TXTATR_WITHEND_END - 1, - RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1> aSet( rDoc.GetAttrPool() ); - SwTextNode * pNode = rRg.Start()->nNode.GetNode().GetTextNode(); - pNode->GetParaAttr( aSet, rRg.Start()->nContent.GetIndex() + 1, rRg.End()->nContent.GetIndex() ); + // Apply the first character's attributes to the ReplaceText + SfxItemSetFixed<RES_CHRATR_BEGIN, RES_TXTATR_WITHEND_END - 1, + RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1> aSet( rDoc.GetAttrPool() ); + SwTextNode * pNode = rRg.Start()->nNode.GetNode().GetTextNode(); + pNode->GetParaAttr( aSet, rRg.Start()->nContent.GetIndex() + 1, rRg.End()->nContent.GetIndex() ); - aSet.ClearItem( RES_TXTATR_REFMARK ); - aSet.ClearItem( RES_TXTATR_TOXMARK ); - aSet.ClearItem( RES_TXTATR_CJK_RUBY ); - aSet.ClearItem( RES_TXTATR_INETFMT ); - aSet.ClearItem( RES_TXTATR_META ); - aSet.ClearItem( RES_TXTATR_METAFIELD ); + aSet.ClearItem( RES_TXTATR_REFMARK ); + aSet.ClearItem( RES_TXTATR_TOXMARK ); + aSet.ClearItem( RES_TXTATR_CJK_RUBY ); + aSet.ClearItem( RES_TXTATR_INETFMT ); + aSet.ClearItem( RES_TXTATR_META ); + aSet.ClearItem( RES_TXTATR_METAFIELD ); - // After GetParaAttr aSet can contain INVALID_POOL_ITEM items, e.g. RES_TXTATR_CHARFMT - // and (a copy of) this SfxItemSet can be passed to MSWordExportBase::OutputItemSet - // which doesn't handle INVALID_POOL_ITEM items so clear InvalidItems here - aSet.ClearInvalidItems(); + // After GetParaAttr aSet can contain INVALID_POOL_ITEM items, e.g. RES_TXTATR_CHARFMT + // and (a copy of) this SfxItemSet can be passed to MSWordExportBase::OutputItemSet + // which doesn't handle INVALID_POOL_ITEM items so clear InvalidItems here + aSet.ClearInvalidItems(); - xExtra.reset(new SwRedlineExtraData_FormatColl("", USHRT_MAX, &aSet)); - } + xExtra.reset(new SwRedlineExtraData_FormatColl("", USHRT_MAX, &aSet)); + } - if (xExtra) - { - pRedline->SetExtraData(xExtra.get() ); - } + if (xExtra) + { + pRedline->SetExtraData(xExtra.get() ); } } @@ -2672,20 +2672,20 @@ void DocumentContentOperationsManager::MoveAndJoin( SwPaM& rPaM, SwPosition& rPo aIdx--; // in front of the move area! bool bRet = MoveRange( rPaM, rPos, SwMoveFlags::DEFAULT ); - if( bRet && !bOneNode ) + if( !bRet || bOneNode ) + return; + + if( bJoinText ) + ++aIdx; + SwTextNode * pTextNd = aIdx.GetNode().GetTextNode(); + SwNodeIndex aNxtIdx( aIdx ); + if( pTextNd && pTextNd->CanJoinNext( &aNxtIdx ) ) { - if( bJoinText ) - ++aIdx; - SwTextNode * pTextNd = aIdx.GetNode().GetTextNode(); - SwNodeIndex aNxtIdx( aIdx ); - if( pTextNd && pTextNd->CanJoinNext( &aNxtIdx ) ) - { - { // Block so SwIndex into node is deleted before Join - m_rDoc.CorrRel( aNxtIdx, SwPosition( aIdx, SwIndex(pTextNd, - pTextNd->GetText().getLength()) ), 0, true ); - } - pTextNd->JoinNext(); + { // Block so SwIndex into node is deleted before Join + m_rDoc.CorrRel( aNxtIdx, SwPosition( aIdx, SwIndex(pTextNd, + pTextNd->GetText().getLength()) ), 0, true ); } + pTextNd->JoinNext(); } } diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 82342dfbbb2e..2d799dccc6eb 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -437,36 +437,38 @@ namespace // delete the empty tracked table row (i.e. if it's last tracked deletion was accepted) void lcl_DeleteTrackedTableRow ( const SwPosition* pPos ) { - if ( const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox() ) - { - const SwTableLine* pLine = pBox->GetUpper(); - const SvxPrintItem *pHasTextChangesOnlyProp = - pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); - // empty table row with property "HasTextChangesOnly" = false - if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() && - pLine->IsEmpty() ) - { - SwCursor aCursor( *pPos, nullptr ); - pPos->GetDoc().DeleteRow( aCursor ); - } + const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox(); + if ( !pBox ) + return; + + const SwTableLine* pLine = pBox->GetUpper(); + const SvxPrintItem *pHasTextChangesOnlyProp = + pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); + // empty table row with property "HasTextChangesOnly" = false + if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() && + pLine->IsEmpty() ) + { + SwCursor aCursor( *pPos, nullptr ); + pPos->GetDoc().DeleteRow( aCursor ); } } // at rejection of a deletion in a table, remove the tracking of the table row void lcl_RemoveTrackingOfTableRow( const SwPosition* pPos ) { - if ( const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox() ) + const SwTableBox* pBox = pPos->nNode.GetNode().GetTableBox(); + if ( !pBox ) + return; + + const SwTableLine* pLine = pBox->GetUpper(); + const SvxPrintItem *pHasTextChangesOnlyProp = + pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); + // table row property "HasTextChangesOnly" is set and its value is false + if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() ) { - const SwTableLine* pLine = pBox->GetUpper(); - const SvxPrintItem *pHasTextChangesOnlyProp = - pLine->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); - // table row property "HasTextChangesOnly" is set and its value is false - if ( pHasTextChangesOnlyProp && !pHasTextChangesOnlyProp->GetValue() ) - { - SvxPrintItem aUnsetTracking(RES_PRINT, true); - SwCursor aCursor( *pPos, nullptr ); - pPos->GetDoc().SetRowNotTracked( aCursor, aUnsetTracking ); - } + SvxPrintItem aUnsetTracking(RES_PRINT, true); + SwCursor aCursor( *pPos, nullptr ); + pPos->GetDoc().SetRowNotTracked( aCursor, aUnsetTracking ); } } diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 644d360bc6bf..60b8d82e7aa2 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1180,39 +1180,39 @@ void SwDoc::ReplaceNumRule( const SwPosition& rPos, { SwNumRule *pOldRule = FindNumRulePtr( rOldRule ), *pNewRule = FindNumRulePtr( rNewRule ); - if( pOldRule && pNewRule && pOldRule != pNewRule ) + if( !pOldRule || !pNewRule || pOldRule == pNewRule ) + return; + + SwUndoInsNum* pUndo = nullptr; + if (GetIDocumentUndoRedo().DoesUndo()) { - SwUndoInsNum* pUndo = nullptr; - if (GetIDocumentUndoRedo().DoesUndo()) - { - // Start/End for attributes! - GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr ); - pUndo = new SwUndoInsNum( rPos, *pNewRule, rOldRule ); - GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo)); - } + // Start/End for attributes! + GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr ); + pUndo = new SwUndoInsNum( rPos, *pNewRule, rOldRule ); + GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo)); + } - SwNumRule::tTextNodeList aTextNodeList; - pOldRule->GetTextNodeList( aTextNodeList ); - if ( !aTextNodeList.empty() ) - { - SwRegHistory aRegH( pUndo ? pUndo->GetHistory() : nullptr ); + SwNumRule::tTextNodeList aTextNodeList; + pOldRule->GetTextNodeList( aTextNodeList ); + if ( !aTextNodeList.empty() ) + { + SwRegHistory aRegH( pUndo ? pUndo->GetHistory() : nullptr ); - const SwTextNode* pGivenTextNode = rPos.nNode.GetNode().GetTextNode(); - SwNumRuleItem aRule( rNewRule ); - for ( SwTextNode* pTextNd : aTextNodeList ) + const SwTextNode* pGivenTextNode = rPos.nNode.GetNode().GetTextNode(); + SwNumRuleItem aRule( rNewRule ); + for ( SwTextNode* pTextNd : aTextNodeList ) + { + if ( pGivenTextNode && + pGivenTextNode->GetListId() == pTextNd->GetListId() ) { - if ( pGivenTextNode && - pGivenTextNode->GetListId() == pTextNd->GetListId() ) - { - aRegH.RegisterInModify( pTextNd, *pTextNd ); + aRegH.RegisterInModify( pTextNd, *pTextNd ); - pTextNd->SetAttr( aRule ); - pTextNd->NumRuleChgd(); - } + pTextNd->SetAttr( aRule ); + pTextNd->NumRuleChgd(); } - GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); - getIDocumentState().SetModified(); } + GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr ); + getIDocumentState().SetModified(); } } diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index f00e49883b4d..d6b49f81df75 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -1422,19 +1422,19 @@ void SwTextBoxNode::AddTextBox(SdrObject* pDrawObject, SwFrameFormat* pNewTextBo void SwTextBoxNode::DelTextBox(const SdrObject* pDrawObject) { assert(pDrawObject); - if (!m_pTextBoxes.empty()) + if (m_pTextBoxes.empty()) + return; + + for (auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end();) { - for (auto it = m_pTextBoxes.begin(); it != m_pTextBoxes.end();) + if (it->m_pDrawObject == pDrawObject) { - if (it->m_pDrawObject == pDrawObject) - { - m_pOwnerShapeFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat( - it->m_pTextBoxFormat); - it = m_pTextBoxes.erase(it); - break; - } - ++it; + m_pOwnerShapeFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat( + it->m_pTextBoxFormat); + it = m_pTextBoxes.erase(it); + break; } + ++it; } } diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 76c961168110..9d25671ee56a 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2547,23 +2547,23 @@ SwFrameFormat::~SwFrameFormat() } } - if( nullptr != m_pOtherTextBoxFormat ) + if( nullptr == m_pOtherTextBoxFormat ) + return; + + auto pObj = FindRealSdrObject(); + if (Which() == RES_FLYFRMFMT && pObj) { - auto pObj = FindRealSdrObject(); - if (Which() == RES_FLYFRMFMT && pObj) - { - // This is a fly-frame-format just delete this - // textbox entry from the draw-frame-format. - m_pOtherTextBoxFormat->DelTextBox(pObj); - } + // This is a fly-frame-format just delete this + // textbox entry from the draw-frame-format. + m_pOtherTextBoxFormat->DelTextBox(pObj); + } - if (Which() == RES_DRAWFRMFMT) - { - // This format is the owner shape, so its time - // to del the textbox node. - delete m_pOtherTextBoxFormat; - m_pOtherTextBoxFormat = nullptr; - } + if (Which() == RES_DRAWFRMFMT) + { + // This format is the owner shape, so its time + // to del the textbox node. + delete m_pOtherTextBoxFormat; + m_pOtherTextBoxFormat = nullptr; } } diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 1380e886fed5..5e80f7cb1b30 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -627,70 +627,70 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) SetRedline( bHasRedline ); // redlining: set crossing out for deleted anchored objects - if ( bHasFlyPortion ) + if ( !bHasFlyPortion ) + return; + + SwLinePortion *pPos = mpNextPortion; + TextFrameIndex nLineLength; + while ( pPos ) { - SwLinePortion *pPos = mpNextPortion; - TextFrameIndex nLineLength; - while ( pPos ) + TextFrameIndex const nPorSttIdx = rInf.GetLineStart() + nLineLength; + nLineLength += pPos->GetLen(); + // anchored as characters + if( pPos->IsFlyCntPortion() ) { - TextFrameIndex const nPorSttIdx = rInf.GetLineStart() + nLineLength; - nLineLength += pPos->GetLen(); - // anchored as characters - if( pPos->IsFlyCntPortion() ) + bool bDeleted = false; + size_t nAuthor = std::string::npos; + if ( bHasRedline ) { - bool bDeleted = false; - size_t nAuthor = std::string::npos; - if ( bHasRedline ) - { - OUString sRedlineText; - bool bHasRedlineEnd; - enum RedlineType eRedlineEnd; - std::pair<SwTextNode const*, sal_Int32> const flyStart( - rInf.GetTextFrame()->MapViewToModel(nPorSttIdx)); - bool bHasFlyRedline = rLine.GetRedln()->CheckLine(flyStart.first->GetIndex(), - flyStart.second, flyStart.first->GetIndex(), flyStart.second, sRedlineText, - bHasRedlineEnd, eRedlineEnd, /*pAuthorAtPos=*/&nAuthor); - bDeleted = bHasFlyRedline && eRedlineEnd == RedlineType::Delete; - } - static_cast<SwFlyCntPortion*>(pPos)->SetDeleted(bDeleted); - static_cast<SwFlyCntPortion*>(pPos)->SetAuthor(nAuthor); + OUString sRedlineText; + bool bHasRedlineEnd; + enum RedlineType eRedlineEnd; + std::pair<SwTextNode const*, sal_Int32> const flyStart( + rInf.GetTextFrame()->MapViewToModel(nPorSttIdx)); + bool bHasFlyRedline = rLine.GetRedln()->CheckLine(flyStart.first->GetIndex(), + flyStart.second, flyStart.first->GetIndex(), flyStart.second, sRedlineText, + bHasRedlineEnd, eRedlineEnd, /*pAuthorAtPos=*/&nAuthor); + bDeleted = bHasFlyRedline && eRedlineEnd == RedlineType::Delete; } - // anchored to characters - else if ( pPos->IsFlyPortion() ) + static_cast<SwFlyCntPortion*>(pPos)->SetDeleted(bDeleted); + static_cast<SwFlyCntPortion*>(pPos)->SetAuthor(nAuthor); + } + // anchored to characters + else if ( pPos->IsFlyPortion() ) + { + const IDocumentRedlineAccess& rIDRA = + rInf.GetTextFrame()->GetDoc().getIDocumentRedlineAccess(); + SwSortedObjs *pObjs = rInf.GetTextFrame()->GetDrawObjs(); + if ( pObjs && IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) ) { - const IDocumentRedlineAccess& rIDRA = - rInf.GetTextFrame()->GetDoc().getIDocumentRedlineAccess(); - SwSortedObjs *pObjs = rInf.GetTextFrame()->GetDrawObjs(); - if ( pObjs && IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) ) + for ( size_t i = 0; rInf.GetTextFrame()->GetDrawObjs() && i < pObjs->size(); ++i ) { - for ( size_t i = 0; rInf.GetTextFrame()->GetDrawObjs() && i < pObjs->size(); ++i ) + SwAnchoredObject* pAnchoredObj = (*rInf.GetTextFrame()->GetDrawObjs())[i]; + if ( auto pFly = pAnchoredObj->DynCastFlyFrame() ) { - SwAnchoredObject* pAnchoredObj = (*rInf.GetTextFrame()->GetDrawObjs())[i]; - if ( auto pFly = pAnchoredObj->DynCastFlyFrame() ) + bool bDeleted = false; + size_t nAuthor = std::string::npos; + const SwFormatAnchor& rAnchor = pAnchoredObj->GetFrameFormat().GetAnchor(); + if ( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR ) { - bool bDeleted = false; - size_t nAuthor = std::string::npos; - const SwFormatAnchor& rAnchor = pAnchoredObj->GetFrameFormat().GetAnchor(); - if ( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR ) + SwPosition aAnchor = *rAnchor.GetContentAnchor(); + SwRedlineTable::size_type n = 0; + const SwRangeRedline* pFnd = + rIDRA.GetRedlineTable().FindAtPosition( aAnchor, n ); + if ( pFnd && RedlineType::Delete == pFnd->GetType() ) { - SwPosition aAnchor = *rAnchor.GetContentAnchor(); - SwRedlineTable::size_type n = 0; - const SwRangeRedline* pFnd = - rIDRA.GetRedlineTable().FindAtPosition( aAnchor, n ); - if ( pFnd && RedlineType::Delete == pFnd->GetType() ) - { - bDeleted = true; - nAuthor = pFnd->GetAuthor(); - } + bDeleted = true; + nAuthor = pFnd->GetAuthor(); } - pFly->SetDeleted(bDeleted); - pFly->SetAuthor(nAuthor); } + pFly->SetDeleted(bDeleted); + pFly->SetAuthor(nAuthor); } } } - pPos = pPos->GetNextPortion(); } + pPos = pPos->GetNextPortion(); } } diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 95ec669dddcc..c762056c30fe 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -120,34 +120,34 @@ void SwBreakPortion::Paint( const SwTextPaintInfo &rInf ) const rInf.DrawLineBreak( *this ); // paint redlining - if (m_eRedline != RedlineType::None) + if (m_eRedline == RedlineType::None) + return; + + sal_Int16 nNoBreakWidth = rInf.GetTextSize(S_NOBREAK_FOR_REDLINE).Width(); + if ( nNoBreakWidth > 0 ) { - sal_Int16 nNoBreakWidth = rInf.GetTextSize(S_NOBREAK_FOR_REDLINE).Width(); - if ( nNoBreakWidth > 0 ) - { - // approximate portion size with multiple no-break spaces - // and draw these spaces (at least a single one) by DrawText - // painting the requested redline underline/strikeout - sal_Int16 nSpaces = (LINE_BREAK_WIDTH + nNoBreakWidth/2) / nNoBreakWidth; - OUStringBuffer aBuf(S_NOBREAK_FOR_REDLINE); - for (sal_Int16 i = 1; i < nSpaces; ++i) - aBuf.append(S_NOBREAK_FOR_REDLINE); + // approximate portion size with multiple no-break spaces + // and draw these spaces (at least a single one) by DrawText + // painting the requested redline underline/strikeout + sal_Int16 nSpaces = (LINE_BREAK_WIDTH + nNoBreakWidth/2) / nNoBreakWidth; + OUStringBuffer aBuf(S_NOBREAK_FOR_REDLINE); + for (sal_Int16 i = 1; i < nSpaces; ++i) + aBuf.append(S_NOBREAK_FOR_REDLINE); - const SwFont* pOldFnt = rInf.GetFont(); + const SwFont* pOldFnt = rInf.GetFont(); - SwFont aFont(*pOldFnt); + SwFont aFont(*pOldFnt); - if (m_eRedline == RedlineType::Delete) - aFont.SetUnderline( LINESTYLE_NONE ); - else - aFont.SetStrikeout( STRIKEOUT_NONE ); + if (m_eRedline == RedlineType::Delete) + aFont.SetUnderline( LINESTYLE_NONE ); + else + aFont.SetStrikeout( STRIKEOUT_NONE ); - const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont); + const_cast<SwTextPaintInfo&>(rInf).SetFont(&aFont); - rInf.DrawText(aBuf.makeStringAndClear(), *this); + rInf.DrawText(aBuf.makeStringAndClear(), *this); - const_cast<SwTextPaintInfo&>(rInf).SetFont(const_cast<SwFont*>(pOldFnt)); - } + const_cast<SwTextPaintInfo&>(rInf).SetFont(const_cast<SwFont*>(pOldFnt)); } } diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 05d10a2aae40..c9ced5ea7a1d 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -376,35 +376,35 @@ void SwFormatField::UpdateTextNode(const SfxPoolItem* pOld, const SfxPoolItem* p } if(bTriggerNode) pTextNd->TriggerNodeUpdate(sw::LegacyModifyHint(pNodeOld, pNodeNew)); - if(bExpand) + if(!bExpand) + return; + + bool bForceNotify = pOld == nullptr && pNew == nullptr; + if (bForceNotify) { - bool bForceNotify = pOld == nullptr && pNew == nullptr; - if (bForceNotify) + // Force notify was added for conditional text fields, at least the below fields need + // no forced notify. + const SwField* pField = mpTextField->GetFormatField().GetField(); + const SwFieldIds nWhich = pField->GetTyp()->Which(); + if (nWhich == SwFieldIds::DocInfo) { - // Force notify was added for conditional text fields, at least the below fields need - // no forced notify. - const SwField* pField = mpTextField->GetFormatField().GetField(); - const SwFieldIds nWhich = pField->GetTyp()->Which(); - if (nWhich == SwFieldIds::DocInfo) ... etc. - the rest is truncated