diff options
77 files changed, 2465 insertions, 2461 deletions
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) + auto pDocInfoField = static_cast<const SwDocInfoField*>(pField); + sal_uInt16 nSubType = pDocInfoField->GetSubType(); + // Do not consider extended SubTypes. + nSubType &= 0xff; + switch (nSubType) { - auto pDocInfoField = static_cast<const SwDocInfoField*>(pField); - sal_uInt16 nSubType = pDocInfoField->GetSubType(); - // Do not consider extended SubTypes. - nSubType &= 0xff; - switch (nSubType) - { - case nsSwDocInfoSubType::DI_TITLE: - case nsSwDocInfoSubType::DI_SUBJECT: - case nsSwDocInfoSubType::DI_CHANGE: - case nsSwDocInfoSubType::DI_CUSTOM: - bForceNotify = false; - break; - } + case nsSwDocInfoSubType::DI_TITLE: + case nsSwDocInfoSubType::DI_SUBJECT: + case nsSwDocInfoSubType::DI_CHANGE: + case nsSwDocInfoSubType::DI_CUSTOM: + bForceNotify = false; + break; } } - - mpTextField->ExpandTextField(bForceNotify); } + + mpTextField->ExpandTextField(bForceNotify); } bool SwFormatField::GetInfo( SfxPoolItem& rInfo ) const diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index dcf25fadde59..4c35a9248665 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1416,10 +1416,9 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& if (!pEntry) { // Hack to skip the dummy CursorNotIgnoreTables property - if (rPropertyName == "CursorNotIgnoreTables") - return; - else + if (rPropertyName != "CursorNotIgnoreTables") throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast <cppu::OWeakObject*> (this)); + return; } const sal_uInt8 nMemberId(pEntry->nMemberId); diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 6c7d9003ceb3..fc7bf6edbc80 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -1757,32 +1757,32 @@ static Writer& OutHTML_FrameFormatAsDivOrSpan( Writer& rWrt, static void OutHTML_ImageOLEStart(SwHTMLWriter& rHTMLWrt, const Graphic& rGraphic, const SwFrameFormat& rFrameFormat) { - if (rHTMLWrt.mbReqIF && rHTMLWrt.m_bExportImagesAsOLE) - { - // Write the original image as an RTF fragment. - OUString aFileName; - if (rHTMLWrt.GetOrigFileName()) - aFileName = *rHTMLWrt.GetOrigFileName(); - INetURLObject aURL(aFileName); - OUString aName = aURL.getBase() + "_" + aURL.getExtension() + "_" - + OUString::number(rGraphic.GetChecksum(), 16); - aURL.setBase(aName); - aURL.setExtension(u"ole"); - aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); - - SvFileStream aOutStream(aFileName, StreamMode::WRITE); - if (!SwReqIfReader::WrapGraphicInRtf(rGraphic, rFrameFormat, aOutStream)) - SAL_WARN("sw.html", "SwReqIfReader::WrapGraphicInRtf() failed"); - - // Refer to this data. - aFileName = URIHelper::simpleNormalizedMakeRelative(rHTMLWrt.GetBaseURL(), aFileName); - rHTMLWrt.Strm().WriteOString( - OStringConcatenation("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object)); - rHTMLWrt.Strm().WriteOString(OStringConcatenation(" data=\"" + aFileName.toUtf8() + "\"")); - rHTMLWrt.Strm().WriteOString(" type=\"text/rtf\""); - rHTMLWrt.Strm().WriteOString(">"); - rHTMLWrt.OutNewLine(); - } + if (!rHTMLWrt.mbReqIF || !rHTMLWrt.m_bExportImagesAsOLE) + return; + + // Write the original image as an RTF fragment. + OUString aFileName; + if (rHTMLWrt.GetOrigFileName()) + aFileName = *rHTMLWrt.GetOrigFileName(); + INetURLObject aURL(aFileName); + OUString aName = aURL.getBase() + "_" + aURL.getExtension() + "_" + + OUString::number(rGraphic.GetChecksum(), 16); + aURL.setBase(aName); + aURL.setExtension(u"ole"); + aFileName = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); + + SvFileStream aOutStream(aFileName, StreamMode::WRITE); + if (!SwReqIfReader::WrapGraphicInRtf(rGraphic, rFrameFormat, aOutStream)) + SAL_WARN("sw.html", "SwReqIfReader::WrapGraphicInRtf() failed"); + + // Refer to this data. + aFileName = URIHelper::simpleNormalizedMakeRelative(rHTMLWrt.GetBaseURL(), aFileName); + rHTMLWrt.Strm().WriteOString( + OStringConcatenation("<" + rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_object)); + rHTMLWrt.Strm().WriteOString(OStringConcatenation(" data=\"" + aFileName.toUtf8() + "\"")); + rHTMLWrt.Strm().WriteOString(" type=\"text/rtf\""); + rHTMLWrt.Strm().WriteOString(">"); + rHTMLWrt.OutNewLine(); } /// Ends the OLE version of an image in the ReqIF + OLE case. diff --git a/sw/source/filter/indexing/IndexingExport.cxx b/sw/source/filter/indexing/IndexingExport.cxx index e4532aaf6f34..97e90b08bc89 100644 --- a/sw/source/filter/indexing/IndexingExport.cxx +++ b/sw/source/filter/indexing/IndexingExport.cxx @@ -120,24 +120,24 @@ public: m_rXmlWriter.endElement(); SdrTextObj* pTextObject = dynamic_cast<SdrTextObj*>(pObject); - if (pTextObject) + if (!pTextObject) + return; + + OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject(); + if (!pOutlinerParagraphObject) + return; + + const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject(); + for (sal_Int32 nParagraph = 0; nParagraph < aEdit.GetParagraphCount(); ++nParagraph) { - OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject(); - if (pOutlinerParagraphObject) - { - const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject(); - for (sal_Int32 nParagraph = 0; nParagraph < aEdit.GetParagraphCount(); ++nParagraph) - { - OUString sText = aEdit.GetText(nParagraph); - - m_rXmlWriter.startElement("paragraph"); - m_rXmlWriter.attribute("index", nParagraph); - m_rXmlWriter.attribute("node_type", "common"); - m_rXmlWriter.attribute("object_name", pObject->GetName()); - m_rXmlWriter.content(sText); - m_rXmlWriter.endElement(); - } - } + OUString sText = aEdit.GetText(nParagraph); + + m_rXmlWriter.startElement("paragraph"); + m_rXmlWriter.attribute("index", nParagraph); + m_rXmlWriter.attribute("node_type", "common"); + m_rXmlWriter.attribute("object_name", pObject->GetName()); + m_rXmlWriter.content(sText); + m_rXmlWriter.endElement(); } } diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index f8bf63264e62..44b43a1f864d 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -1766,28 +1766,28 @@ void SwWW8ImplReader::RegisterNumFormatOnStyle(sal_uInt16 nStyle) rStyleInf.maWordLR.reset(ItemGet<SvxLRSpaceItem>(*rStyleInf.m_pFormat, RES_LR_SPACE).Clone()); // Phase 2: refresh StyleDef after reading all Lists - if (rStyleInf.m_nLFOIndex < USHRT_MAX && rStyleInf.m_nListLevel < WW8ListManager::nMaxLevel) - { - std::vector<sal_uInt8> aParaSprms; - SwNumRule* pNmRule = m_xLstManager->GetNumRuleForActivation( - rStyleInf.m_nLFOIndex, rStyleInf.m_nListLevel, aParaSprms); + if (rStyleInf.m_nLFOIndex >= USHRT_MAX || rStyleInf.m_nListLevel >= WW8ListManager::nMaxLevel) + return; - if (pNmRule != nullptr) - { - if (rStyleInf.IsWW8BuiltInHeadingStyle() - && rStyleInf.HasWW8OutlineLevel()) - { - rStyleInf.m_pOutlineNumrule = pNmRule; - } - else - { - rStyleInf.m_pFormat->SetFormatAttr( - SwNumRuleItem(pNmRule->GetName())); - rStyleInf.m_bHasStyNumRule = true; - } + std::vector<sal_uInt8> aParaSprms; + SwNumRule* pNmRule = m_xLstManager->GetNumRuleForActivation( + rStyleInf.m_nLFOIndex, rStyleInf.m_nListLevel, aParaSprms); - SetStyleIndent(rStyleInf, pNmRule->Get(rStyleInf.m_nListLevel)); + if (pNmRule != nullptr) + { + if (rStyleInf.IsWW8BuiltInHeadingStyle() + && rStyleInf.HasWW8OutlineLevel()) + { + rStyleInf.m_pOutlineNumrule = pNmRule; } + else + { + rStyleInf.m_pFormat->SetFormatAttr( + SwNumRuleItem(pNmRule->GetName())); + rStyleInf.m_bHasStyNumRule = true; + } + + SetStyleIndent(rStyleInf, pNmRule->Get(rStyleInf.m_nListLevel)); } } diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx index 36986ba59f5e..cd46d6b386eb 100644 --- a/sw/source/uibase/dbui/mmconfigitem.cxx +++ b/sw/source/uibase/dbui/mmconfigitem.cxx @@ -330,18 +330,18 @@ SwMailMergeConfigItem_Impl::SwMailMergeConfigItem_Impl() : } } //check if the saved documents still exist - if(m_aSavedDocuments.hasElements()) - { - uno::Sequence< OUString > aTempDocuments(m_aSavedDocuments.getLength()); - auto begin = aTempDocuments.getArray(); - OUString* pTempDocuments = std::copy_if(std::cbegin(m_aSavedDocuments), std::cend(m_aSavedDocuments), begin, - [](const OUString& rDoc) { return SWUnoHelper::UCB_IsFile( rDoc ); }); - sal_Int32 nIndex = static_cast<sal_Int32>(std::distance(begin, pTempDocuments)); - if(nIndex < m_aSavedDocuments.getLength()) - { - m_aSavedDocuments.swap(aTempDocuments); - m_aSavedDocuments.realloc(nIndex); - } + if(!m_aSavedDocuments.hasElements()) + return; + + uno::Sequence< OUString > aTempDocuments(m_aSavedDocuments.getLength()); + auto begin = aTempDocuments.getArray(); + OUString* pTempDocuments = std::copy_if(std::cbegin(m_aSavedDocuments), std::cend(m_aSavedDocuments), begin, + [](const OUString& rDoc) { return SWUnoHelper::UCB_IsFile( rDoc ); }); + sal_Int32 nIndex = static_cast<sal_Int32>(std::distance(begin, pTempDocuments)); + if(nIndex < m_aSavedDocuments.getLength()) + { + m_aSavedDocuments.swap(aTempDocuments); + m_aSavedDocuments.realloc(nIndex); } } diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx index f520501c13f1..df1636ea510c 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx @@ -251,23 +251,23 @@ void SidebarTextControl::Paint(vcl::RenderContext& rRenderContext, const tools:: DoPaint(rRenderContext, rRect); - if (mrSidebarWin.GetLayoutStatus() == SwPostItHelper::DELETED) - { - const AntialiasingFlags nFormerAntialiasing( rRenderContext.GetAntialiasing() ); - const bool bIsAntiAliasing = officecfg::Office::Common::Drawinglayer::AntiAliasing::get(); - if ( bIsAntiAliasing ) - rRenderContext.SetAntialiasing(AntialiasingFlags::Enable); - rRenderContext.SetLineColor(mrSidebarWin.GetChangeColor()); - rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos), - rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), - aSize.Height() * 0.95))); - rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), - 0)), - rRenderContext.PixelToLogic(aPos + Point(0, - aSize.Height() * 0.95))); - if ( bIsAntiAliasing ) - rRenderContext.SetAntialiasing(nFormerAntialiasing); - } + if (mrSidebarWin.GetLayoutStatus() != SwPostItHelper::DELETED) + return; + + const AntialiasingFlags nFormerAntialiasing( rRenderContext.GetAntialiasing() ); + const bool bIsAntiAliasing = officecfg::Office::Common::Drawinglayer::AntiAliasing::get(); + if ( bIsAntiAliasing ) + rRenderContext.SetAntialiasing(AntialiasingFlags::Enable); + rRenderContext.SetLineColor(mrSidebarWin.GetChangeColor()); + rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos), + rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), + aSize.Height() * 0.95))); + rRenderContext.DrawLine(rRenderContext.PixelToLogic(aPos + Point(aSize.Width(), + 0)), + rRenderContext.PixelToLogic(aPos + Point(0, + aSize.Height() * 0.95))); + if ( bIsAntiAliasing ) + rRenderContext.SetAntialiasing(nFormerAntialiasing); } void SidebarTextControl::MakeVisible() diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx index bd7274bde397..48c2de119311 100644 --- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx +++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx @@ -387,30 +387,29 @@ static void MetadataToTreeNode(const css::uno::Reference<css::uno::XInterface>& { uno::Reference<rdf::XMetadatable> xMeta(rSource, uno::UNO_QUERY_THROW); // don't add tree node "Metadata Reference", if there is no xml:id - if (xMeta.is() && !xMeta->getMetadataReference().Second.isEmpty()) - { - svx::sidebar::TreeNode aCurNode; - aCurNode.sNodeName = PropertyNametoRID("MetadataReference"); - aCurNode.NodeType = svx::sidebar::TreeNode::ComplexProperty; - - aCurNode.children.push_back( - SimplePropToTreeNode("xml:id", uno::makeAny(xMeta->getMetadataReference().Second))); - - // list associated (predicate, object) pairs of the actual subject - // under the tree node "Metadata Reference" - SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current()); - uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(pDocSh->GetBaseModel(), - uno::UNO_QUERY); - const uno::Reference<rdf::XRepository>& xRepo = xDocumentMetadataAccess->getRDFRepository(); - const css::uno::Reference<css::rdf::XResource> xSubject(rSource, uno::UNO_QUERY); - std::map<OUString, OUString> xStatements - = SwRDFHelper::getStatements(pDocSh->GetBaseModel(), xRepo->getGraphNames(), xSubject); - for (const auto& pair : xStatements) - aCurNode.children.push_back( - SimplePropToTreeNode(pair.first, uno::makeAny(pair.second))); - - rNode.children.push_back(aCurNode); - } + if (!xMeta.is() || xMeta->getMetadataReference().Second.isEmpty()) + return; + + svx::sidebar::TreeNode aCurNode; + aCurNode.sNodeName = PropertyNametoRID("MetadataReference"); + aCurNode.NodeType = svx::sidebar::TreeNode::ComplexProperty; + + aCurNode.children.push_back( + SimplePropToTreeNode("xml:id", uno::makeAny(xMeta->getMetadataReference().Second))); + + // list associated (predicate, object) pairs of the actual subject + // under the tree node "Metadata Reference" + SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current()); + uno::Reference<rdf::XDocumentMetadataAccess> xDocumentMetadataAccess(pDocSh->GetBaseModel(), + uno::UNO_QUERY); + const uno::Reference<rdf::XRepository>& xRepo = xDocumentMetadataAccess->getRDFRepository(); + const css::uno::Reference<css::rdf::XResource> xSubject(rSource, uno::UNO_QUERY); + std::map<OUString, OUString> xStatements + = SwRDFHelper::getStatements(pDocSh->GetBaseModel(), xRepo->getGraphNames(), xSubject); + for (const auto& pair : xStatements) + aCurNode.children.push_back(SimplePropToTreeNode(pair.first, uno::makeAny(pair.second))); + + rNode.children.push_back(aCurNode); } static svx::sidebar::TreeNode diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 34588eee0dbe..3e91ee202e21 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -3378,64 +3378,64 @@ static void lcl_SelectByContentTypeAndAddress(SwContentTree* pThis, weld::TreeVi bFoundEntry = rContentTree.iter_next_sibling(*xIter); } - if (bFoundEntry) - { - // assure content type entry is expanded - rContentTree.expand_row(*xIter); + if (!bFoundEntry) + return; - // find content type content entry and select it - const void* p = nullptr; - while (rContentTree.iter_next(*xIter) && lcl_IsContent(*xIter, rContentTree)) + // assure content type entry is expanded + rContentTree.expand_row(*xIter); + + // find content type content entry and select it + const void* p = nullptr; + while (rContentTree.iter_next(*xIter) && lcl_IsContent(*xIter, rContentTree)) + { + void* pUserData = reinterpret_cast<void*>(rContentTree.get_id(*xIter).toInt64()); + switch( nType ) { - void* pUserData = reinterpret_cast<void*>(rContentTree.get_id(*xIter).toInt64()); - switch( nType ) + case ContentTypeId::FOOTNOTE: { - case ContentTypeId::FOOTNOTE: - { - assert(dynamic_cast<SwTextFootnoteContent*>(static_cast<SwTypeNumber*>(pUserData))); - SwTextFootnoteContent* pCnt = static_cast<SwTextFootnoteContent*>(pUserData); - p = pCnt->GetTextFootnote(); - break; - } - case ContentTypeId::URLFIELD: - { - assert(dynamic_cast<SwURLFieldContent*>(static_cast<SwTypeNumber*>(pUserData))); - SwURLFieldContent* pCnt = static_cast<SwURLFieldContent*>(pUserData); - p = static_cast<const SwTextAttr*>(pCnt->GetINetAttr()); - break; - } - case ContentTypeId::TEXTFIELD: - { - assert(dynamic_cast<SwTextFieldContent*>(static_cast<SwTypeNumber*>(pUserData))); - SwTextFieldContent* pCnt = static_cast/*reinterpret_cast*/<SwTextFieldContent*>(pUserData); - p = pCnt->GetFormatField()->GetField(); - break; - } - case ContentTypeId::POSTIT: - { - assert(dynamic_cast<SwPostItContent*>(static_cast<SwTypeNumber*>(pUserData))); - SwPostItContent* pCnt = static_cast<SwPostItContent*>(pUserData); - p = pCnt->GetPostIt()->GetField(); - break; - } - default: - break; + assert(dynamic_cast<SwTextFootnoteContent*>(static_cast<SwTypeNumber*>(pUserData))); + SwTextFootnoteContent* pCnt = static_cast<SwTextFootnoteContent*>(pUserData); + p = pCnt->GetTextFootnote(); + break; } - if (ptr == p) + case ContentTypeId::URLFIELD: { - // get first selected for comparison - std::unique_ptr<weld::TreeIter> xFirstSelected(rContentTree.make_iterator()); - if (!rContentTree.get_selected(xFirstSelected.get())) - xFirstSelected.reset(); - if (rContentTree.count_selected_rows() != 1 || - rContentTree.iter_compare(*xIter, *xFirstSelected) != 0) - { - // unselect all entries and make passed entry visible and selected - rContentTree.set_cursor(*xIter); - pThis->Select(); - } - return; + assert(dynamic_cast<SwURLFieldContent*>(static_cast<SwTypeNumber*>(pUserData))); + SwURLFieldContent* pCnt = static_cast<SwURLFieldContent*>(pUserData); + p = static_cast<const SwTextAttr*>(pCnt->GetINetAttr()); + break; + } + case ContentTypeId::TEXTFIELD: + { + assert(dynamic_cast<SwTextFieldContent*>(static_cast<SwTypeNumber*>(pUserData))); + SwTextFieldContent* pCnt = static_cast/*reinterpret_cast*/<SwTextFieldContent*>(pUserData); + p = pCnt->GetFormatField()->GetField(); + break; + } + case ContentTypeId::POSTIT: + { + assert(dynamic_cast<SwPostItContent*>(static_cast<SwTypeNumber*>(pUserData))); + SwPostItContent* pCnt = static_cast<SwPostItContent*>(pUserData); + p = pCnt->GetPostIt()->GetField(); + break; } + default: + break; + } + if (ptr == p) + { + // get first selected for comparison + std::unique_ptr<weld::TreeIter> xFirstSelected(rContentTree.make_iterator()); + if (!rContentTree.get_selected(xFirstSelected.get())) + xFirstSelected.reset(); + if (rContentTree.count_selected_rows() != 1 || + rContentTree.iter_compare(*xIter, *xFirstSelected) != 0) + { + // unselect all entries and make passed entry visible and selected + rContentTree.set_cursor(*xIter); + pThis->Select(); + } + return; } } } @@ -3452,26 +3452,26 @@ static void lcl_SelectByContentTypeAndName(SwContentTree* pThis, weld::TreeView& while (bFoundEntry && rContentTypeName != rContentTree.get_text(*xIter)) bFoundEntry = rContentTree.iter_next_sibling(*xIter); // find content type content entry and select it - if (bFoundEntry) + if (!bFoundEntry) + return; + + rContentTree.expand_row(*xIter); // assure content type entry is expanded + while (rContentTree.iter_next(*xIter) && lcl_IsContent(*xIter, rContentTree)) { - rContentTree.expand_row(*xIter); // assure content type entry is expanded - while (rContentTree.iter_next(*xIter) && lcl_IsContent(*xIter, rContentTree)) + if (rName == rContentTree.get_text(*xIter)) { - if (rName == rContentTree.get_text(*xIter)) + // get first selected for comparison + std::unique_ptr<weld::TreeIter> xFirstSelected(rContentTree.make_iterator()); + if (!rContentTree.get_selected(xFirstSelected.get())) + xFirstSelected.reset(); + if (rContentTree.count_selected_rows() != 1 || + rContentTree.iter_compare(*xIter, *xFirstSelected) != 0) { - // get first selected for comparison - std::unique_ptr<weld::TreeIter> xFirstSelected(rContentTree.make_iterator()); - if (!rContentTree.get_selected(xFirstSelected.get())) - xFirstSelected.reset(); - if (rContentTree.count_selected_rows() != 1 || - rContentTree.iter_compare(*xIter, *xFirstSelected) != 0) - { - // unselect all entries and make passed entry visible and selected - rContentTree.set_cursor(*xIter); - pThis->Select(); - } - break; + // unselect all entries and make passed entry visible and selected + rContentTree.set_cursor(*xIter); + pThis->Select(); } + break; } } } diff --git a/sw/source/uibase/utlui/gotodlg.cxx b/sw/source/uibase/utlui/gotodlg.cxx index 050f6507bfc8..9ab0d366db35 100644 --- a/sw/source/uibase/utlui/gotodlg.cxx +++ b/sw/source/uibase/utlui/gotodlg.cxx @@ -49,19 +49,19 @@ SwGotoPageDlg::SwGotoPageDlg(weld::Window* pParent, SfxBindings* _pBindings) IMPL_LINK_NOARG(SwGotoPageDlg, PageModifiedHdl, weld::Entry&, void) { - if (!mxMtrPageCtrl->get_text().isEmpty()) - { - int page_value = mxMtrPageCtrl->get_text().toInt32(); + if (mxMtrPageCtrl->get_text().isEmpty()) + return; - if (page_value <= 0) - mxMtrPageCtrl->set_value(1); - else if (page_value > mnMaxPageCnt) - mxMtrPageCtrl->set_value(mnMaxPageCnt); - else - mxMtrPageCtrl->set_value(page_value); + int page_value = mxMtrPageCtrl->get_text().toInt32(); - mxMtrPageCtrl->set_position(-1); - } + if (page_value <= 0) + mxMtrPageCtrl->set_value(1); + else if (page_value > mnMaxPageCnt) + mxMtrPageCtrl->set_value(mnMaxPageCnt); + else + mxMtrPageCtrl->set_value(page_value); + + mxMtrPageCtrl->set_position(-1); } SwView* SwGotoPageDlg::GetCreateView() const diff --git a/unoidl/source/unoidl-read.cxx b/unoidl/source/unoidl-read.cxx index e7e82d7a0b86..a458d9b32863 100644 --- a/unoidl/source/unoidl-read.cxx +++ b/unoidl/source/unoidl-read.cxx @@ -158,21 +158,22 @@ void insertEntityDependency( OUString const & name, bool weakInterfaceDependency = false) { assert(manager.is()); - if (name != iterator->first) { - bool ifc = false; - if (weakInterfaceDependency) { - rtl::Reference<unoidl::Entity> ent(manager->findEntity(name)); - if (!ent.is()) { - std::cerr << "Unknown entity " << name << std::endl; - std::exit(EXIT_FAILURE); - } - ifc = ent->getSort() == unoidl::Entity::SORT_INTERFACE_TYPE; + if (name == iterator->first) + return; + + bool ifc = false; + if (weakInterfaceDependency) { + rtl::Reference<unoidl::Entity> ent(manager->findEntity(name)); + if (!ent.is()) { + std::cerr << "Unknown entity " << name << std::endl; + std::exit(EXIT_FAILURE); } - (ifc - ? iterator->second.interfaceDependencies - : iterator->second.dependencies) - .insert(name); + ifc = ent->getSort() == unoidl::Entity::SORT_INTERFACE_TYPE; } + (ifc + ? iterator->second.interfaceDependencies + : iterator->second.dependencies) + .insert(name); } void insertEntityDependencies( @@ -550,201 +551,331 @@ void writeEntity( OUString const & name) { std::map<OUString, Entity>::iterator i(entities.find(name)); - if (i != entities.end() && i->second.relevant) { - assert(i->second.written != Entity::Written::DEFINITION); - i->second.written = Entity::Written::DEFINITION; - for (auto & j: i->second.interfaceDependencies) { - std::map<OUString, Entity>::iterator k(entities.find(j)); - if (k != entities.end() && k->second.written == Entity::Written::NO) { - k->second.written = Entity::Written::DECLARATION; - OUString id(openModulesFor(modules, j)); - if (k->second.entity->getSort() - != unoidl::Entity::SORT_INTERFACE_TYPE) - { - std::cerr - << "Entity " << j << " should be an interface type" - << std::endl; - std::exit(EXIT_FAILURE); - } - writePublished( - static_cast<unoidl::PublishableEntity *>( - k->second.entity.get())); - std::cout << "interface " << id << ";\n"; + if (i == entities.end() || !i->second.relevant) + return; + + assert(i->second.written != Entity::Written::DEFINITION); + i->second.written = Entity::Written::DEFINITION; + for (auto & j: i->second.interfaceDependencies) { + std::map<OUString, Entity>::iterator k(entities.find(j)); + if (k != entities.end() && k->second.written == Entity::Written::NO) { + k->second.written = Entity::Written::DECLARATION; + OUString id(openModulesFor(modules, j)); + if (k->second.entity->getSort() + != unoidl::Entity::SORT_INTERFACE_TYPE) + { + std::cerr + << "Entity " << j << " should be an interface type" + << std::endl; + std::exit(EXIT_FAILURE); } + writePublished( + static_cast<unoidl::PublishableEntity *>( + k->second.entity.get())); + std::cout << "interface " << id << ";\n"; } - OUString id(openModulesFor(modules, name)); - rtl::Reference<unoidl::PublishableEntity> ent( - static_cast<unoidl::PublishableEntity *>(i->second.entity.get())); - switch (ent->getSort()) { - case unoidl::Entity::SORT_ENUM_TYPE: + } + OUString id(openModulesFor(modules, name)); + rtl::Reference<unoidl::PublishableEntity> ent( + static_cast<unoidl::PublishableEntity *>(i->second.entity.get())); + switch (ent->getSort()) { + case unoidl::Entity::SORT_ENUM_TYPE: + { + rtl::Reference<unoidl::EnumTypeEntity> ent2( + static_cast<unoidl::EnumTypeEntity *>(ent.get())); + writeAnnotationsPublished(ent); + std::cout << "enum " << id << " {\n"; + for (auto j(ent2->getMembers().begin()); + j != ent2->getMembers().end(); ++j) { - rtl::Reference<unoidl::EnumTypeEntity> ent2( - static_cast<unoidl::EnumTypeEntity *>(ent.get())); - writeAnnotationsPublished(ent); - std::cout << "enum " << id << " {\n"; - for (auto j(ent2->getMembers().begin()); - j != ent2->getMembers().end(); ++j) - { - indent(modules, 1); - writeAnnotations(j->annotations); - std::cout << j->name << " = " << j->value; - if (j + 1 != ent2->getMembers().end()) { - std::cout << ','; - } - std::cout << '\n'; + indent(modules, 1); + writeAnnotations(j->annotations); + std::cout << j->name << " = " << j->value; + if (j + 1 != ent2->getMembers().end()) { + std::cout << ','; } - indent(modules); - std::cout << "};\n"; - break; + std::cout << '\n'; + } + indent(modules); + std::cout << "};\n"; + break; + } + case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE: + { + rtl::Reference<unoidl::PlainStructTypeEntity> ent2( + static_cast<unoidl::PlainStructTypeEntity *>(ent.get())); + writeAnnotationsPublished(ent); + std::cout << "struct " << id; + if (!ent2->getDirectBase().isEmpty()) { + std::cout << ": "; + writeName(ent2->getDirectBase()); + } + std::cout << " {\n"; + for (auto & j: ent2->getDirectMembers()) { + indent(modules, 1); + writeAnnotations(j.annotations); + writeType(j.type); + std::cout << ' ' << j.name << ";\n"; } - case unoidl::Entity::SORT_PLAIN_STRUCT_TYPE: + indent(modules); + std::cout << "};\n"; + break; + } + case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE: + { + rtl::Reference<unoidl::PolymorphicStructTypeTemplateEntity> + ent2( + static_cast<unoidl::PolymorphicStructTypeTemplateEntity *>( + ent.get())); + writeAnnotationsPublished(ent); + std::cout << "struct " << id << '<'; + for (auto j(ent2->getTypeParameters().begin()); + j != ent2->getTypeParameters().end(); ++j) { - rtl::Reference<unoidl::PlainStructTypeEntity> ent2( - static_cast<unoidl::PlainStructTypeEntity *>(ent.get())); - writeAnnotationsPublished(ent); - std::cout << "struct " << id; - if (!ent2->getDirectBase().isEmpty()) { - std::cout << ": "; - writeName(ent2->getDirectBase()); + if (j != ent2->getTypeParameters().begin()) { + std::cout << ", "; } - std::cout << " {\n"; - for (auto & j: ent2->getDirectMembers()) { - indent(modules, 1); - writeAnnotations(j.annotations); + std::cout << *j; + } + std::cout << "> {\n"; + for (auto & j: ent2->getMembers()) { + indent(modules, 1); + writeAnnotations(j.annotations); + if (j.parameterized) { + std::cout << j.type; + } else { writeType(j.type); - std::cout << ' ' << j.name << ";\n"; } - indent(modules); - std::cout << "};\n"; - break; + std::cout << ' ' << j.name << ";\n"; } - case unoidl::Entity::SORT_POLYMORPHIC_STRUCT_TYPE_TEMPLATE: - { - rtl::Reference<unoidl::PolymorphicStructTypeTemplateEntity> - ent2( - static_cast<unoidl::PolymorphicStructTypeTemplateEntity *>( - ent.get())); - writeAnnotationsPublished(ent); - std::cout << "struct " << id << '<'; - for (auto j(ent2->getTypeParameters().begin()); - j != ent2->getTypeParameters().end(); ++j) + indent(modules); + std::cout << "};\n"; + break; + } + case unoidl::Entity::SORT_EXCEPTION_TYPE: + { + rtl::Reference<unoidl::ExceptionTypeEntity> ent2( + static_cast<unoidl::ExceptionTypeEntity *>(ent.get())); + writeAnnotationsPublished(ent); + std::cout << "exception " << id; + if (!ent2->getDirectBase().isEmpty()) { + std::cout << ": "; + writeName(ent2->getDirectBase()); + } + std::cout << " {\n"; + for (auto & j: ent2->getDirectMembers()) { + indent(modules, 1); + writeAnnotations(j.annotations); + writeType(j.type); + std::cout << ' ' << j.name << ";\n"; + } + indent(modules); + std::cout << "};\n"; + break; + } + case unoidl::Entity::SORT_INTERFACE_TYPE: + { + rtl::Reference<unoidl::InterfaceTypeEntity> ent2( + static_cast<unoidl::InterfaceTypeEntity *>( + ent.get())); + writeAnnotationsPublished(ent); + std::cout << "interface " << id << " {\n"; + for (auto & j: ent2->getDirectMandatoryBases()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "interface "; + writeName(j.name); + std::cout << ";\n"; + } + for (auto & j: ent2->getDirectOptionalBases()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "[optional] interface "; + writeName(j.name); + std::cout << ";\n"; + } + for (auto & j: ent2->getDirectAttributes()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "[attribute"; + if (j.bound) { + std::cout << ", bound"; + } + if (j.readOnly) { + std::cout << ", readonly"; + } + std::cout << "] "; + writeType(j.type); + std::cout << ' ' << j.name; + if (!(j.getExceptions.empty() && j.setExceptions.empty())) { + std::cout << " {\n"; + if (!j.getExceptions.empty()) { + indent(modules, 2); + std::cout << "get"; + writeExceptionSpecification(j.getExceptions); + std::cout << ";\n"; + } + if (!j.setExceptions.empty()) { + indent(modules, 2); + std::cout << "set"; + writeExceptionSpecification(j.setExceptions); + std::cout << ";\n"; + } + std::cout << " }"; + } + std::cout << ";\n"; + } + for (auto & j: ent2->getDirectMethods()) { + indent(modules, 1); + writeAnnotations(j.annotations); + writeType(j.returnType); + std::cout << ' ' << j.name << '('; + for (auto k(j.parameters.begin()); k != j.parameters.end(); + ++k) { - if (j != ent2->getTypeParameters().begin()) { + if (k != j.parameters.begin()) { std::cout << ", "; } - std::cout << *j; - } - std::cout << "> {\n"; - for (auto & j: ent2->getMembers()) { - indent(modules, 1); - writeAnnotations(j.annotations); - if (j.parameterized) { - std::cout << j.type; - } else { - writeType(j.type); + switch (k->direction) { + case unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN: + std::cout << "[in] "; + break; + case unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT: + std::cout << "[out] "; + break; + case unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN_OUT: + std::cout << "[inout] "; + break; } - std::cout << ' ' << j.name << ";\n"; + writeType(k->type); + std::cout << ' ' << k->name; } - indent(modules); - std::cout << "};\n"; - break; + std::cout << ')'; + writeExceptionSpecification(j.exceptions); + std::cout << ";\n"; } - case unoidl::Entity::SORT_EXCEPTION_TYPE: - { - rtl::Reference<unoidl::ExceptionTypeEntity> ent2( - static_cast<unoidl::ExceptionTypeEntity *>(ent.get())); - writeAnnotationsPublished(ent); - std::cout << "exception " << id; - if (!ent2->getDirectBase().isEmpty()) { - std::cout << ": "; - writeName(ent2->getDirectBase()); + indent(modules); + std::cout << "};\n"; + break; + } + case unoidl::Entity::SORT_TYPEDEF: + { + rtl::Reference<unoidl::TypedefEntity> ent2( + static_cast<unoidl::TypedefEntity *>(ent.get())); + writeAnnotationsPublished(ent); + std::cout << "typedef "; + writeType(ent2->getType()); + std::cout << ' ' << id << ";\n"; + break; + } + case unoidl::Entity::SORT_CONSTANT_GROUP: + { + rtl::Reference<unoidl::ConstantGroupEntity> ent2( + static_cast<unoidl::ConstantGroupEntity *>(ent.get())); + writeAnnotationsPublished(ent); + std::cout << "constants " << id << " {\n"; + for (auto & j: ent2->getMembers()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "const "; + switch (j.value.type) { + case unoidl::ConstantValue::TYPE_BOOLEAN: + std::cout << "boolean"; + break; + case unoidl::ConstantValue::TYPE_BYTE: + std::cout << "byte"; + break; + case unoidl::ConstantValue::TYPE_SHORT: + std::cout << "short"; + break; + case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT: + std::cout << "unsigned short"; + break; + case unoidl::ConstantValue::TYPE_LONG: + std::cout << "long"; + break; + case unoidl::ConstantValue::TYPE_UNSIGNED_LONG: + std::cout << "unsigned long"; + break; + case unoidl::ConstantValue::TYPE_HYPER: + std::cout << "hyper"; + break; + case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER: + std::cout << "unsigned hyper"; + break; + case unoidl::ConstantValue::TYPE_FLOAT: + std::cout << "float"; + break; + case unoidl::ConstantValue::TYPE_DOUBLE: + std::cout << "double"; + break; } - std::cout << " {\n"; - for (auto & j: ent2->getDirectMembers()) { - indent(modules, 1); - writeAnnotations(j.annotations); - writeType(j.type); - std::cout << ' ' << j.name << ";\n"; + std::cout << ' ' << j.name << " = "; + switch (j.value.type) { + case unoidl::ConstantValue::TYPE_BOOLEAN: + std::cout << (j.value.booleanValue ? "TRUE" : "FALSE"); + break; + case unoidl::ConstantValue::TYPE_BYTE: + std::cout << int(j.value.byteValue); + break; + case unoidl::ConstantValue::TYPE_SHORT: + std::cout << j.value.shortValue; + break; + case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT: + std::cout << j.value.unsignedShortValue; + break; + case unoidl::ConstantValue::TYPE_LONG: + std::cout << j.value.longValue; + break; + case unoidl::ConstantValue::TYPE_UNSIGNED_LONG: + std::cout << j.value.unsignedLongValue; + break; + case unoidl::ConstantValue::TYPE_HYPER: + std::cout << j.value.hyperValue; + break; + case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER: + std::cout << j.value.unsignedHyperValue; + break; + case unoidl::ConstantValue::TYPE_FLOAT: + std::cout << j.value.floatValue; + break; + case unoidl::ConstantValue::TYPE_DOUBLE: + std::cout << j.value.doubleValue; + break; } - indent(modules); - std::cout << "};\n"; - break; + std::cout << ";\n"; } - case unoidl::Entity::SORT_INTERFACE_TYPE: + indent(modules); + std::cout << "};\n"; + break; + } + case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE: + { + rtl::Reference<unoidl::SingleInterfaceBasedServiceEntity> ent2( + static_cast<unoidl::SingleInterfaceBasedServiceEntity *>( + ent.get())); + writeAnnotationsPublished(ent); + std::cout << "service " << id << ": "; + writeName(ent2->getBase()); + if (ent2->getConstructors().size() != 1 + || !ent2->getConstructors().front().defaultConstructor) { - rtl::Reference<unoidl::InterfaceTypeEntity> ent2( - static_cast<unoidl::InterfaceTypeEntity *>( - ent.get())); - writeAnnotationsPublished(ent); - std::cout << "interface " << id << " {\n"; - for (auto & j: ent2->getDirectMandatoryBases()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "interface "; - writeName(j.name); - std::cout << ";\n"; - } - for (auto & j: ent2->getDirectOptionalBases()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "[optional] interface "; - writeName(j.name); - std::cout << ";\n"; - } - for (auto & j: ent2->getDirectAttributes()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "[attribute"; - if (j.bound) { - std::cout << ", bound"; - } - if (j.readOnly) { - std::cout << ", readonly"; - } - std::cout << "] "; - writeType(j.type); - std::cout << ' ' << j.name; - if (!(j.getExceptions.empty() && j.setExceptions.empty())) { - std::cout << " {\n"; - if (!j.getExceptions.empty()) { - indent(modules, 2); - std::cout << "get"; - writeExceptionSpecification(j.getExceptions); - std::cout << ";\n"; - } - if (!j.setExceptions.empty()) { - indent(modules, 2); - std::cout << "set"; - writeExceptionSpecification(j.setExceptions); - std::cout << ";\n"; - } - std::cout << " }"; - } - std::cout << ";\n"; - } - for (auto & j: ent2->getDirectMethods()) { + std::cout << " {\n"; + for (auto & j: ent2->getConstructors()) { indent(modules, 1); writeAnnotations(j.annotations); - writeType(j.returnType); - std::cout << ' ' << j.name << '('; - for (auto k(j.parameters.begin()); k != j.parameters.end(); - ++k) + std::cout << j.name << '('; + for (auto k(j.parameters.begin()); + k != j.parameters.end(); ++k) { if (k != j.parameters.begin()) { std::cout << ", "; } - switch (k->direction) { - case unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN: - std::cout << "[in] "; - break; - case unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_OUT: - std::cout << "[out] "; - break; - case unoidl::InterfaceTypeEntity::Method::Parameter::DIRECTION_IN_OUT: - std::cout << "[inout] "; - break; - } + std::cout << "[in] "; writeType(k->type); + if (k->rest) { + std::cout << "..."; + } std::cout << ' ' << k->name; } std::cout << ')'; @@ -752,265 +883,136 @@ void writeEntity( std::cout << ";\n"; } indent(modules); - std::cout << "};\n"; - break; + std::cout << '}'; } - case unoidl::Entity::SORT_TYPEDEF: - { - rtl::Reference<unoidl::TypedefEntity> ent2( - static_cast<unoidl::TypedefEntity *>(ent.get())); - writeAnnotationsPublished(ent); - std::cout << "typedef "; - writeType(ent2->getType()); - std::cout << ' ' << id << ";\n"; - break; + std::cout << ";\n"; + break; + } + case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE: + { + rtl::Reference<unoidl::AccumulationBasedServiceEntity> ent2( + static_cast<unoidl::AccumulationBasedServiceEntity *>( + ent.get())); + writeAnnotationsPublished(ent); + std::cout << "service " << id << " {\n"; + for (auto & j: ent2->getDirectMandatoryBaseServices()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "service "; + writeName(j.name); + std::cout << ";\n"; } - case unoidl::Entity::SORT_CONSTANT_GROUP: - { - rtl::Reference<unoidl::ConstantGroupEntity> ent2( - static_cast<unoidl::ConstantGroupEntity *>(ent.get())); - writeAnnotationsPublished(ent); - std::cout << "constants " << id << " {\n"; - for (auto & j: ent2->getMembers()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "const "; - switch (j.value.type) { - case unoidl::ConstantValue::TYPE_BOOLEAN: - std::cout << "boolean"; - break; - case unoidl::ConstantValue::TYPE_BYTE: - std::cout << "byte"; - break; - case unoidl::ConstantValue::TYPE_SHORT: - std::cout << "short"; - break; - case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT: - std::cout << "unsigned short"; - break; - case unoidl::ConstantValue::TYPE_LONG: - std::cout << "long"; - break; - case unoidl::ConstantValue::TYPE_UNSIGNED_LONG: - std::cout << "unsigned long"; - break; - case unoidl::ConstantValue::TYPE_HYPER: - std::cout << "hyper"; - break; - case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER: - std::cout << "unsigned hyper"; - break; - case unoidl::ConstantValue::TYPE_FLOAT: - std::cout << "float"; - break; - case unoidl::ConstantValue::TYPE_DOUBLE: - std::cout << "double"; - break; - } - std::cout << ' ' << j.name << " = "; - switch (j.value.type) { - case unoidl::ConstantValue::TYPE_BOOLEAN: - std::cout << (j.value.booleanValue ? "TRUE" : "FALSE"); - break; - case unoidl::ConstantValue::TYPE_BYTE: - std::cout << int(j.value.byteValue); - break; - case unoidl::ConstantValue::TYPE_SHORT: - std::cout << j.value.shortValue; - break; - case unoidl::ConstantValue::TYPE_UNSIGNED_SHORT: - std::cout << j.value.unsignedShortValue; - break; - case unoidl::ConstantValue::TYPE_LONG: - std::cout << j.value.longValue; - break; - case unoidl::ConstantValue::TYPE_UNSIGNED_LONG: - std::cout << j.value.unsignedLongValue; - break; - case unoidl::ConstantValue::TYPE_HYPER: - std::cout << j.value.hyperValue; - break; - case unoidl::ConstantValue::TYPE_UNSIGNED_HYPER: - std::cout << j.value.unsignedHyperValue; - break; - case unoidl::ConstantValue::TYPE_FLOAT: - std::cout << j.value.floatValue; - break; - case unoidl::ConstantValue::TYPE_DOUBLE: - std::cout << j.value.doubleValue; - break; - } - std::cout << ";\n"; - } - indent(modules); - std::cout << "};\n"; - break; + for (auto & j: ent2->getDirectOptionalBaseServices()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "[optional] service "; + writeName(j.name); + std::cout << ";\n"; } - case unoidl::Entity::SORT_SINGLE_INTERFACE_BASED_SERVICE: - { - rtl::Reference<unoidl::SingleInterfaceBasedServiceEntity> ent2( - static_cast<unoidl::SingleInterfaceBasedServiceEntity *>( - ent.get())); - writeAnnotationsPublished(ent); - std::cout << "service " << id << ": "; - writeName(ent2->getBase()); - if (ent2->getConstructors().size() != 1 - || !ent2->getConstructors().front().defaultConstructor) - { - std::cout << " {\n"; - for (auto & j: ent2->getConstructors()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << j.name << '('; - for (auto k(j.parameters.begin()); - k != j.parameters.end(); ++k) - { - if (k != j.parameters.begin()) { - std::cout << ", "; - } - std::cout << "[in] "; - writeType(k->type); - if (k->rest) { - std::cout << "..."; - } - std::cout << ' ' << k->name; - } - std::cout << ')'; - writeExceptionSpecification(j.exceptions); - std::cout << ";\n"; - } - indent(modules); - std::cout << '}'; - } + for (auto & j: ent2->getDirectMandatoryBaseInterfaces()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "interface "; + writeName(j.name); std::cout << ";\n"; - break; } - case unoidl::Entity::SORT_ACCUMULATION_BASED_SERVICE: - { - rtl::Reference<unoidl::AccumulationBasedServiceEntity> ent2( - static_cast<unoidl::AccumulationBasedServiceEntity *>( - ent.get())); - writeAnnotationsPublished(ent); - std::cout << "service " << id << " {\n"; - for (auto & j: ent2->getDirectMandatoryBaseServices()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "service "; - writeName(j.name); - std::cout << ";\n"; + for (auto & j: ent2->getDirectOptionalBaseInterfaces()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "[optional] interface "; + writeName(j.name); + std::cout << ";\n"; + } + for (auto & j: ent2->getDirectProperties()) { + indent(modules, 1); + writeAnnotations(j.annotations); + std::cout << "[property"; + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_BOUND) + != 0) + { + std::cout << ", bound"; } - for (auto & j: ent2->getDirectOptionalBaseServices()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "[optional] service "; - writeName(j.name); - std::cout << ";\n"; + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED) + != 0) + { + std::cout << ", constrained"; } - for (auto & j: ent2->getDirectMandatoryBaseInterfaces()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "interface "; - writeName(j.name); - std::cout << ";\n"; + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_AMBIGUOUS) + != 0) + { + std::cout << ", maybeambiguous"; } - for (auto & j: ent2->getDirectOptionalBaseInterfaces()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "[optional] interface "; - writeName(j.name); - std::cout << ";\n"; + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_DEFAULT) + != 0) + { + std::cout << ", maybedefault"; } - for (auto & j: ent2->getDirectProperties()) { - indent(modules, 1); - writeAnnotations(j.annotations); - std::cout << "[property"; - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_BOUND) - != 0) - { - std::cout << ", bound"; - } - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_CONSTRAINED) - != 0) - { - std::cout << ", constrained"; - } - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_AMBIGUOUS) - != 0) - { - std::cout << ", maybeambiguous"; - } - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_DEFAULT) - != 0) - { - std::cout << ", maybedefault"; - } - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_VOID) - != 0) - { - std::cout << ", maybevoid"; - } - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_OPTIONAL) - != 0) - { - std::cout << ", optional"; - } - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_READ_ONLY) - != 0) - { - std::cout << ", readonly"; - } - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_REMOVABLE) - != 0) - { - std::cout << ", removable"; - } - if ((j.attributes - & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_TRANSIENT) - != 0) - { - std::cout << ", transient"; - } - std::cout << "] "; - writeType(j.type); - std::cout << ' ' << j.name << ";\n"; + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_MAYBE_VOID) + != 0) + { + std::cout << ", maybevoid"; } - indent(modules); - std::cout << "};\n"; - break; - } - case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON: - { - rtl::Reference<unoidl::InterfaceBasedSingletonEntity> ent2( - static_cast<unoidl::InterfaceBasedSingletonEntity *>( - ent.get())); - writeAnnotationsPublished(ent); - std::cout << "singleton " << id << ": "; - writeName(ent2->getBase()); - std::cout << ";\n"; - break; - } - case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON: - { - rtl::Reference<unoidl::ServiceBasedSingletonEntity> ent2( - static_cast<unoidl::ServiceBasedSingletonEntity *>( - ent.get())); - writeAnnotationsPublished(ent); - std::cout << "singleton " << id << " { service "; - writeName(ent2->getBase()); - std::cout << "; };"; - break; + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_OPTIONAL) + != 0) + { + std::cout << ", optional"; + } + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_READ_ONLY) + != 0) + { + std::cout << ", readonly"; + } + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_REMOVABLE) + != 0) + { + std::cout << ", removable"; + } + if ((j.attributes + & unoidl::AccumulationBasedServiceEntity::Property::ATTRIBUTE_TRANSIENT) + != 0) + { + std::cout << ", transient"; + } + std::cout << "] "; + writeType(j.type); + std::cout << ' ' << j.name << ";\n"; } - case unoidl::Entity::SORT_MODULE: - assert(false && "this cannot happen"); + indent(modules); + std::cout << "};\n"; + break; + } + case unoidl::Entity::SORT_INTERFACE_BASED_SINGLETON: + { + rtl::Reference<unoidl::InterfaceBasedSingletonEntity> ent2( + static_cast<unoidl::InterfaceBasedSingletonEntity *>( + ent.get())); + writeAnnotationsPublished(ent); + std::cout << "singleton " << id << ": "; + writeName(ent2->getBase()); + std::cout << ";\n"; + break; + } + case unoidl::Entity::SORT_SERVICE_BASED_SINGLETON: + { + rtl::Reference<unoidl::ServiceBasedSingletonEntity> ent2( + static_cast<unoidl::ServiceBasedSingletonEntity *>( + ent.get())); + writeAnnotationsPublished(ent); + std::cout << "singleton " << id << " { service "; + writeName(ent2->getBase()); + std::cout << "; };"; + break; } + case unoidl::Entity::SORT_MODULE: + assert(false && "this cannot happen"); } } diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx index 62de1e70d1c4..c317aff79918 100644 --- a/unotools/source/config/historyoptions.cxx +++ b/unotools/source/config/historyoptions.cxx @@ -396,21 +396,21 @@ static void TruncateList( xList->getByName(s_sItemList) >>= xItemList; const sal_uInt32 nLength = xOrderList->getElementNames().getLength(); - if (nSize < nLength) - { - for (sal_uInt32 i=nLength-1; i>=nSize; --i) - { - uno::Reference<beans::XPropertySet> xSet; - OUString sTmp; - const OUString sRemove = OUString::number(i); - xOrderList->getByName(sRemove) >>= xSet; - xSet->getPropertyValue(s_sHistoryItemRef) >>= sTmp; - xItemList->removeByName(sTmp); - xOrderList->removeByName(sRemove); - } + if (nSize >= nLength) + return; - ::comphelper::ConfigurationHelper::flush(xCfg); + for (sal_uInt32 i=nLength-1; i>=nSize; --i) + { + uno::Reference<beans::XPropertySet> xSet; + OUString sTmp; + const OUString sRemove = OUString::number(i); + xOrderList->getByName(sRemove) >>= xSet; + xSet->getPropertyValue(s_sHistoryItemRef) >>= sTmp; + xItemList->removeByName(sTmp); + xOrderList->removeByName(sRemove); } + + ::comphelper::ConfigurationHelper::flush(xCfg); } diff --git a/unotools/source/config/moduleoptions.cxx b/unotools/source/config/moduleoptions.cxx index 35018b8b88c7..e73165ff4b18 100644 --- a/unotools/source/config/moduleoptions.cxx +++ b/unotools/source/config/moduleoptions.cxx @@ -781,18 +781,18 @@ SvtModuleOptions::SvtModuleOptions() { // no need to take the mutex yet, shared_ptr/weak_ptr are thread-safe m_pImpl = g_pModuleOptions.lock(); + if( m_pImpl ) + return; + + // take the mutex, so we don't accidentally create more than one + ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() ); + + m_pImpl = g_pModuleOptions.lock(); if( !m_pImpl ) { - // take the mutex, so we don't accidentally create more than one - ::osl::MutexGuard aGuard( impl_GetOwnStaticMutex() ); - - m_pImpl = g_pModuleOptions.lock(); - if( !m_pImpl ) - { - m_pImpl = std::make_shared<SvtModuleOptions_Impl>(); - g_pModuleOptions = m_pImpl; - ItemHolder1::holdConfigItem(EItem::ModuleOptions); - } + m_pImpl = std::make_shared<SvtModuleOptions_Impl>(); + g_pModuleOptions = m_pImpl; + ItemHolder1::holdConfigItem(EItem::ModuleOptions); } } diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx index b53a56c60c02..22ce434b0e3e 100644 --- a/unotools/source/ucbhelper/tempfile.cxx +++ b/unotools/source/ucbhelper/tempfile.cxx @@ -385,20 +385,20 @@ TempFile::TempFile(TempFile && other) noexcept : TempFile::~TempFile() { - if ( bKillingFileEnabled ) + if ( !bKillingFileEnabled ) + return; + + // if we're going to delete this file, no point in flushing it when closing + if (pStream && !aName.isEmpty()) + static_cast<SvFileStream*>(pStream.get())->SetDontFlushOnClose(true); + pStream.reset(); + if ( bIsDirectory ) { - // if we're going to delete this file, no point in flushing it when closing - if (pStream && !aName.isEmpty()) - static_cast<SvFileStream*>(pStream.get())->SetDontFlushOnClose(true); - pStream.reset(); - if ( bIsDirectory ) - { - comphelper::DirectoryHelper::deleteDirRecursively(aName); - } - else - { - File::remove( aName ); - } + comphelper::DirectoryHelper::deleteDirRecursively(aName); + } + else + { + File::remove( aName ); } } diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 164aa3a4fb0d..3471efd6f0ad 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1279,25 +1279,25 @@ JSMessageDialog::JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* p { m_pSender = m_pOwnedSender.get(); - if (!pBuilder) + if (pBuilder) + return; + + if (::OKButton* pOKBtn + = dynamic_cast<::OKButton*>(m_xMessageDialog->get_widget_for_response(RET_OK))) { - if (::OKButton* pOKBtn - = dynamic_cast<::OKButton*>(m_xMessageDialog->get_widget_for_response(RET_OK))) - { - m_pOK.reset(new JSButton(m_pSender, pOKBtn, nullptr, false)); - JSInstanceBuilder::AddChildWidget(m_xMessageDialog->GetLOKWindowId(), - pOKBtn->get_id().toUtf8(), m_pOK.get()); - m_pOK->connect_clicked(LINK(this, JSMessageDialog, OKHdl)); - } + m_pOK.reset(new JSButton(m_pSender, pOKBtn, nullptr, false)); + JSInstanceBuilder::AddChildWidget(m_xMessageDialog->GetLOKWindowId(), + pOKBtn->get_id().toUtf8(), m_pOK.get()); + m_pOK->connect_clicked(LINK(this, JSMessageDialog, OKHdl)); + } - if (::CancelButton* pCancelBtn - = dynamic_cast<::CancelButton*>(m_xMessageDialog->get_widget_for_response(RET_CANCEL))) - { - m_pCancel.reset(new JSButton(m_pSender, pCancelBtn, nullptr, false)); - JSInstanceBuilder::AddChildWidget(m_xMessageDialog->GetLOKWindowId(), - pCancelBtn->get_id().toUtf8(), m_pCancel.get()); - m_pCancel->connect_clicked(LINK(this, JSMessageDialog, CancelHdl)); - } + if (::CancelButton* pCancelBtn + = dynamic_cast<::CancelButton*>(m_xMessageDialog->get_widget_for_response(RET_CANCEL))) + { + m_pCancel.reset(new JSButton(m_pSender, pCancelBtn, nullptr, false)); + JSInstanceBuilder::AddChildWidget(m_xMessageDialog->GetLOKWindowId(), + pCancelBtn->get_id().toUtf8(), m_pCancel.get()); + m_pCancel->connect_clicked(LINK(this, JSMessageDialog, CancelHdl)); } } @@ -1383,22 +1383,22 @@ void JSToolbar::set_menu_item_active(const OString& rIdent, bool bActive) ToolBoxItemId nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); VclPtr<vcl::Window> pFloat = m_aFloats[nItemId]; - if (pFloat) - { - // See WeldToolbarPopup : include/svtools/toolbarmenu.hxx - // TopLevel (Popover) -> Container -> main container of the popup - vcl::Window* pPopupRoot = pFloat->GetChild(0); - if (pPopupRoot) - pPopupRoot = pPopupRoot->GetChild(0); + if (!pFloat) + return; - if (pPopupRoot) - { - if (bActive) - sendPopup(pPopupRoot, m_xToolBox->get_id(), - OStringToOUString(rIdent, RTL_TEXTENCODING_ASCII_US)); - else if (bWasActive) - sendClosePopup(pPopupRoot->GetLOKWindowId()); - } + // See WeldToolbarPopup : include/svtools/toolbarmenu.hxx + // TopLevel (Popover) -> Container -> main container of the popup + vcl::Window* pPopupRoot = pFloat->GetChild(0); + if (pPopupRoot) + pPopupRoot = pPopupRoot->GetChild(0); + + if (pPopupRoot) + { + if (bActive) + sendPopup(pPopupRoot, m_xToolBox->get_id(), + OStringToOUString(rIdent, RTL_TEXTENCODING_ASCII_US)); + else if (bWasActive) + sendClosePopup(pPopupRoot->GetLOKWindowId()); } } diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 00bbbe6660c3..73f6cc3dd479 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -455,22 +455,23 @@ void SkiaSalGraphicsImpl::postDraw() } SkiaZone::leave(); // matched in preDraw() // If there's a problem with the GPU context, abort. - if (GrDirectContext* context = GrAsDirectContext(mSurface->getCanvas()->recordingContext())) + GrDirectContext* context = GrAsDirectContext(mSurface->getCanvas()->recordingContext()); + if (!context) + return; + + // Running out of memory on the GPU technically could be possibly recoverable, + // but we don't know the exact status of the surface (and what has or has not been drawn to it), + // so in practice this is unrecoverable without possible data loss. + if (context->oomed()) { - // Running out of memory on the GPU technically could be possibly recoverable, - // but we don't know the exact status of the surface (and what has or has not been drawn to it), - // so in practice this is unrecoverable without possible data loss. - if (context->oomed()) - { - SAL_WARN("vcl.skia", "GPU context has run out of memory, aborting."); - abort(); - } - // Unrecoverable problem. - if (context->abandoned()) - { - SAL_WARN("vcl.skia", "GPU context has been abandoned, aborting."); - abort(); - } + SAL_WARN("vcl.skia", "GPU context has run out of memory, aborting."); + abort(); + } + // Unrecoverable problem. + if (context->abandoned()) + { + SAL_WARN("vcl.skia", "GPU context has been abandoned, aborting."); + abort(); } } @@ -1058,21 +1059,22 @@ static void roundPolygonPoints(basegfx::B2DPolyPolygon& polyPolygon) void SkiaSalGraphicsImpl::checkPendingDrawing() { - if (mLastPolyPolygonInfo.polygons.size() != 0) - { // Flush any pending polygon drawing. - basegfx::B2DPolyPolygonVector polygons; - std::swap(polygons, mLastPolyPolygonInfo.polygons); - double transparency = mLastPolyPolygonInfo.transparency; - mLastPolyPolygonInfo.bounds.reset(); - if (polygons.size() == 1) - performDrawPolyPolygon(polygons.front(), transparency, true); - else - { - for (basegfx::B2DPolyPolygon& p : polygons) - roundPolygonPoints(p); - performDrawPolyPolygon(basegfx::utils::mergeToSinglePolyPolygon(std::move(polygons)), - transparency, true); - } + if (mLastPolyPolygonInfo.polygons.size() == 0) + return; + + // Flush any pending polygon drawing. + basegfx::B2DPolyPolygonVector polygons; + std::swap(polygons, mLastPolyPolygonInfo.polygons); + double transparency = mLastPolyPolygonInfo.transparency; + mLastPolyPolygonInfo.bounds.reset(); + if (polygons.size() == 1) + performDrawPolyPolygon(polygons.front(), transparency, true); + else + { + for (basegfx::B2DPolyPolygon& p : polygons) + roundPolygonPoints(p); + performDrawPolyPolygon(basegfx::utils::mergeToSinglePolyPolygon(std::move(polygons)), + transparency, true); } } diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx index 2d0cf4b9686b..5da5c2465c60 100644 --- a/vcl/source/app/scheduler.cxx +++ b/vcl/source/app/scheduler.cxx @@ -436,94 +436,94 @@ void Scheduler::CallbackTaskScheduling() "Calculated minimum timeout as " << nMinPeriod << " of " << nTasks << " tasks"); UpdateSystemTimer(rSchedCtx, nMinPeriod, true, nTime); - if ( pMostUrgent ) + if ( !pMostUrgent ) + return; + + SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " + << pMostUrgent << " invoke-in " << *pMostUrgent->mpTask ); + + Task *pTask = pMostUrgent->mpTask; + + comphelper::ProfileZone aZone( pTask->GetDebugName() ); + + // prepare Scheduler object for deletion after handling + pTask->SetDeletionFlags(); + + assert(!pMostUrgent->mbInScheduler); + pMostUrgent->mbInScheduler = true; + + // always push the stack, as we don't traverse the whole list to push later + DropSchedulerData(rSchedCtx, pPrevMostUrgent, pMostUrgent, nMostUrgentPriority); + pMostUrgent->mpNext = rSchedCtx.mpSchedulerStack; + rSchedCtx.mpSchedulerStack = pMostUrgent; + rSchedCtx.mpSchedulerStackTop = pMostUrgent; + + // invoke the task + Unlock(); + /* + * Current policy is that scheduler tasks aren't allowed to throw an exception. + * Because otherwise the exception is caught somewhere totally unrelated. + * TODO Ideally we could capture a proper backtrace and feed this into breakpad, + * which is do-able, but requires writing some assembly. + * See also SalUserEventList::DispatchUserEvents + */ + try { - SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " - << pMostUrgent << " invoke-in " << *pMostUrgent->mpTask ); - - Task *pTask = pMostUrgent->mpTask; - - comphelper::ProfileZone aZone( pTask->GetDebugName() ); - - // prepare Scheduler object for deletion after handling - pTask->SetDeletionFlags(); - - assert(!pMostUrgent->mbInScheduler); - pMostUrgent->mbInScheduler = true; - - // always push the stack, as we don't traverse the whole list to push later - DropSchedulerData(rSchedCtx, pPrevMostUrgent, pMostUrgent, nMostUrgentPriority); - pMostUrgent->mpNext = rSchedCtx.mpSchedulerStack; - rSchedCtx.mpSchedulerStack = pMostUrgent; - rSchedCtx.mpSchedulerStackTop = pMostUrgent; - - // invoke the task - Unlock(); - /* - * Current policy is that scheduler tasks aren't allowed to throw an exception. - * Because otherwise the exception is caught somewhere totally unrelated. - * TODO Ideally we could capture a proper backtrace and feed this into breakpad, - * which is do-able, but requires writing some assembly. - * See also SalUserEventList::DispatchUserEvents - */ - try - { - pTask->Invoke(); - } - catch (css::uno::Exception&) - { - TOOLS_WARN_EXCEPTION("vcl.schedule", "Uncaught"); - std::abort(); - } - catch (std::exception& e) - { - SAL_WARN("vcl.schedule", "Uncaught " << typeid(e).name() << " " << e.what()); - std::abort(); - } - catch (...) - { - SAL_WARN("vcl.schedule", "Uncaught exception during Task::Invoke()!"); - std::abort(); - } - Lock(); + pTask->Invoke(); + } + catch (css::uno::Exception&) + { + TOOLS_WARN_EXCEPTION("vcl.schedule", "Uncaught"); + std::abort(); + } + catch (std::exception& e) + { + SAL_WARN("vcl.schedule", "Uncaught " << typeid(e).name() << " " << e.what()); + std::abort(); + } + catch (...) + { + SAL_WARN("vcl.schedule", "Uncaught exception during Task::Invoke()!"); + std::abort(); + } + Lock(); - assert(pMostUrgent->mbInScheduler); - pMostUrgent->mbInScheduler = false; + assert(pMostUrgent->mbInScheduler); + pMostUrgent->mbInScheduler = false; - SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " - << pMostUrgent << " invoke-out" ); + SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks() << " " + << pMostUrgent << " invoke-out" ); - // pop the scheduler stack - pSchedulerData = rSchedCtx.mpSchedulerStack; - assert(pSchedulerData == pMostUrgent); - rSchedCtx.mpSchedulerStack = pSchedulerData->mpNext; + // pop the scheduler stack + pSchedulerData = rSchedCtx.mpSchedulerStack; + assert(pSchedulerData == pMostUrgent); + rSchedCtx.mpSchedulerStack = pSchedulerData->mpNext; - // coverity[check_after_deref : FALSE] - pMostUrgent->mpTask is initially pMostUrgent->mpTask, but Task::Invoke can clear it - const bool bTaskAlive = pMostUrgent->mpTask && pMostUrgent->mpTask->IsActive(); - if (!bTaskAlive) - { - if (pMostUrgent->mpTask) - pMostUrgent->mpTask->mpSchedulerData = nullptr; - delete pMostUrgent; - } - else - AppendSchedulerData(rSchedCtx, pMostUrgent); + // coverity[check_after_deref : FALSE] - pMostUrgent->mpTask is initially pMostUrgent->mpTask, but Task::Invoke can clear it + const bool bTaskAlive = pMostUrgent->mpTask && pMostUrgent->mpTask->IsActive(); + if (!bTaskAlive) + { + if (pMostUrgent->mpTask) + pMostUrgent->mpTask->mpSchedulerData = nullptr; + delete pMostUrgent; + } + else + AppendSchedulerData(rSchedCtx, pMostUrgent); - // this just happens for nested calls, which renders all accounting - // invalid, so we just enforce a rescheduling! - if (rSchedCtx.mpSchedulerStackTop != pSchedulerData) - { - UpdateSystemTimer( rSchedCtx, ImmediateTimeoutMs, true, - tools::Time::GetSystemTicks() ); - } - else if (bTaskAlive) - { - pMostUrgent->mnUpdateTime = nTime; - nReadyPeriod = pMostUrgent->mpTask->UpdateMinPeriod( nTime ); - if ( nMinPeriod > nReadyPeriod ) - nMinPeriod = nReadyPeriod; - UpdateSystemTimer( rSchedCtx, nMinPeriod, false, nTime ); - } + // this just happens for nested calls, which renders all accounting + // invalid, so we just enforce a rescheduling! + if (rSchedCtx.mpSchedulerStackTop != pSchedulerData) + { + UpdateSystemTimer( rSchedCtx, ImmediateTimeoutMs, true, + tools::Time::GetSystemTicks() ); + } + else if (bTaskAlive) + { + pMostUrgent->mnUpdateTime = nTime; + nReadyPeriod = pMostUrgent->mpTask->UpdateMinPeriod( nTime ); + if ( nMinPeriod > nReadyPeriod ) + nMinPeriod = nReadyPeriod; + UpdateSystemTimer( rSchedCtx, nMinPeriod, false, nTime ); } } diff --git a/vcl/source/bitmap/impvect.cxx b/vcl/source/bitmap/impvect.cxx index 75d96aa79fc0..0faac17e31dc 100644 --- a/vcl/source/bitmap/impvect.cxx +++ b/vcl/source/bitmap/impvect.cxx @@ -780,84 +780,84 @@ void ImplLimitPolyPoly( tools::PolyPolygon& rPolyPoly ) void ImplExpand( std::optional<ImplVectMap>& oMap, const BitmapReadAccess* pRAcc, const Color& rColor ) { - if( pRAcc && pRAcc->Width() && pRAcc->Height() ) - { - const tools::Long nOldWidth = pRAcc->Width(); - const tools::Long nOldHeight = pRAcc->Height(); - const tools::Long nNewWidth = ( nOldWidth << 2 ) + 4; - const tools::Long nNewHeight = ( nOldHeight << 2 ) + 4; - const BitmapColor aTest( pRAcc->GetBestMatchingColor( rColor ) ); - std::unique_ptr<tools::Long[]> pMapIn(new tools::Long[ std::max( nOldWidth, nOldHeight ) ]); - std::unique_ptr<tools::Long[]> pMapOut(new tools::Long[ std::max( nOldWidth, nOldHeight ) ]); - tools::Long nX, nY, nTmpX, nTmpY; + if( !pRAcc || !pRAcc->Width() || !pRAcc->Height() ) + return; + + const tools::Long nOldWidth = pRAcc->Width(); + const tools::Long nOldHeight = pRAcc->Height(); + const tools::Long nNewWidth = ( nOldWidth << 2 ) + 4; + const tools::Long nNewHeight = ( nOldHeight << 2 ) + 4; + const BitmapColor aTest( pRAcc->GetBestMatchingColor( rColor ) ); + std::unique_ptr<tools::Long[]> pMapIn(new tools::Long[ std::max( nOldWidth, nOldHeight ) ]); + std::unique_ptr<tools::Long[]> pMapOut(new tools::Long[ std::max( nOldWidth, nOldHeight ) ]); + tools::Long nX, nY, nTmpX, nTmpY; - oMap.emplace( nNewWidth, nNewHeight ); + oMap.emplace( nNewWidth, nNewHeight ); - for( nX = 0; nX < nOldWidth; nX++ ) - VECT_MAP( pMapIn, pMapOut, nX ); + for( nX = 0; nX < nOldWidth; nX++ ) + VECT_MAP( pMapIn, pMapOut, nX ); - for( nY = 0, nTmpY = 5; nY < nOldHeight; nY++, nTmpY += 4 ) + for( nY = 0, nTmpY = 5; nY < nOldHeight; nY++, nTmpY += 4 ) + { + Scanline pScanlineRead = pRAcc->GetScanline( nY ); + for( nX = 0; nX < nOldWidth; ) { - Scanline pScanlineRead = pRAcc->GetScanline( nY ); - for( nX = 0; nX < nOldWidth; ) + if( pRAcc->GetPixelFromData( pScanlineRead, nX ) == aTest ) { - if( pRAcc->GetPixelFromData( pScanlineRead, nX ) == aTest ) - { - nTmpX = pMapIn[ nX++ ]; - nTmpY -= 3; + nTmpX = pMapIn[ nX++ ]; + nTmpY -= 3; - oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); - oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); - oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); - oMap->Set( nTmpY, nTmpX, VECT_CONT_INDEX ); + oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); + oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); + oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX, VECT_CONT_INDEX ); - while( nX < nOldWidth && pRAcc->GetPixelFromData( pScanlineRead, nX ) == aTest ) - nX++; + while( nX < nOldWidth && pRAcc->GetPixelFromData( pScanlineRead, nX ) == aTest ) + nX++; - nTmpX = pMapOut[ nX - 1 ]; - nTmpY -= 3; + nTmpX = pMapOut[ nX - 1 ]; + nTmpY -= 3; - oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); - oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); - oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); - oMap->Set( nTmpY, nTmpX, VECT_CONT_INDEX ); - } - else - nX++; + oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); + oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); + oMap->Set( nTmpY++, nTmpX, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX, VECT_CONT_INDEX ); } + else + nX++; } + } - for( nY = 0; nY < nOldHeight; nY++ ) - VECT_MAP( pMapIn, pMapOut, nY ); + for( nY = 0; nY < nOldHeight; nY++ ) + VECT_MAP( pMapIn, pMapOut, nY ); - for( nX = 0, nTmpX = 5; nX < nOldWidth; nX++, nTmpX += 4 ) + for( nX = 0, nTmpX = 5; nX < nOldWidth; nX++, nTmpX += 4 ) + { + for( nY = 0; nY < nOldHeight; ) { - for( nY = 0; nY < nOldHeight; ) + if( pRAcc->GetPixel( nY, nX ) == aTest ) { - if( pRAcc->GetPixel( nY, nX ) == aTest ) - { - nTmpX -= 3; - nTmpY = pMapIn[ nY++ ]; + nTmpX -= 3; + nTmpY = pMapIn[ nY++ ]; - oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); - oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); - oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); - oMap->Set( nTmpY, nTmpX, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX, VECT_CONT_INDEX ); - while( nY < nOldHeight && pRAcc->GetPixel( nY, nX ) == aTest ) - nY++; + while( nY < nOldHeight && pRAcc->GetPixel( nY, nX ) == aTest ) + nY++; - nTmpX -= 3; - nTmpY = pMapOut[ nY - 1 ]; + nTmpX -= 3; + nTmpY = pMapOut[ nY - 1 ]; - oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); - oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); - oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); - oMap->Set( nTmpY, nTmpX, VECT_CONT_INDEX ); - } - else - nY++; + oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX++, VECT_CONT_INDEX ); + oMap->Set( nTmpY, nTmpX, VECT_CONT_INDEX ); } + else + nY++; } } } diff --git a/vcl/source/control/wizardmachine.cxx b/vcl/source/control/wizardmachine.cxx index b68d876b5abb..59d2514fbbce 100644 --- a/vcl/source/control/wizardmachine.cxx +++ b/vcl/source/control/wizardmachine.cxx @@ -473,28 +473,28 @@ namespace vcl void RoadmapWizard::GetOrCreatePage( const WizardTypes::WizardState i_nState ) { - if ( nullptr == GetPage( i_nState ) ) - { - VclPtr<TabPage> pNewPage = createPage( i_nState ); - DBG_ASSERT( pNewPage, "RoadmapWizard::GetOrCreatePage: invalid new page (NULL)!" ); + if ( nullptr != GetPage( i_nState ) ) + return; - // fill up the page sequence of our base class (with dummies) - while ( m_xWizardImpl->nFirstUnknownPage < i_nState ) - { - AddPage( nullptr ); - ++m_xWizardImpl->nFirstUnknownPage; - } + VclPtr<TabPage> pNewPage = createPage( i_nState ); + DBG_ASSERT( pNewPage, "RoadmapWizard::GetOrCreatePage: invalid new page (NULL)!" ); - if ( m_xWizardImpl->nFirstUnknownPage == i_nState ) - { - // encountered this page number the first time - AddPage( pNewPage ); - ++m_xWizardImpl->nFirstUnknownPage; - } - else - // already had this page - just change it - SetPage( i_nState, pNewPage ); + // fill up the page sequence of our base class (with dummies) + while ( m_xWizardImpl->nFirstUnknownPage < i_nState ) + { + AddPage( nullptr ); + ++m_xWizardImpl->nFirstUnknownPage; } + + if ( m_xWizardImpl->nFirstUnknownPage == i_nState ) + { + // encountered this page number the first time + AddPage( pNewPage ); + ++m_xWizardImpl->nFirstUnknownPage; + } + else + // already had this page - just change it + SetPage( i_nState, pNewPage ); } void RoadmapWizard::ActivatePage() diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index b5cc64caec9f..4573d414cfc6 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -2313,22 +2313,22 @@ PDFElement* PDFDictionaryElement::LookupElement(const OString& rDictionaryKey) void PDFObjectElement::parseIfNecessary() { - if (!m_bParsed) + if (m_bParsed) + return; + + if (!m_aElements.empty()) { - if (!m_aElements.empty()) - { - // This is a stored object in an object stream. - PDFObjectParser aParser(m_aElements); - aParser.parse(this); - } - else - { - // Normal object: elements are stored as members of the document itself. - PDFObjectParser aParser(m_rDoc.GetElements()); - aParser.parse(this); - } - m_bParsed = true; + // This is a stored object in an object stream. + PDFObjectParser aParser(m_aElements); + aParser.parse(this); + } + else + { + // Normal object: elements are stored as members of the document itself. + PDFObjectParser aParser(m_rDoc.GetElements()); + aParser.parse(this); } + m_bParsed = true; } PDFElement* PDFObjectElement::Lookup(const OString& rDictionaryKey) diff --git a/vcl/source/outdev/background.cxx b/vcl/source/outdev/background.cxx index 2a6d96c3328f..a22c9e46effd 100644 --- a/vcl/source/outdev/background.cxx +++ b/vcl/source/outdev/background.cxx @@ -44,32 +44,32 @@ void OutputDevice::SetBackground( const Wallpaper& rBackground ) else mbBackground = true; - if( mpAlphaVDev ) + if( !mpAlphaVDev ) + return; + + // Some of these are probably wrong (e.g. if the gradient has transparency), + // but hopefully nobody uses that. If you do, feel free to implement it properly. + if( rBackground.GetStyle() == WallpaperStyle::NONE ) { - // Some of these are probably wrong (e.g. if the gradient has transparency), - // but hopefully nobody uses that. If you do, feel free to implement it properly. - if( rBackground.GetStyle() == WallpaperStyle::NONE ) - { - mpAlphaVDev->SetBackground( rBackground ); - } - else if( rBackground.IsBitmap()) - { - BitmapEx bitmap = rBackground.GetBitmap(); - if( bitmap.IsAlpha()) - mpAlphaVDev->SetBackground( Wallpaper( BitmapEx( Bitmap( bitmap.GetAlpha())))); - else - mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK )); - } - else if( rBackground.IsGradient()) - { - mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK )); - } + mpAlphaVDev->SetBackground( rBackground ); + } + else if( rBackground.IsBitmap()) + { + BitmapEx bitmap = rBackground.GetBitmap(); + if( bitmap.IsAlpha()) + mpAlphaVDev->SetBackground( Wallpaper( BitmapEx( Bitmap( bitmap.GetAlpha())))); else - { - // Color background. - int transparency = 255 - rBackground.GetColor().GetAlpha(); - mpAlphaVDev->SetBackground( Wallpaper( Color( transparency, transparency, transparency ))); - } + mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK )); + } + else if( rBackground.IsGradient()) + { + mpAlphaVDev->SetBackground( Wallpaper( COL_BLACK )); + } + else + { + // Color background. + int transparency = 255 - rBackground.GetColor().GetAlpha(); + mpAlphaVDev->SetBackground( Wallpaper( Color( transparency, transparency, transparency ))); } } diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx index 478c9d04d1f6..09e6091de8d6 100644 --- a/vcl/source/outdev/bitmap.cxx +++ b/vcl/source/outdev/bitmap.cxx @@ -351,23 +351,23 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& rBmp, const AlphaMask& r } tools::Rectangle aBmpRect(Point(), rBmp.GetSizePixel()); - if (!aBmpRect.Intersection(tools::Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty()) - { - Point auxOutPt(LogicToPixel(rDestPt)); - Size auxOutSz(LogicToPixel(rDestSize)); + if (aBmpRect.Intersection(tools::Rectangle(rSrcPtPixel, rSrcSizePixel)).IsEmpty()) + return; - // HACK: The function is broken with alpha vdev and mirroring, mirror here. - Bitmap bitmap(rBmp); - AlphaMask alpha(rAlpha); - if(mpAlphaVDev && (bHMirr || bVMirr)) - { - bitmap.Mirror(mirrorFlags); - alpha.Mirror(mirrorFlags); - auxOutPt = aOutPt; - auxOutSz = aOutSz; - } - DrawDeviceAlphaBitmapSlowPath(bitmap, alpha, aDstRect, aBmpRect, auxOutSz, auxOutPt); + Point auxOutPt(LogicToPixel(rDestPt)); + Size auxOutSz(LogicToPixel(rDestSize)); + + // HACK: The function is broken with alpha vdev and mirroring, mirror here. + Bitmap bitmap(rBmp); + AlphaMask alpha(rAlpha); + if(mpAlphaVDev && (bHMirr || bVMirr)) + { + bitmap.Mirror(mirrorFlags); + alpha.Mirror(mirrorFlags); + auxOutPt = aOutPt; + auxOutSz = aOutSz; } + DrawDeviceAlphaBitmapSlowPath(bitmap, alpha, aDstRect, aBmpRect, auxOutSz, auxOutPt); } namespace diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx index 765302b9961f..af40a630e698 100644 --- a/vcl/source/treelist/svimpbox.cxx +++ b/vcl/source/treelist/svimpbox.cxx @@ -2035,20 +2035,20 @@ void SvImpLBox::MouseMove( const MouseEvent& rMEvt) { Point aPos = rMEvt.GetPosPixel(); SvTreeListEntry* pEntry = GetClickedEntry(aPos); - if ( !MouseMoveCheckCtrl( rMEvt, pEntry ) && ( m_aSelEng.GetSelectionMode() != SelectionMode::NONE ) ) + if ( MouseMoveCheckCtrl( rMEvt, pEntry ) || ( m_aSelEng.GetSelectionMode() == SelectionMode::NONE ) ) + return; + + m_aSelEng.SelMouseMove(rMEvt); + if (m_pView->mbHoverSelection) { - m_aSelEng.SelMouseMove(rMEvt); - if (m_pView->mbHoverSelection) - { - if (aPos.X() < 0 || aPos.Y() < 0 || aPos.X() > m_aOutputSize.Width() || aPos.Y() > m_aOutputSize.Height()) - pEntry = nullptr; - else - pEntry = GetEntry(aPos); - if (!pEntry) - m_pView->SelectAll(false); - else if (!m_pView->IsSelected(pEntry) && IsSelectable(pEntry)) - m_pView->Select(pEntry); - } + if (aPos.X() < 0 || aPos.Y() < 0 || aPos.X() > m_aOutputSize.Width() || aPos.Y() > m_aOutputSize.Height()) + pEntry = nullptr; + else + pEntry = GetEntry(aPos); + if (!pEntry) + m_pView->SelectAll(false); + else if (!m_pView->IsSelected(pEntry) && IsSelectable(pEntry)) + m_pView->Select(pEntry); } } @@ -2983,32 +2983,32 @@ void SvImpLBox::SetMostRight( SvTreeListEntry* pEntry ) sal_uInt16 nLastTab = m_pView->aTabs.size() - 1; sal_uInt16 nLastItem = pEntry->ItemCount() - 1; - if( !m_pView->aTabs.empty() && nLastItem != USHRT_MAX ) - { - if( nLastItem < nLastTab ) - nLastTab = nLastItem; + if( m_pView->aTabs.empty() || nLastItem == USHRT_MAX ) + return; - SvLBoxTab* pTab = m_pView->aTabs[ nLastTab ].get(); - SvLBoxItem& rItem = pEntry->GetItem( nLastTab ); + if( nLastItem < nLastTab ) + nLastTab = nLastItem; - tools::Long nTabPos = m_pView->GetTabPos( pEntry, pTab ); + SvLBoxTab* pTab = m_pView->aTabs[ nLastTab ].get(); + SvLBoxItem& rItem = pEntry->GetItem( nLastTab ); - tools::Long nMaxRight = GetOutputSize().Width(); - Point aPos( m_pView->GetMapMode().GetOrigin() ); - aPos.setX( aPos.X() * -1 ); // conversion document coordinates - nMaxRight = nMaxRight + aPos.X() - 1; + tools::Long nTabPos = m_pView->GetTabPos( pEntry, pTab ); - tools::Long nNextTab = nTabPos < nMaxRight ? nMaxRight : nMaxRight + 50; - tools::Long nTabWidth = nNextTab - nTabPos + 1; - auto nItemSize = rItem.GetWidth(m_pView,pEntry); - tools::Long nOffset = pTab->CalcOffset( nItemSize, nTabWidth ); + tools::Long nMaxRight = GetOutputSize().Width(); + Point aPos( m_pView->GetMapMode().GetOrigin() ); + aPos.setX( aPos.X() * -1 ); // conversion document coordinates + nMaxRight = nMaxRight + aPos.X() - 1; - tools::Long nRight = nTabPos + nOffset + nItemSize; - if( nRight > m_nMostRight ) - { - m_nMostRight = nRight; - m_pMostRightEntry = pEntry; - } + tools::Long nNextTab = nTabPos < nMaxRight ? nMaxRight : nMaxRight + 50; + tools::Long nTabWidth = nNextTab - nTabPos + 1; + auto nItemSize = rItem.GetWidth(m_pView,pEntry); + tools::Long nOffset = pTab->CalcOffset( nItemSize, nTabWidth ); + + tools::Long nRight = nTabPos + nOffset + nItemSize; + if( nRight > m_nMostRight ) + { + m_nMostRight = nRight; + m_pMostRightEntry = pEntry; } } diff --git a/vcl/source/window/bubblewindow.cxx b/vcl/source/window/bubblewindow.cxx index a0c20cedd99e..76fcf308d7a6 100644 --- a/vcl/source/window/bubblewindow.cxx +++ b/vcl/source/window/bubblewindow.cxx @@ -535,23 +535,23 @@ void MenuBarUpdateIconManager::RemoveBubbleWindow( bool bRemoveIcon ) mpBubbleWin.disposeAndClear(); } - if ( bRemoveIcon ) - { - try { - if ( mpIconMBar && ( mnIconID != 0 ) ) - { - mpIconMBar->RemoveMenuBarButton( mnIconID ); - mpIconMBar = nullptr; - mnIconID = 0; - } - } - catch ( ... ) { + if ( !bRemoveIcon ) + return; + + try { + if ( mpIconMBar && ( mnIconID != 0 ) ) + { + mpIconMBar->RemoveMenuBarButton( mnIconID ); mpIconMBar = nullptr; mnIconID = 0; } - - mpIconSysWin = nullptr; } + catch ( ... ) { + mpIconMBar = nullptr; + mnIconID = 0; + } + + mpIconSysWin = nullptr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 16a49d300d23..91dcc41c5a01 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -2910,23 +2910,23 @@ bool isLayoutEnabled(const vcl::Window *pWindow) void VclDrawingArea::RequestHelp(const HelpEvent& rHelpEvent) { - if (rHelpEvent.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON)) - { - Point aPos(ScreenToOutputPixel(rHelpEvent.GetMousePosPixel())); - tools::Rectangle aHelpArea(aPos.X(), aPos.Y()); - OUString sHelpTip = m_aQueryTooltipHdl.Call(aHelpArea); - if (sHelpTip.isEmpty()) - return; - Point aPt = OutputToScreenPixel(aHelpArea.TopLeft()); - aHelpArea.SetLeft(aPt.X()); - aHelpArea.SetTop(aPt.Y()); - aPt = OutputToScreenPixel(aHelpArea.BottomRight()); - aHelpArea.SetRight(aPt.X()); - aHelpArea.SetBottom(aPt.Y()); - // tdf#125369 recover newline support of tdf#101779 - QuickHelpFlags eHelpWinStyle = sHelpTip.indexOf('\n') != -1 ? QuickHelpFlags::TipStyleBalloon : QuickHelpFlags::NONE; - Help::ShowQuickHelp(this, aHelpArea, sHelpTip, eHelpWinStyle); - } + if (!(rHelpEvent.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON))) + return; + + Point aPos(ScreenToOutputPixel(rHelpEvent.GetMousePosPixel())); + tools::Rectangle aHelpArea(aPos.X(), aPos.Y()); + OUString sHelpTip = m_aQueryTooltipHdl.Call(aHelpArea); + if (sHelpTip.isEmpty()) + return; + Point aPt = OutputToScreenPixel(aHelpArea.TopLeft()); + aHelpArea.SetLeft(aPt.X()); + aHelpArea.SetTop(aPt.Y()); + aPt = OutputToScreenPixel(aHelpArea.BottomRight()); + aHelpArea.SetRight(aPt.X()); + aHelpArea.SetBottom(aPt.Y()); + // tdf#125369 recover newline support of tdf#101779 + QuickHelpFlags eHelpWinStyle = sHelpTip.indexOf('\n') != -1 ? QuickHelpFlags::TipStyleBalloon : QuickHelpFlags::NONE; + Help::ShowQuickHelp(this, aHelpArea, sHelpTip, eHelpWinStyle); } void VclDrawingArea::StartDrag(sal_Int8, const Point&) diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index ba9fce890110..f448a3492e2e 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -1736,45 +1736,45 @@ void ToolBox::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) { DockingWindow::DumpAsPropertyTree(rJsonWriter); - if (!GetChildCount()) + if (GetChildCount()) + return; + + auto childrenNode = rJsonWriter.startArray("children"); + for (ToolBox::ImplToolItems::size_type i = 0; i < GetItemCount(); ++i) { - auto childrenNode = rJsonWriter.startArray("children"); - for (ToolBox::ImplToolItems::size_type i = 0; i < GetItemCount(); ++i) - { - auto childNode = rJsonWriter.startStruct(); - ToolBoxItemId nId = GetItemId(i); + auto childNode = rJsonWriter.startStruct(); + ToolBoxItemId nId = GetItemId(i); - vcl::Window* pWindow = GetItemWindow(nId); - if (pWindow) - { - pWindow->DumpAsPropertyTree(rJsonWriter); - } - else + vcl::Window* pWindow = GetItemWindow(nId); + if (pWindow) + { + pWindow->DumpAsPropertyTree(rJsonWriter); + } + else + { + OUString sCommand = GetItemCommand(nId); + rJsonWriter.put("type", "toolitem"); + rJsonWriter.put("text", GetItemText(nId)); + rJsonWriter.put("command", sCommand); + if (IsItemChecked(nId)) + rJsonWriter.put("selected", true); + if (!IsItemVisible(nId)) + rJsonWriter.put("visible", false); + if (GetItemBits(nId) & ToolBoxItemBits::DROPDOWN) + rJsonWriter.put("dropdown", true); + if (!IsItemEnabled(nId)) + rJsonWriter.put("enabled", false); + + Image aImage = GetItemImage(nId); + if (!sCommand.startsWith(".uno:") && !!aImage) { - OUString sCommand = GetItemCommand(nId); - rJsonWriter.put("type", "toolitem"); - rJsonWriter.put("text", GetItemText(nId)); - rJsonWriter.put("command", sCommand); - if (IsItemChecked(nId)) - rJsonWriter.put("selected", true); - if (!IsItemVisible(nId)) - rJsonWriter.put("visible", false); - if (GetItemBits(nId) & ToolBoxItemBits::DROPDOWN) - rJsonWriter.put("dropdown", true); - if (!IsItemEnabled(nId)) - rJsonWriter.put("enabled", false); - - Image aImage = GetItemImage(nId); - if (!sCommand.startsWith(".uno:") && !!aImage) + SvMemoryStream aOStm(6535, 6535); + if(GraphicConverter::Export(aOStm, aImage.GetBitmapEx(), ConvertDataFormat::PNG) == ERRCODE_NONE) { - SvMemoryStream aOStm(6535, 6535); - if(GraphicConverter::Export(aOStm, aImage.GetBitmapEx(), ConvertDataFormat::PNG) == ERRCODE_NONE) - { - css::uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell()); - OUStringBuffer aBuffer("data:image/png;base64,"); - ::comphelper::Base64::encode(aBuffer, aSeq); - rJsonWriter.put("image", aBuffer.makeStringAndClear()); - } + css::uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell()); + OUStringBuffer aBuffer("data:image/png;base64,"); + ::comphelper::Base64::encode(aBuffer, aSeq); + rJsonWriter.put("image", aBuffer.makeStringAndClear()); } } } diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx index 0703aeaa309f..af4aeb10a564 100644 --- a/vcl/source/window/window2.cxx +++ b/vcl/source/window/window2.cxx @@ -286,27 +286,27 @@ void Window::EndTracking( TrackingEventFlags nFlags ) ReleaseMouse(); // call EndTracking if required - if (mpWindowImpl && mpWindowImpl->mpFrameData) - { - Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY ); - if( GetOutDev()->ImplIsAntiparallel() ) - { - // re-mirror frame pos at pChild - const OutputDevice *pOutDev = GetOutDev(); - pOutDev->ReMirror( aMousePos ); - } + if (!mpWindowImpl || !mpWindowImpl->mpFrameData) + return; - MouseEvent aMEvt( ImplFrameToOutput( aMousePos ), - mpWindowImpl->mpFrameData->mnClickCount, MouseEventModifiers::NONE, - mpWindowImpl->mpFrameData->mnMouseCode, - mpWindowImpl->mpFrameData->mnMouseCode ); - TrackingEvent aTEvt( aMEvt, nFlags | TrackingEventFlags::End ); - // CompatTracking effectively - if (!mpWindowImpl || mpWindowImpl->mbInDispose) - return Window::Tracking( aTEvt ); - else - return Tracking( aTEvt ); + Point aMousePos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY ); + if( GetOutDev()->ImplIsAntiparallel() ) + { + // re-mirror frame pos at pChild + const OutputDevice *pOutDev = GetOutDev(); + pOutDev->ReMirror( aMousePos ); } + + MouseEvent aMEvt( ImplFrameToOutput( aMousePos ), + mpWindowImpl->mpFrameData->mnClickCount, MouseEventModifiers::NONE, + mpWindowImpl->mpFrameData->mnMouseCode, + mpWindowImpl->mpFrameData->mnMouseCode ); + TrackingEvent aTEvt( aMEvt, nFlags | TrackingEventFlags::End ); + // CompatTracking effectively + if (!mpWindowImpl || mpWindowImpl->mbInDispose) + return Window::Tracking( aTEvt ); + else + return Tracking( aTEvt ); } bool Window::IsTracking() const diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx index 41e621db24db..a4463bde6d06 100644 --- a/vcl/unx/gtk3/gtkframe.cxx +++ b/vcl/unx/gtk3/gtkframe.cxx @@ -528,61 +528,61 @@ static void attach_menu_model(GtkSalFrame* pSalFrame) GtkWidget* pWidget = pSalFrame->getWindow(); GdkSurface* gdkWindow = widget_get_surface(pWidget); - if ( gdkWindow != nullptr && g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-menubar" ) == nullptr ) - { - // Create menu model and action group attached to this frame. - GMenuModel* pMenuModel = G_MENU_MODEL( g_lo_menu_new() ); - GActionGroup* pActionGroup = reinterpret_cast<GActionGroup*>(g_lo_action_group_new()); + if ( gdkWindow == nullptr || g_object_get_data( G_OBJECT( gdkWindow ), "g-lo-menubar" ) != nullptr ) + return; + + // Create menu model and action group attached to this frame. + GMenuModel* pMenuModel = G_MENU_MODEL( g_lo_menu_new() ); + GActionGroup* pActionGroup = reinterpret_cast<GActionGroup*>(g_lo_action_group_new()); - // Set window properties. - g_object_set_data_full( G_OBJECT( gdkWindow ), "g-lo-menubar", pMenuModel, ObjectDestroyedNotify ); - g_object_set_data_full( G_OBJECT( gdkWindow ), "g-lo-action-group", pActionGroup, ObjectDestroyedNotify ); + // Set window properties. + g_object_set_data_full( G_OBJECT( gdkWindow ), "g-lo-menubar", pMenuModel, ObjectDestroyedNotify ); + g_object_set_data_full( G_OBJECT( gdkWindow ), "g-lo-action-group", pActionGroup, ObjectDestroyedNotify ); #if !GTK_CHECK_VERSION(4,0,0) - // Get a DBus session connection. - if (!pSessionBus) - pSessionBus = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, nullptr); - if (!pSessionBus) - return; + // Get a DBus session connection. + if (!pSessionBus) + pSessionBus = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, nullptr); + if (!pSessionBus) + return; - // Generate menu paths. - sal_uIntPtr windowId = GtkSalFrame::GetNativeWindowHandle(pWidget); - gchar* aDBusWindowPath = g_strdup_printf( "/org/libreoffice/window/%lu", windowId ); - gchar* aDBusMenubarPath = g_strdup_printf( "/org/libreoffice/window/%lu/menus/menubar", windowId ); + // Generate menu paths. + sal_uIntPtr windowId = GtkSalFrame::GetNativeWindowHandle(pWidget); + gchar* aDBusWindowPath = g_strdup_printf( "/org/libreoffice/window/%lu", windowId ); + gchar* aDBusMenubarPath = g_strdup_printf( "/org/libreoffice/window/%lu/menus/menubar", windowId ); - GdkDisplay *pDisplay = GtkSalFrame::getGdkDisplay(); + GdkDisplay *pDisplay = GtkSalFrame::getGdkDisplay(); #if defined(GDK_WINDOWING_X11) - if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay)) - { - gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_ID", "org.libreoffice" ); - gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_MENUBAR_OBJECT_PATH", aDBusMenubarPath ); - gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_WINDOW_OBJECT_PATH", aDBusWindowPath ); - gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_OBJECT_PATH", "/org/libreoffice" ); - gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_UNIQUE_BUS_NAME", g_dbus_connection_get_unique_name( pSessionBus ) ); - } + if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay)) + { + gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_ID", "org.libreoffice" ); + gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_MENUBAR_OBJECT_PATH", aDBusMenubarPath ); + gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_WINDOW_OBJECT_PATH", aDBusWindowPath ); + gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_APPLICATION_OBJECT_PATH", "/org/libreoffice" ); + gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_UNIQUE_BUS_NAME", g_dbus_connection_get_unique_name( pSessionBus ) ); + } #endif #if defined(GDK_WINDOWING_WAYLAND) - if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay)) - { - gdk_wayland_window_set_dbus_properties_libgtk_only(gdkWindow, "org.libreoffice", - nullptr, - aDBusMenubarPath, - aDBusWindowPath, - "/org/libreoffice", - g_dbus_connection_get_unique_name( pSessionBus )); - } + if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay)) + { + gdk_wayland_window_set_dbus_properties_libgtk_only(gdkWindow, "org.libreoffice", + nullptr, + aDBusMenubarPath, + aDBusWindowPath, + "/org/libreoffice", + g_dbus_connection_get_unique_name( pSessionBus )); + } #endif - // Publish the menu model and the action group. - SAL_INFO("vcl.unity", "exporting menu model at " << pMenuModel << " for window " << windowId); - pSalFrame->m_nMenuExportId = g_dbus_connection_export_menu_model (pSessionBus, aDBusMenubarPath, pMenuModel, nullptr); - SAL_INFO("vcl.unity", "exporting action group at " << pActionGroup << " for window " << windowId); - pSalFrame->m_nActionGroupExportId = g_dbus_connection_export_action_group( pSessionBus, aDBusWindowPath, pActionGroup, nullptr); - pSalFrame->m_nHudAwarenessId = hud_awareness_register( pSessionBus, aDBusMenubarPath, hud_activated, pSalFrame, nullptr, nullptr ); + // Publish the menu model and the action group. + SAL_INFO("vcl.unity", "exporting menu model at " << pMenuModel << " for window " << windowId); + pSalFrame->m_nMenuExportId = g_dbus_connection_export_menu_model (pSessionBus, aDBusMenubarPath, pMenuModel, nullptr); + SAL_INFO("vcl.unity", "exporting action group at " << pActionGroup << " for window " << windowId); + pSalFrame->m_nActionGroupExportId = g_dbus_connection_export_action_group( pSessionBus, aDBusWindowPath, pActionGroup, nullptr); + pSalFrame->m_nHudAwarenessId = hud_awareness_register( pSessionBus, aDBusMenubarPath, hud_activated, pSalFrame, nullptr, nullptr ); - g_free( aDBusWindowPath ); - g_free( aDBusMenubarPath ); + g_free( aDBusWindowPath ); + g_free( aDBusMenubarPath ); #endif - } } void on_registrar_available( GDBusConnection * /*connection*/, @@ -1496,25 +1496,25 @@ void GtkSalFrame::SetIcon(const char* appicon) gtk_window_set_icon_name(GTK_WINDOW(m_pWindow), appicon); #if defined(GDK_WINDOWING_WAYLAND) - if (DLSYM_GDK_IS_WAYLAND_DISPLAY(getGdkDisplay())) - { + if (!DLSYM_GDK_IS_WAYLAND_DISPLAY(getGdkDisplay())) + return; + #if GTK_CHECK_VERSION(4,0,0) - GdkSurface* gdkWindow = gtk_native_get_surface(gtk_widget_get_native(m_pWindow)); - gdk_wayland_toplevel_set_application_id((GDK_TOPLEVEL(gdkWindow)), appicon); + GdkSurface* gdkWindow = gtk_native_get_surface(gtk_widget_get_native(m_pWindow)); + gdk_wayland_toplevel_set_application_id((GDK_TOPLEVEL(gdkWindow)), appicon); #else - static auto set_application_id = reinterpret_cast<void (*) (GdkWindow*, const char*)>( - dlsym(nullptr, "gdk_wayland_window_set_application_id")); - if (set_application_id) - { - GdkSurface* gdkWindow = widget_get_surface(m_pWindow); - set_application_id(gdkWindow, appicon); - } -#endif - // gdk_wayland_window_set_application_id doesn't seem to work before - // the window is mapped, so set this for real when/if we are mapped - m_bIconSetWhileUnmapped = !gtk_widget_get_mapped(m_pWindow); + static auto set_application_id = reinterpret_cast<void (*) (GdkWindow*, const char*)>( + dlsym(nullptr, "gdk_wayland_window_set_application_id")); + if (set_application_id) + { + GdkSurface* gdkWindow = widget_get_surface(m_pWindow); + set_application_id(gdkWindow, appicon); } #endif + // gdk_wayland_window_set_application_id doesn't seem to work before + // the window is mapped, so set this for real when/if we are mapped + m_bIconSetWhileUnmapped = !gtk_widget_get_mapped(m_pWindow); +#endif } void GtkSalFrame::SetIcon( sal_uInt16 nIcon ) @@ -5079,19 +5079,19 @@ void GtkSalFrame::IMHandler::createIMContext() void GtkSalFrame::IMHandler::deleteIMContext() { - if( m_pIMContext ) - { - // first give IC a chance to deinitialize - GetGenericUnixSalData()->ErrorTrapPush(); + if( !m_pIMContext ) + return; + + // first give IC a chance to deinitialize + GetGenericUnixSalData()->ErrorTrapPush(); #if GTK_CHECK_VERSION(4, 0, 0) - gtk_event_controller_key_set_im_context(m_pFrame->m_pKeyController, nullptr); + gtk_event_controller_key_set_im_context(m_pFrame->m_pKeyController, nullptr); #endif - im_context_set_client_widget(m_pIMContext, nullptr); - GetGenericUnixSalData()->ErrorTrapPop(); - // destroy old IC - g_object_unref( m_pIMContext ); - m_pIMContext = nullptr; - } + im_context_set_client_widget(m_pIMContext, nullptr); + GetGenericUnixSalData()->ErrorTrapPop(); + // destroy old IC + g_object_unref( m_pIMContext ); + m_pIMContext = nullptr; } void GtkSalFrame::IMHandler::doCallEndExtTextInput() diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index b76bd0dac1f0..6a69b9909b7f 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -2771,22 +2771,22 @@ protected: } #if !GTK_CHECK_VERSION(4, 0, 0) - if (m_pMouseEventBox && m_pMouseEventBox != m_pWidget) - { - // put things back they way we found them - GtkWidget* pParent = gtk_widget_get_parent(m_pMouseEventBox); + if (!(m_pMouseEventBox && m_pMouseEventBox != m_pWidget)) + return; - g_object_ref(m_pWidget); - gtk_container_remove(GTK_CONTAINER(m_pMouseEventBox), m_pWidget); + // put things back they way we found them + GtkWidget* pParent = gtk_widget_get_parent(m_pMouseEventBox); - gtk_widget_destroy(m_pMouseEventBox); + g_object_ref(m_pWidget); + gtk_container_remove(GTK_CONTAINER(m_pMouseEventBox), m_pWidget); - gtk_container_add(GTK_CONTAINER(pParent), m_pWidget); - // coverity[freed_arg : FALSE] - this does not free m_pWidget, it is reffed by pParent - g_object_unref(m_pWidget); + gtk_widget_destroy(m_pMouseEventBox); - m_pMouseEventBox = m_pWidget; - } + gtk_container_add(GTK_CONTAINER(pParent), m_pWidget); + // coverity[freed_arg : FALSE] - this does not free m_pWidget, it is reffed by pParent + g_object_unref(m_pWidget); + + m_pMouseEventBox = m_pWidget; #endif } @@ -8891,22 +8891,22 @@ public: GtkWidget* pOverFlowWidget = GTK_WIDGET(m_pOverFlowNotebook); g_clear_pointer(&pOverFlowWidget, gtk_widget_unparent); #endif - if (m_pOverFlowBox) - { - // put it back to how we found it initially - GtkWidget* pParent = gtk_widget_get_parent(GTK_WIDGET(m_pOverFlowBox)); - g_object_ref(m_pNotebook); - container_remove(GTK_WIDGET(m_pOverFlowBox), GTK_WIDGET(m_pNotebook)); - container_add(GTK_WIDGET(pParent), GTK_WIDGET(m_pNotebook)); - g_object_unref(m_pNotebook); + if (!m_pOverFlowBox) + return; + + // put it back to how we found it initially + GtkWidget* pParent = gtk_widget_get_parent(GTK_WIDGET(m_pOverFlowBox)); + g_object_ref(m_pNotebook); + container_remove(GTK_WIDGET(m_pOverFlowBox), GTK_WIDGET(m_pNotebook)); + container_add(GTK_WIDGET(pParent), GTK_WIDGET(m_pNotebook)); + g_object_unref(m_pNotebook); #if !GTK_CHECK_VERSION(4, 0, 0) - gtk_widget_destroy(GTK_WIDGET(m_pOverFlowBox)); + gtk_widget_destroy(GTK_WIDGET(m_pOverFlowBox)); #else - GtkWidget* pOverFlowBox = GTK_WIDGET(m_pOverFlowBox); - g_clear_pointer(&pOverFlowBox, gtk_widget_unparent); + GtkWidget* pOverFlowBox = GTK_WIDGET(m_pOverFlowBox); + g_clear_pointer(&pOverFlowBox, gtk_widget_unparent); #endif - } } }; @@ -9848,21 +9848,21 @@ private: void ensure_image_widget() { - if (!m_pImage) - { + if (m_pImage) + return; + #if !GTK_CHECK_VERSION(4, 0, 0) - m_pImage = GTK_IMAGE(gtk_image_new()); - gtk_box_pack_start(m_pBox, GTK_WIDGET(m_pImage), false, false, 0); - gtk_box_reorder_child(m_pBox, GTK_WIDGET(m_pImage), 0); + m_pImage = GTK_IMAGE(gtk_image_new()); + gtk_box_pack_start(m_pBox, GTK_WIDGET(m_pImage), false, false, 0); + gtk_box_reorder_child(m_pBox, GTK_WIDGET(m_pImage), 0); #else - m_pImage = GTK_PICTURE(gtk_picture_new()); - gtk_widget_set_halign(GTK_WIDGET(m_pImage), GTK_ALIGN_CENTER); - gtk_widget_set_valign(GTK_WIDGET(m_pImage), GTK_ALIGN_CENTER); - gtk_box_prepend(m_pBox, GTK_WIDGET(m_pImage)); - gtk_widget_set_halign(m_pLabel, GTK_ALIGN_START); + m_pImage = GTK_PICTURE(gtk_picture_new()); + gtk_widget_set_halign(GTK_WIDGET(m_pImage), GTK_ALIGN_CENTER); + gtk_widget_set_valign(GTK_WIDGET(m_pImage), GTK_ALIGN_CENTER); + gtk_box_prepend(m_pBox, GTK_WIDGET(m_pImage)); + gtk_widget_set_halign(m_pLabel, GTK_ALIGN_START); #endif - gtk_widget_show(GTK_WIDGET(m_pImage)); - } + gtk_widget_show(GTK_WIDGET(m_pImage)); } #if GTK_CHECK_VERSION(4, 0, 0) @@ -19692,18 +19692,18 @@ private: menu_toggled(); bool bIsShown = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_pToggleButton)); - if (m_bPopupActive != bIsShown) + if (m_bPopupActive == bIsShown) + return; + + m_bPopupActive = bIsShown; + ComboBox::signal_popup_toggled(); + if (!m_bPopupActive && m_pEntry) { - m_bPopupActive = bIsShown; - ComboBox::signal_popup_toggled(); - if (!m_bPopupActive && m_pEntry) - { - disable_notify_events(); - //restore focus to the GtkEntry when the popup is gone, which - //is what the vcl case does, to ease the transition a little - gtk_widget_grab_focus(m_pEntry); - enable_notify_events(); - } + disable_notify_events(); + //restore focus to the GtkEntry when the popup is gone, which + //is what the vcl case does, to ease the transition a little + gtk_widget_grab_focus(m_pEntry); + enable_notify_events(); } } diff --git a/vcl/unx/gtk3/gtkobject.cxx b/vcl/unx/gtk3/gtkobject.cxx index d5fb4119a98b..d712dae3c8bb 100644 --- a/vcl/unx/gtk3/gtkobject.cxx +++ b/vcl/unx/gtk3/gtkobject.cxx @@ -110,22 +110,22 @@ GtkSalObjectBase::~GtkSalObjectBase() GtkSalObject::~GtkSalObject() { - if( m_pSocket ) - { + if( !m_pSocket ) + return; + #if GTK_CHECK_VERSION(4, 0, 0) - gtk_widget_unparent(m_pSocket); + gtk_widget_unparent(m_pSocket); #else - // remove socket from parent frame's fixed container - gtk_container_remove( GTK_CONTAINER(gtk_widget_get_parent(m_pSocket)), - m_pSocket ); - // get rid of the socket - // actually the gtk_container_remove should let the ref count - // of the socket sink to 0 and destroy it (see signalDestroy) - // this is just a sanity check - if( m_pSocket ) - gtk_widget_destroy( m_pSocket ); + // remove socket from parent frame's fixed container + gtk_container_remove( GTK_CONTAINER(gtk_widget_get_parent(m_pSocket)), + m_pSocket ); + // get rid of the socket + // actually the gtk_container_remove should let the ref count + // of the socket sink to 0 and destroy it (see signalDestroy) + // this is just a sanity check + if( m_pSocket ) + gtk_widget_destroy( m_pSocket ); #endif - } } void GtkSalObject::ResetClipRegion() @@ -357,24 +357,24 @@ GtkSalObjectWidgetClip::GtkSalObjectWidgetClip(GtkSalFrame* pParent, bool bShow) GtkSalObjectWidgetClip::~GtkSalObjectWidgetClip() { - if( m_pSocket ) - { - // remove socket from parent frame's fixed container + if( !m_pSocket ) + return; + + // remove socket from parent frame's fixed container #if !GTK_CHECK_VERSION(4, 0, 0) - gtk_container_remove( GTK_CONTAINER(gtk_widget_get_parent(m_pScrolledWindow)), - m_pScrolledWindow ); - - // get rid of the socket - // actually the gtk_container_remove should let the ref count - // of the socket sink to 0 and destroy it (see signalDestroy) - // this is just a sanity check - if( m_pScrolledWindow ) - gtk_widget_destroy( m_pScrolledWindow ); + gtk_container_remove( GTK_CONTAINER(gtk_widget_get_parent(m_pScrolledWindow)), + m_pScrolledWindow ); + + // get rid of the socket + // actually the gtk_container_remove should let the ref count + // of the socket sink to 0 and destroy it (see signalDestroy) + // this is just a sanity check + if( m_pScrolledWindow ) + gtk_widget_destroy( m_pScrolledWindow ); #else - gtk_fixed_remove(GTK_FIXED(gtk_widget_get_parent(m_pScrolledWindow)), - m_pScrolledWindow); + gtk_fixed_remove(GTK_FIXED(gtk_widget_get_parent(m_pScrolledWindow)), + m_pScrolledWindow); #endif - } } void GtkSalObjectWidgetClip::ResetClipRegion() diff --git a/vcl/unx/gtk3/gtksalmenu.cxx b/vcl/unx/gtk3/gtksalmenu.cxx index 9e7d9edf050f..e0a35c1d5404 100644 --- a/vcl/unx/gtk3/gtksalmenu.cxx +++ b/vcl/unx/gtk3/gtksalmenu.cxx @@ -856,19 +856,19 @@ void GtkSalMenu::RemoveMenuBarButton( sal_uInt16 nId ) { const auto it = std::find_if(maExtraButtons.begin(), maExtraButtons.end(), [&nId](const auto &item) { return item.first == nId; }); - if (it != maExtraButtons.end()) - { - gint nAttach(0); + if (it == maExtraButtons.end()) + return; + + gint nAttach(0); #if !GTK_CHECK_VERSION(4, 0, 0) - gtk_container_child_get(GTK_CONTAINER(mpMenuBarContainerWidget), it->second, "left-attach", &nAttach, nullptr); - gtk_widget_destroy(it->second); + gtk_container_child_get(GTK_CONTAINER(mpMenuBarContainerWidget), it->second, "left-attach", &nAttach, nullptr); + gtk_widget_destroy(it->second); #else - gtk_grid_query_child(GTK_GRID(mpMenuBarContainerWidget), it->second, &nAttach, nullptr, nullptr, nullptr); - g_clear_pointer(&(it->second), gtk_widget_unparent); + gtk_grid_query_child(GTK_GRID(mpMenuBarContainerWidget), it->second, &nAttach, nullptr, nullptr, nullptr); + g_clear_pointer(&(it->second), gtk_widget_unparent); #endif - gtk_grid_remove_column(GTK_GRID(mpMenuBarContainerWidget), nAttach); - maExtraButtons.erase(it); - } + gtk_grid_remove_column(GTK_GRID(mpMenuBarContainerWidget), nAttach); + maExtraButtons.erase(it); } tools::Rectangle GtkSalMenu::GetMenuBarButtonRectPixel(sal_uInt16 nId, SalFrame* pReferenceFrame) @@ -1103,20 +1103,20 @@ void GtkSalMenu::ApplyPersona() void GtkSalMenu::DestroyMenuBarWidget() { - if (mpMenuBarContainerWidget) - { + if (!mpMenuBarContainerWidget) + return; + #if !GTK_CHECK_VERSION(4, 0, 0) - // tdf#140225 call cancel before destroying it in case there are some - // active menus popped open - gtk_menu_shell_cancel(GTK_MENU_SHELL(mpMenuBarWidget)); + // tdf#140225 call cancel before destroying it in case there are some + // active menus popped open + gtk_menu_shell_cancel(GTK_MENU_SHELL(mpMenuBarWidget)); - gtk_widget_destroy(mpMenuBarContainerWidget); + gtk_widget_destroy(mpMenuBarContainerWidget); #else - g_clear_pointer(&mpMenuBarContainerWidget, gtk_widget_unparent); + g_clear_pointer(&mpMenuBarContainerWidget, gtk_widget_unparent); #endif - mpMenuBarContainerWidget = nullptr; - mpCloseButton = nullptr; - } + mpMenuBarContainerWidget = nullptr; + mpCloseButton = nullptr; } void GtkSalMenu::SetFrame(const SalFrame* pFrame) @@ -1438,21 +1438,21 @@ void GtkSalMenu::ActivateAllSubmenus(Menu* pMenuBar) // We can re-enter this method via the new event loop that gets created // in GtkClipboardTransferable::getTransferDataFlavorsAsVector, so use the InActivateCallback // flag to detect that and skip some startup work. - if (!mbInActivateCallback) + if (mbInActivateCallback) + return; + + mbInActivateCallback = true; + pMenuBar->HandleMenuActivateEvent(GetMenu()); + mbInActivateCallback = false; + for (GtkSalMenuItem* pSalItem : maItems) { - mbInActivateCallback = true; - pMenuBar->HandleMenuActivateEvent(GetMenu()); - mbInActivateCallback = false; - for (GtkSalMenuItem* pSalItem : maItems) + if ( pSalItem->mpSubMenu != nullptr ) { - if ( pSalItem->mpSubMenu != nullptr ) - { - pSalItem->mpSubMenu->ActivateAllSubmenus(pMenuBar); - } + pSalItem->mpSubMenu->ActivateAllSubmenus(pMenuBar); } - Update(); - pMenuBar->HandleMenuDeActivateEvent(GetMenu()); } + Update(); + pMenuBar->HandleMenuDeActivateEvent(GetMenu()); } void GtkSalMenu::ClearActionGroupAndMenuModel() diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx b/vcl/unx/gtk3/salnativewidgets-gtk.cxx index 8fe550371d7e..47556a97edc5 100644 --- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx @@ -744,30 +744,30 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, aTrackRect.GetWidth(), aTrackRect.GetHeight() ); // ----------------- THUMB - if ( has_slider ) - { - stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnThumbState); - if ( rScrollbarVal.mnThumbState & ControlState::PRESSED ) - stateFlags = static_cast<GtkStateFlags>(stateFlags | GTK_STATE_FLAG_PRELIGHT); + if ( !has_slider ) + return; - GtkStyleContext* pScrollbarSliderStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? - mpVScrollbarSliderStyle : mpHScrollbarSliderStyle; + stateFlags = NWConvertVCLStateToGTKState(rScrollbarVal.mnThumbState); + if ( rScrollbarVal.mnThumbState & ControlState::PRESSED ) + stateFlags = static_cast<GtkStateFlags>(stateFlags | GTK_STATE_FLAG_PRELIGHT); - gtk_style_context_set_state(pScrollbarSliderStyle, stateFlags); + GtkStyleContext* pScrollbarSliderStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? + mpVScrollbarSliderStyle : mpHScrollbarSliderStyle; - GtkBorder margin; - style_context_get_margin(pScrollbarSliderStyle, &margin); + gtk_style_context_set_state(pScrollbarSliderStyle, stateFlags); - gtk_render_background(pScrollbarSliderStyle, cr, - thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, - thumbRect.GetWidth() - margin.left - margin.right, - thumbRect.GetHeight() - margin.top - margin.bottom); + GtkBorder margin; + style_context_get_margin(pScrollbarSliderStyle, &margin); - gtk_render_frame(pScrollbarSliderStyle, cr, - thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, - thumbRect.GetWidth() - margin.left - margin.right, - thumbRect.GetHeight() - margin.top - margin.bottom); - } + gtk_render_background(pScrollbarSliderStyle, cr, + thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, + thumbRect.GetWidth() - margin.left - margin.right, + thumbRect.GetHeight() - margin.top - margin.bottom); + + gtk_render_frame(pScrollbarSliderStyle, cr, + thumbRect.Left() + margin.left, thumbRect.Top() + margin.top, + thumbRect.GetWidth() - margin.left - margin.right, + thumbRect.GetHeight() - margin.top - margin.bottom); } void GtkSalGraphics::PaintOneSpinButton( GtkStyleContext *context, diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index ec16cdd3b36e..d3ea9bcbe225 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -557,20 +557,20 @@ void GraphicImport::lcl_correctWord2007EffectExtent(const sal_Int32 nMSOAngle) // Word versions older than 14 do not swap width and height (see lcl_doMSOWidthHeightSwap) // and therefore generate different effectExtent. We correct them here. sal_Int16 nAngleDeg = (nMSOAngle / 60000) % 180; - if (nAngleDeg >= 45 && nAngleDeg < 135) - { - sal_Int32 nDiff = o3tl::convert( - (double(m_pImpl->getXSize()) - double(m_pImpl->getYSize())) / 2.0, - o3tl::Length::mm100, o3tl::Length::emu); - if (m_pImpl->m_oEffectExtentLeft) - *m_pImpl->m_oEffectExtentLeft += nDiff; - if (m_pImpl->m_oEffectExtentRight) - *m_pImpl->m_oEffectExtentRight += nDiff; - if (m_pImpl->m_oEffectExtentTop) - *m_pImpl->m_oEffectExtentTop -= nDiff; - if (m_pImpl->m_oEffectExtentBottom) - *m_pImpl->m_oEffectExtentBottom -= nDiff; - } + if (nAngleDeg < 45 || nAngleDeg >= 135) + return; + + sal_Int32 nDiff = o3tl::convert( + (double(m_pImpl->getXSize()) - double(m_pImpl->getYSize())) / 2.0, + o3tl::Length::mm100, o3tl::Length::emu); + if (m_pImpl->m_oEffectExtentLeft) + *m_pImpl->m_oEffectExtentLeft += nDiff; + if (m_pImpl->m_oEffectExtentRight) + *m_pImpl->m_oEffectExtentRight += nDiff; + if (m_pImpl->m_oEffectExtentTop) + *m_pImpl->m_oEffectExtentTop -= nDiff; + if (m_pImpl->m_oEffectExtentBottom) + *m_pImpl->m_oEffectExtentBottom -= nDiff; } static void lcl_doMSOWidthHeightSwap(awt::Point& rLeftTop, awt::Size& rSize, diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 60c3c03b8d51..bcfc0c10b510 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -416,24 +416,23 @@ void OOXMLFastContextHandler::startParagraphGroup() if (! mpParserState->isInSectionGroup()) startSectionGroup(); - if (! mpParserState->isInParagraphGroup()) - { - mpStream->startParagraphGroup(); - mpParserState->setInParagraphGroup(true); + if ( mpParserState->isInParagraphGroup()) + return; + + mpStream->startParagraphGroup(); + mpParserState->setInParagraphGroup(true); - if (const auto& pPropSet = getPropertySet()) + if (const auto& pPropSet = getPropertySet()) + { + OOXMLPropertySetEntryToString aHandler(NS_ooxml::LN_AG_Parids_paraId); + pPropSet->resolve(aHandler); + if (const OUString& sText = aHandler.getString(); !sText.isEmpty()) { - OOXMLPropertySetEntryToString aHandler(NS_ooxml::LN_AG_Parids_paraId); - pPropSet->resolve(aHandler); - if (const OUString& sText = aHandler.getString(); !sText.isEmpty()) - { - OOXMLStringValue::Pointer_t pVal = new OOXMLStringValue(sText); - OOXMLPropertySet::Pointer_t pPropertySet(new OOXMLPropertySet); - pPropertySet->add(NS_ooxml::LN_AG_Parids_paraId, pVal, OOXMLProperty::ATTRIBUTE); - mpStream->props(pPropertySet.get()); - } + OOXMLStringValue::Pointer_t pVal = new OOXMLStringValue(sText); + OOXMLPropertySet::Pointer_t pPropertySet(new OOXMLPropertySet); + pPropertySet->add(NS_ooxml::LN_AG_Parids_paraId, pVal, OOXMLProperty::ATTRIBUTE); + mpStream->props(pPropertySet.get()); } - } } diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index 5e0e46dabeb0..2fa78344835b 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -399,33 +399,33 @@ void SvXMLExport::DetermineModelType_() { meModelType = SvtModuleOptions::EFactory::UNKNOWN_FACTORY; - if ( mxModel.is() ) - { - meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel ); + if ( !mxModel.is() ) + return; + + meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel ); - // note: MATH documents will throw NotInitializedException; maybe unit test problem - if (meModelType == SvtModuleOptions::EFactory::WRITER) + // note: MATH documents will throw NotInitializedException; maybe unit test problem + if (meModelType == SvtModuleOptions::EFactory::WRITER) + { + uno::Reference<frame::XModule> const xModule(mxModel, uno::UNO_QUERY); + bool const isBaseForm(xModule.is() && + xModule->getIdentifier() == "com.sun.star.sdb.FormDesign"); + if (isBaseForm) { - uno::Reference<frame::XModule> const xModule(mxModel, uno::UNO_QUERY); - bool const isBaseForm(xModule.is() && - xModule->getIdentifier() == "com.sun.star.sdb.FormDesign"); - if (isBaseForm) + switch (GetODFSaneDefaultVersion()) { - switch (GetODFSaneDefaultVersion()) - { - case SvtSaveOptions::ODFSVER_013_EXTENDED: - SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); - mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012_EXTENDED; - maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012_EXTENDED); - break; - case SvtSaveOptions::ODFSVER_013: - SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); - mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012; - maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012); - break; - default: - break; - } + case SvtSaveOptions::ODFSVER_013_EXTENDED: + SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); + mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012_EXTENDED; + maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012_EXTENDED); + break; + case SvtSaveOptions::ODFSVER_013: + SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); + mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012; + maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012); + break; + default: + break; } } } diff --git a/xmloff/source/style/PageMasterImportPropMapper.cxx b/xmloff/source/style/PageMasterImportPropMapper.cxx index cee84997dfdd..b9850eaec618 100644 --- a/xmloff/source/style/PageMasterImportPropMapper.cxx +++ b/xmloff/source/style/PageMasterImportPropMapper.cxx @@ -446,65 +446,65 @@ void PageMasterImportPropertyMapper::finished(std::vector< XMLPropertyState >& r xFooterDynamic.reset(); } - if (pMarginGutter) - { - sal_Int32 nGutterMargin{}; - pMarginGutter->maValue >>= nGutterMargin; + if (!pMarginGutter) + return; + + sal_Int32 nGutterMargin{}; + pMarginGutter->maValue >>= nGutterMargin; - bool bGutterAtTop{}; - uno::Reference<lang::XServiceInfo> xSI(GetImport().GetModel(), uno::UNO_QUERY); - if (xSI.is() && xSI->supportsService("com.sun.star.text.TextDocument")) + bool bGutterAtTop{}; + uno::Reference<lang::XServiceInfo> xSI(GetImport().GetModel(), uno::UNO_QUERY); + if (xSI.is() && xSI->supportsService("com.sun.star.text.TextDocument")) + { + uno::Reference<lang::XMultiServiceFactory> xFac(GetImport().GetModel(), uno::UNO_QUERY); + if (xFac.is()) { - uno::Reference<lang::XMultiServiceFactory> xFac(GetImport().GetModel(), uno::UNO_QUERY); - if (xFac.is()) + uno::Reference<beans::XPropertySet> xProps( + xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + if (xProps.is()) { - uno::Reference<beans::XPropertySet> xProps( - xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); - if (xProps.is()) - { - xProps->getPropertyValue("GutterAtTop") >>= bGutterAtTop; - } + xProps->getPropertyValue("GutterAtTop") >>= bGutterAtTop; } } - if (bGutterAtTop) + } + if (bGutterAtTop) + { + if (nGutterMargin && pMargins[XML_LINE_TOP]) + { + // Decrease top margin to not include gutter. + sal_Int32 nTopMargin{}; + pMargins[XML_LINE_TOP]->maValue >>= nTopMargin; + nTopMargin -= nGutterMargin; + pMargins[XML_LINE_TOP]->maValue <<= nTopMargin; + } + } + else + { + bool bRtlGutter{}; + if (nGutterMargin && pRtlGutter) + { + pRtlGutter->maValue >>= bRtlGutter; + } + if (bRtlGutter) { - if (nGutterMargin && pMargins[XML_LINE_TOP]) + if (nGutterMargin && pMargins[XML_LINE_RIGHT]) { - // Decrease top margin to not include gutter. - sal_Int32 nTopMargin{}; - pMargins[XML_LINE_TOP]->maValue >>= nTopMargin; - nTopMargin -= nGutterMargin; - pMargins[XML_LINE_TOP]->maValue <<= nTopMargin; + // Decrease right margin to not include gutter. + sal_Int32 nRightMargin{}; + pMargins[XML_LINE_RIGHT]->maValue >>= nRightMargin; + nRightMargin -= nGutterMargin; + pMargins[XML_LINE_RIGHT]->maValue <<= nRightMargin; } } else { - bool bRtlGutter{}; - if (nGutterMargin && pRtlGutter) - { - pRtlGutter->maValue >>= bRtlGutter; - } - if (bRtlGutter) - { - if (nGutterMargin && pMargins[XML_LINE_RIGHT]) - { - // Decrease right margin to not include gutter. - sal_Int32 nRightMargin{}; - pMargins[XML_LINE_RIGHT]->maValue >>= nRightMargin; - nRightMargin -= nGutterMargin; - pMargins[XML_LINE_RIGHT]->maValue <<= nRightMargin; - } - } - else + if (nGutterMargin && pMargins[XML_LINE_LEFT]) { - if (nGutterMargin && pMargins[XML_LINE_LEFT]) - { - // Decrease left margin to not include gutter. - sal_Int32 nLeftMargin{}; - pMargins[XML_LINE_LEFT]->maValue >>= nLeftMargin; - nLeftMargin -= nGutterMargin; - pMargins[XML_LINE_LEFT]->maValue <<= nLeftMargin; - } + // Decrease left margin to not include gutter. + sal_Int32 nLeftMargin{}; + pMargins[XML_LINE_LEFT]->maValue >>= nLeftMargin; + nLeftMargin -= nGutterMargin; + pMargins[XML_LINE_LEFT]->maValue <<= nLeftMargin; } } } diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx index 87de784951cb..042a703982ba 100644 --- a/xmloff/source/style/XMLPageExport.cxx +++ b/xmloff/source/style/XMLPageExport.cxx @@ -226,24 +226,24 @@ XMLPageExport::XMLPageExport(SvXMLExport & rExp) } } - if (GetExport().GetModelType() == SvtModuleOptions::EFactory::WRITER) + if (GetExport().GetModelType() != SvtModuleOptions::EFactory::WRITER) + return; + + uno::Reference<lang::XMultiServiceFactory> xFac(GetExport().GetModel(), uno::UNO_QUERY); + if (!xFac.is()) + return; + + uno::Reference<beans::XPropertySet> xProps( + xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); + if (!xProps.is()) + return; + + bool bGutterAtTop{}; + xProps->getPropertyValue("GutterAtTop") >>= bGutterAtTop; + if (bGutterAtTop) { - uno::Reference<lang::XMultiServiceFactory> xFac(GetExport().GetModel(), uno::UNO_QUERY); - if (xFac.is()) - { - uno::Reference<beans::XPropertySet> xProps( - xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY); - if (xProps.is()) - { - bool bGutterAtTop{}; - xProps->getPropertyValue("GutterAtTop") >>= bGutterAtTop; - if (bGutterAtTop) - { - static_cast<XMLPageMasterExportPropMapper*>(xPageMasterExportPropMapper.get()) - ->SetGutterAtTop(true); - } - } - } + static_cast<XMLPageMasterExportPropMapper*>(xPageMasterExportPropMapper.get()) + ->SetGutterAtTop(true); } } diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index 823cdf79e904..bc2f7f948130 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -2069,68 +2069,68 @@ void SvXMLNumFormatContext::AddColor( Color const nColor ) void SvXMLNumFormatContext::UpdateCalendar( const OUString& rNewCalendar ) { - if ( rNewCalendar != sCalendar ) + if ( rNewCalendar == sCalendar ) + return; + + if (rNewCalendar.isEmpty() || rNewCalendar == aImplicitCalendar[0]) { - if (rNewCalendar.isEmpty() || rNewCalendar == aImplicitCalendar[0]) - { - eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? - ImplicitCalendar::DEFAULT_FROM_OTHER : ImplicitCalendar::DEFAULT); - } - else if (aImplicitCalendar[0].isEmpty() && rNewCalendar == GetLocaleData().getDefaultCalendar()->Name) - { - eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? - ImplicitCalendar::DEFAULT_FROM_OTHER : ImplicitCalendar::DEFAULT); - aImplicitCalendar[0] = rNewCalendar; - } - else if (rNewCalendar == aImplicitCalendar[1]) - { - eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? - ImplicitCalendar::SECONDARY_FROM_OTHER : ImplicitCalendar::SECONDARY); - } - else if (aImplicitCalendar[1].isEmpty() && GetLocaleData().doesSecondaryCalendarUseEC( rNewCalendar)) - { - eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? - ImplicitCalendar::SECONDARY_FROM_OTHER : ImplicitCalendar::SECONDARY); - aImplicitCalendar[1] = rNewCalendar; - } - else + eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? + ImplicitCalendar::DEFAULT_FROM_OTHER : ImplicitCalendar::DEFAULT); + } + else if (aImplicitCalendar[0].isEmpty() && rNewCalendar == GetLocaleData().getDefaultCalendar()->Name) + { + eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? + ImplicitCalendar::DEFAULT_FROM_OTHER : ImplicitCalendar::DEFAULT); + aImplicitCalendar[0] = rNewCalendar; + } + else if (rNewCalendar == aImplicitCalendar[1]) + { + eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? + ImplicitCalendar::SECONDARY_FROM_OTHER : ImplicitCalendar::SECONDARY); + } + else if (aImplicitCalendar[1].isEmpty() && GetLocaleData().doesSecondaryCalendarUseEC( rNewCalendar)) + { + eImplicitCalendar = (eImplicitCalendar == ImplicitCalendar::OTHER ? + ImplicitCalendar::SECONDARY_FROM_OTHER : ImplicitCalendar::SECONDARY); + aImplicitCalendar[1] = rNewCalendar; + } + else + { + eImplicitCalendar = ImplicitCalendar::OTHER; + } + + if (eImplicitCalendar != ImplicitCalendar::DEFAULT && eImplicitCalendar != ImplicitCalendar::SECONDARY) + { + // A switch from empty default calendar to named default calendar or + // vice versa is not a switch. + bool bSameDefault = false; + if (sCalendar.isEmpty() || rNewCalendar.isEmpty()) { - eImplicitCalendar = ImplicitCalendar::OTHER; + // As both are not equal, only one can be empty here, the other + // can not. + const OUString& rDefaultCalendar = GetLocaleData().getDefaultCalendar()->Name; + // So if one is the named default calendar the other is the + // empty default calendar. + bSameDefault = (rNewCalendar == rDefaultCalendar || sCalendar == rDefaultCalendar); } - - if (eImplicitCalendar != ImplicitCalendar::DEFAULT && eImplicitCalendar != ImplicitCalendar::SECONDARY) + if (!bSameDefault) { - // A switch from empty default calendar to named default calendar or - // vice versa is not a switch. - bool bSameDefault = false; - if (sCalendar.isEmpty() || rNewCalendar.isEmpty()) + aFormatCode.append( "[~" ); // intro for calendar code + if (rNewCalendar.isEmpty()) { - // As both are not equal, only one can be empty here, the other - // can not. - const OUString& rDefaultCalendar = GetLocaleData().getDefaultCalendar()->Name; - // So if one is the named default calendar the other is the - // empty default calendar. - bSameDefault = (rNewCalendar == rDefaultCalendar || sCalendar == rDefaultCalendar); + // Empty calendar name here means switching to default calendar + // from a different calendar. Needs to be explicitly stated in + // format code. + aFormatCode.append( GetLocaleData().getDefaultCalendar()->Name ); } - if (!bSameDefault) + else { - aFormatCode.append( "[~" ); // intro for calendar code - if (rNewCalendar.isEmpty()) - { - // Empty calendar name here means switching to default calendar - // from a different calendar. Needs to be explicitly stated in - // format code. - aFormatCode.append( GetLocaleData().getDefaultCalendar()->Name ); - } - else - { - aFormatCode.append( rNewCalendar ); - } - aFormatCode.append( ']' ); // end of calendar code + aFormatCode.append( rNewCalendar ); } + aFormatCode.append( ']' ); // end of calendar code } - sCalendar = rNewCalendar; } + sCalendar = rNewCalendar; } bool SvXMLNumFormatContext::IsSystemLanguage() const diff --git a/xmloff/source/text/XMLIndexTOCContext.cxx b/xmloff/source/text/XMLIndexTOCContext.cxx index 8dd1dac881c7..e7235f093efa 100644 --- a/xmloff/source/text/XMLIndexTOCContext.cxx +++ b/xmloff/source/text/XMLIndexTOCContext.cxx @@ -248,28 +248,28 @@ void XMLIndexTOCContext::endFastElement(sal_Int32 ) { // complete import of index by removing the markers (if the index // was actually inserted, that is) - if( bValid ) - { - // preliminaries - rtl::Reference<XMLTextImportHelper> rHelper= GetImport().GetTextImport(); + if( !bValid ) + return; - // get rid of last paragraph (unless it's the only paragraph) - rHelper->GetCursor()->goRight(1, false); - if( xBodyContextRef.is() && xBodyContextRef->HasContent() ) - { - rHelper->GetCursor()->goLeft(1, true); - rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), - "", true); - } + // preliminaries + rtl::Reference<XMLTextImportHelper> rHelper= GetImport().GetTextImport(); - // and delete second marker - rHelper->GetCursor()->goRight(1, true); + // get rid of last paragraph (unless it's the only paragraph) + rHelper->GetCursor()->goRight(1, false); + if( xBodyContextRef.is() && xBodyContextRef->HasContent() ) + { + rHelper->GetCursor()->goLeft(1, true); rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), "", true); - - // check for Redlines on our end node - GetImport().GetTextImport()->RedlineAdjustStartNodeCursor(); } + + // and delete second marker + rHelper->GetCursor()->goRight(1, true); + rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), + "", true); + + // check for Redlines on our end node + GetImport().GetTextImport()->RedlineAdjustStartNodeCursor(); } css::uno::Reference< css::xml::sax::XFastContextHandler > XMLIndexTOCContext::createFastChildContext( diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 01ac94d097f2..9c05e72f9708 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -715,33 +715,33 @@ void XMLTextImportHelper::InsertString( const OUString& rChars, { assert(m_xImpl->m_xText.is()); assert(m_xImpl->m_xCursorAsRange.is()); - if (m_xImpl->m_xText.is()) - { - sal_Int32 nLen = rChars.getLength(); - OUStringBuffer sChars( nLen ); + if (!m_xImpl->m_xText.is()) + return; + + sal_Int32 nLen = rChars.getLength(); + OUStringBuffer sChars( nLen ); - for( sal_Int32 i=0; i < nLen; i++ ) + for( sal_Int32 i=0; i < nLen; i++ ) + { + sal_Unicode c = rChars[i]; + switch( c ) { - sal_Unicode c = rChars[i]; - switch( c ) - { - case 0x20: - case 0x09: - case 0x0a: - case 0x0d: - if( !rIgnoreLeadingSpace ) - sChars.append( u' ' ); - rIgnoreLeadingSpace = true; - break; - default: - rIgnoreLeadingSpace = false; - sChars.append( c ); - break; - } + case 0x20: + case 0x09: + case 0x0a: + case 0x0d: + if( !rIgnoreLeadingSpace ) + sChars.append( u' ' ); + rIgnoreLeadingSpace = true; + break; + default: + rIgnoreLeadingSpace = false; + sChars.append( c ); + break; } - m_xImpl->m_xText->insertString(m_xImpl->m_xCursorAsRange, - sChars.makeStringAndClear(), false); } + m_xImpl->m_xText->insertString(m_xImpl->m_xCursorAsRange, + sChars.makeStringAndClear(), false); } void XMLTextImportHelper::InsertControlCharacter( sal_Int16 nControl ) @@ -1458,46 +1458,46 @@ void XMLTextImportHelper::FindOutlineStyleName( OUString& rStyleName, sal_Int8 nOutlineLevel ) { // style name empty? - if( rStyleName.isEmpty() ) + if( !rStyleName.isEmpty() ) + return; + + // Empty? Then we need o do stuff. Let's do error checking first. + if (m_xImpl->m_xChapterNumbering.is() && + ( nOutlineLevel > 0 ) && + (nOutlineLevel <= m_xImpl->m_xChapterNumbering->getCount())) { - // Empty? Then we need o do stuff. Let's do error checking first. - if (m_xImpl->m_xChapterNumbering.is() && - ( nOutlineLevel > 0 ) && - (nOutlineLevel <= m_xImpl->m_xChapterNumbering->getCount())) - { - nOutlineLevel--; // for the remainder, the level's are 0-based + nOutlineLevel--; // for the remainder, the level's are 0-based - // empty style name: look-up previously used name + // empty style name: look-up previously used name - // if we don't have a previously used name, we'll use the default - m_xImpl->InitOutlineStylesCandidates(); - if (m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].empty()) + // if we don't have a previously used name, we'll use the default + m_xImpl->InitOutlineStylesCandidates(); + if (m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].empty()) + { + // no other name used previously? Then use default + + // iterate over property value sequence to find the style name + Sequence<PropertyValue> aProperties; + m_xImpl->m_xChapterNumbering->getByIndex( nOutlineLevel ) + >>= aProperties; + auto pProp = std::find_if(std::cbegin(aProperties), std::cend(aProperties), + [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; }); + if (pProp != std::cend(aProperties)) { - // no other name used previously? Then use default - - // iterate over property value sequence to find the style name - Sequence<PropertyValue> aProperties; - m_xImpl->m_xChapterNumbering->getByIndex( nOutlineLevel ) - >>= aProperties; - auto pProp = std::find_if(std::cbegin(aProperties), std::cend(aProperties), - [](const PropertyValue& rProp) { return rProp.Name == "HeadingStyleName"; }); - if (pProp != std::cend(aProperties)) - { - OUString aOutlineStyle; - pProp->Value >>= aOutlineStyle; - m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel] - .push_back( aOutlineStyle ); - } + OUString aOutlineStyle; + pProp->Value >>= aOutlineStyle; + m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel] + .push_back( aOutlineStyle ); } - - // finally, we'll use the previously used style name for this - // format (or the default we've just put into that style) - // take last added one (#i71249#) - rStyleName = - m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].back(); } - // else: nothing we can do, so we'll leave it empty + + // finally, we'll use the previously used style name for this + // format (or the default we've just put into that style) + // take last added one (#i71249#) + rStyleName = + m_xImpl->m_xOutlineStylesCandidates[nOutlineLevel].back(); } + // else: nothing we can do, so we'll leave it empty // else: we already had a style name, so we let it pass. } @@ -1666,29 +1666,29 @@ void XMLTextImportHelper::SetHyperlink( } } - if (m_xImpl->m_xTextStyles.is()) + if (!m_xImpl->m_xTextStyles.is()) + return; + + OUString sDisplayName( + rImport.GetStyleDisplayName( + XmlStyleFamily::TEXT_TEXT, rStyleName ) ); + if( !sDisplayName.isEmpty() && + xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) && + m_xImpl->m_xTextStyles->hasByName(sDisplayName)) { - OUString sDisplayName( - rImport.GetStyleDisplayName( - XmlStyleFamily::TEXT_TEXT, rStyleName ) ); - if( !sDisplayName.isEmpty() && - xPropSetInfo->hasPropertyByName(s_UnvisitedCharStyleName) && - m_xImpl->m_xTextStyles->hasByName(sDisplayName)) - { - xPropSet->setPropertyValue(s_UnvisitedCharStyleName, - makeAny(sDisplayName)); - } + xPropSet->setPropertyValue(s_UnvisitedCharStyleName, + makeAny(sDisplayName)); + } - sDisplayName = - rImport.GetStyleDisplayName( - XmlStyleFamily::TEXT_TEXT, rVisitedStyleName ); - if( !sDisplayName.isEmpty() && - xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) && - m_xImpl->m_xTextStyles->hasByName(sDisplayName)) - { - xPropSet->setPropertyValue(s_VisitedCharStyleName, - makeAny(sDisplayName)); - } + sDisplayName = + rImport.GetStyleDisplayName( + XmlStyleFamily::TEXT_TEXT, rVisitedStyleName ); + if( !sDisplayName.isEmpty() && + xPropSetInfo->hasPropertyByName(s_VisitedCharStyleName) && + m_xImpl->m_xTextStyles->hasByName(sDisplayName)) + { + xPropSet->setPropertyValue(s_VisitedCharStyleName, + makeAny(sDisplayName)); } } @@ -1704,35 +1704,35 @@ void XMLTextImportHelper::SetRuby( OUString sRubyText("RubyText"); // if we have one Ruby property, we assume all of them are present - if (xPropSet.is() && - xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText )) - { - // the ruby text - xPropSet->setPropertyValue(sRubyText, makeAny(rText)); + if (!xPropSet.is() || + !xPropSet->getPropertySetInfo()->hasPropertyByName( sRubyText )) + return; - // the ruby style (ruby-adjust) - if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is()) - { - const SvXMLStyleContext* pTempStyle = - m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_RUBY, - rStyleName, true ); - XMLPropStyleContext *pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle)); + // the ruby text + xPropSet->setPropertyValue(sRubyText, makeAny(rText)); - if (nullptr != pStyle) - pStyle->FillPropertySet( xPropSet ); - } + // the ruby style (ruby-adjust) + if (!rStyleName.isEmpty() && m_xImpl->m_xAutoStyles.is()) + { + const SvXMLStyleContext* pTempStyle = + m_xImpl->m_xAutoStyles->FindStyleChildContext( XmlStyleFamily::TEXT_RUBY, + rStyleName, true ); + XMLPropStyleContext *pStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pTempStyle)); + + if (nullptr != pStyle) + pStyle->FillPropertySet( xPropSet ); + } - // the ruby text character style - if (m_xImpl->m_xTextStyles.is()) + // the ruby text character style + if (m_xImpl->m_xTextStyles.is()) + { + OUString sDisplayName( + rImport.GetStyleDisplayName( + XmlStyleFamily::TEXT_TEXT, rTextStyleName ) ); + if( (!sDisplayName.isEmpty()) && + m_xImpl->m_xTextStyles->hasByName( sDisplayName )) { - OUString sDisplayName( - rImport.GetStyleDisplayName( - XmlStyleFamily::TEXT_TEXT, rTextStyleName ) ); - if( (!sDisplayName.isEmpty()) && - m_xImpl->m_xTextStyles->hasByName( sDisplayName )) - { - xPropSet->setPropertyValue("RubyCharStyleName", makeAny(sDisplayName)); - } + xPropSet->setPropertyValue("RubyCharStyleName", makeAny(sDisplayName)); } } } @@ -2191,22 +2191,22 @@ void XMLTextImportHelper::ConnectFrameChains( m_xImpl->m_xNextFrmNames->push_back(sNextFrmName); } } - if (m_xImpl->m_xPrevFrmNames && !m_xImpl->m_xPrevFrmNames->empty()) + if (!m_xImpl->m_xPrevFrmNames || m_xImpl->m_xPrevFrmNames->empty()) + return; + + for(std::vector<OUString>::iterator i = m_xImpl->m_xPrevFrmNames->begin(), j = m_xImpl->m_xNextFrmNames->begin(); i != m_xImpl->m_xPrevFrmNames->end() && j != m_xImpl->m_xNextFrmNames->end(); ++i, ++j) { - for(std::vector<OUString>::iterator i = m_xImpl->m_xPrevFrmNames->begin(), j = m_xImpl->m_xNextFrmNames->begin(); i != m_xImpl->m_xPrevFrmNames->end() && j != m_xImpl->m_xNextFrmNames->end(); ++i, ++j) + if((*j) == rFrmName) { - if((*j) == rFrmName) - { - // The previous frame must exist, because it existing than - // inserting the entry - rFrmPropSet->setPropertyValue("ChainPrevName", makeAny(*i)); + // The previous frame must exist, because it existing than + // inserting the entry + rFrmPropSet->setPropertyValue("ChainPrevName", makeAny(*i)); - i = m_xImpl->m_xPrevFrmNames->erase(i); - j = m_xImpl->m_xNextFrmNames->erase(j); + i = m_xImpl->m_xPrevFrmNames->erase(i); + j = m_xImpl->m_xNextFrmNames->erase(j); - // There cannot be more than one previous frames - break; - } + // There cannot be more than one previous frames + break; } } } diff --git a/xmlsecurity/source/helper/ooxmlsecparser.cxx b/xmlsecurity/source/helper/ooxmlsecparser.cxx index a4e46951bf51..2692190ccb89 100644 --- a/xmlsecurity/source/helper/ooxmlsecparser.cxx +++ b/xmlsecurity/source/helper/ooxmlsecparser.cxx @@ -373,21 +373,21 @@ class OOXMLSecParser::DsDigestMethodContext OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); SAL_WARN_IF( ouAlgorithm.isEmpty(), "xmlsecurity.helper", "no Algorithm in Reference" ); - if (!ouAlgorithm.isEmpty()) - { - SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 - && ouAlgorithm != ALGO_XMLDSIGSHA256 - && ouAlgorithm != ALGO_XMLDSIGSHA512, - "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); - if (ouAlgorithm == ALGO_XMLDSIGSHA1) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; - else if (ouAlgorithm == ALGO_XMLDSIGSHA256) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; - else if (ouAlgorithm == ALGO_XMLDSIGSHA512) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; - else - m_rReferenceDigestID = 0; - } + if (ouAlgorithm.isEmpty()) + return; + + SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 + && ouAlgorithm != ALGO_XMLDSIGSHA256 + && ouAlgorithm != ALGO_XMLDSIGSHA512, + "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); + if (ouAlgorithm == ALGO_XMLDSIGSHA1) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; + else if (ouAlgorithm == ALGO_XMLDSIGSHA256) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; + else if (ouAlgorithm == ALGO_XMLDSIGSHA512) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; + else + m_rReferenceDigestID = 0; } }; @@ -1272,17 +1272,15 @@ void SAL_CALL OOXMLSecParser::startElement(const OUString& rName, const uno::Ref if (m_ContextStack.empty()) { - if (nPrefix == XML_NAMESPACE_DS - && localName == "Signature") - { - pContext.reset(new DsSignatureContext(*this, std::move(pRewindMap))); - } - else + if (nPrefix != XML_NAMESPACE_DS || localName != "Signature") { throw css::xml::sax::SAXException( "xmlsecurity: unexpected root element", nullptr, css::uno::Any()); } + + pContext.reset(new DsSignatureContext(*this, std::move(pRewindMap))); + } else { diff --git a/xmlsecurity/source/helper/xsecparser.cxx b/xmlsecurity/source/helper/xsecparser.cxx index b31f961e3548..af3562f46c40 100644 --- a/xmlsecurity/source/helper/xsecparser.cxx +++ b/xmlsecurity/source/helper/xsecparser.cxx @@ -492,21 +492,21 @@ class XSecParser::DsDigestMethodContext OUString ouAlgorithm = xAttrs->getValueByName("Algorithm"); SAL_WARN_IF( ouAlgorithm.isEmpty(), "xmlsecurity.helper", "no Algorithm in Reference" ); - if (!ouAlgorithm.isEmpty()) - { - SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 - && ouAlgorithm != ALGO_XMLDSIGSHA256 - && ouAlgorithm != ALGO_XMLDSIGSHA512, - "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); - if (ouAlgorithm == ALGO_XMLDSIGSHA1) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; - else if (ouAlgorithm == ALGO_XMLDSIGSHA256) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; - else if (ouAlgorithm == ALGO_XMLDSIGSHA512) - m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; - else - m_rReferenceDigestID = 0; - } + if (ouAlgorithm.isEmpty()) + return; + + SAL_WARN_IF( ouAlgorithm != ALGO_XMLDSIGSHA1 + && ouAlgorithm != ALGO_XMLDSIGSHA256 + && ouAlgorithm != ALGO_XMLDSIGSHA512, + "xmlsecurity.helper", "Algorithm neither SHA1, SHA256 nor SHA512"); + if (ouAlgorithm == ALGO_XMLDSIGSHA1) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA1; + else if (ouAlgorithm == ALGO_XMLDSIGSHA256) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA256; + else if (ouAlgorithm == ALGO_XMLDSIGSHA512) + m_rReferenceDigestID = css::xml::crypto::DigestID::SHA512; + else + m_rReferenceDigestID = 0; } }; @@ -1508,17 +1508,16 @@ void SAL_CALL XSecParser::startElement( if (m_ContextStack.empty()) { - if ((nPrefix == XML_NAMESPACE_DSIG || nPrefix == XML_NAMESPACE_DSIG_OOO) - && localName == "document-signatures") - { - pContext.reset(new DsigSignaturesContext(*this, std::move(pRewindMap))); - } - else + if ((nPrefix != XML_NAMESPACE_DSIG && nPrefix != XML_NAMESPACE_DSIG_OOO) + || localName != "document-signatures") { throw css::xml::sax::SAXException( "xmlsecurity: unexpected root element", nullptr, css::uno::Any()); } + + pContext.reset(new DsigSignaturesContext(*this, std::move(pRewindMap))); + } else { |