From 3e57aad962c9d24c535daff893db203314709cfc Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 17 Apr 2020 14:48:19 +0200 Subject: loplugin:flatten in cui Change-Id: I0ea0784ab8c4542747da1e15fa7c60c60bccb602 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92423 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cui/source/customize/SvxMenuConfigPage.cxx | 68 +-- cui/source/customize/SvxToolbarConfigPage.cxx | 52 +- cui/source/customize/cfg.cxx | 120 ++--- cui/source/customize/macropg.cxx | 22 +- cui/source/dialogs/QrCodeGenDialog.cxx | 112 ++-- cui/source/dialogs/SignSignatureLineDialog.cxx | 30 +- cui/source/dialogs/SignatureLineDialog.cxx | 87 ++- cui/source/dialogs/SpellDialog.cxx | 72 +-- cui/source/dialogs/colorpicker.cxx | 24 +- cui/source/dialogs/cuigaldlg.cxx | 176 +++--- cui/source/dialogs/cuihyperdlg.cxx | 24 +- cui/source/dialogs/hangulhanjadlg.cxx | 138 ++--- cui/source/dialogs/hldocntp.cxx | 134 ++--- cui/source/dialogs/hldoctp.cxx | 20 +- cui/source/dialogs/hltpbase.cxx | 78 +-- cui/source/dialogs/hyphen.cxx | 28 +- cui/source/dialogs/iconcdlg.cxx | 76 +-- cui/source/dialogs/linkdlg.cxx | 200 +++---- cui/source/dialogs/multipat.cxx | 80 +-- cui/source/dialogs/screenshotannotationdlg.cxx | 214 ++++---- cui/source/dialogs/scriptdlg.cxx | 196 +++---- cui/source/options/dbregister.cxx | 22 +- cui/source/options/optaboutconfig.cxx | 356 ++++++------- cui/source/options/optchart.cxx | 36 +- cui/source/options/optcolor.cxx | 83 +-- cui/source/options/optdict.cxx | 76 +-- cui/source/options/optgdlg.cxx | 56 +- cui/source/options/optgenrl.cxx | 26 +- cui/source/options/optinet2.cxx | 36 +- cui/source/options/optjava.cxx | 74 +-- cui/source/options/optlingu.cxx | 238 ++++----- cui/source/options/optpath.cxx | 28 +- cui/source/options/optsave.cxx | 26 +- cui/source/options/treeopt.cxx | 52 +- cui/source/tabpages/autocdlg.cxx | 96 ++-- cui/source/tabpages/backgrnd.cxx | 76 +-- cui/source/tabpages/chardlg.cxx | 54 +- cui/source/tabpages/labdlg.cxx | 22 +- cui/source/tabpages/numfmt.cxx | 74 +-- cui/source/tabpages/numpages.cxx | 709 ++++++++++++------------- cui/source/tabpages/page.cxx | 256 ++++----- cui/source/tabpages/paragrph.cxx | 80 +-- cui/source/tabpages/swpossizetabpage.cxx | 167 +++--- cui/source/tabpages/textanim.cxx | 135 +++-- cui/source/tabpages/textattr.cxx | 142 ++--- cui/source/tabpages/tpbitmap.cxx | 214 ++++---- cui/source/tabpages/tpcolor.cxx | 120 ++--- cui/source/tabpages/tpgradnt.cxx | 238 ++++----- cui/source/tabpages/tphatch.cxx | 156 +++--- cui/source/tabpages/tpline.cxx | 138 ++--- cui/source/tabpages/tplnedef.cxx | 200 +++---- cui/source/tabpages/tplneend.cxx | 200 +++---- cui/source/tabpages/tppattern.cxx | 206 +++---- cui/source/tabpages/tpshadow.cxx | 60 +-- cui/source/tabpages/transfrm.cxx | 176 +++--- 55 files changed, 3287 insertions(+), 3292 deletions(-) diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx index d2cd438d4e35..064a0d508f8c 100644 --- a/cui/source/customize/SvxMenuConfigPage.cxx +++ b/cui/source/customize/SvxMenuConfigPage.cxx @@ -221,33 +221,33 @@ void SvxMenuConfigPage::DeleteSelectedContent() { int nActEntry = m_xContentsListBox->get_selected_index(); - if (nActEntry != -1) - { - // get currently selected menu entry - SvxConfigEntry* pMenuEntry = - reinterpret_cast(m_xContentsListBox->get_id(nActEntry).toInt64()); + if (nActEntry == -1) + return; - // get currently selected menu - SvxConfigEntry* pMenu = GetTopLevelSelection(); + // get currently selected menu entry + SvxConfigEntry* pMenuEntry = + reinterpret_cast(m_xContentsListBox->get_id(nActEntry).toInt64()); - // remove menu entry from the list for this menu - SvxConfigPageHelper::RemoveEntry( pMenu->GetEntries(), pMenuEntry ); + // get currently selected menu + SvxConfigEntry* pMenu = GetTopLevelSelection(); - // remove menu entry from UI - m_xContentsListBox->remove(nActEntry); + // remove menu entry from the list for this menu + SvxConfigPageHelper::RemoveEntry( pMenu->GetEntries(), pMenuEntry ); - // if this is a submenu entry, redraw the menus list box - if ( pMenuEntry->IsPopup() ) - { - ReloadTopLevelListBox(); - } + // remove menu entry from UI + m_xContentsListBox->remove(nActEntry); - // delete data for menu entry - delete pMenuEntry; - - GetSaveInData()->SetModified(); - pMenu->SetModified(); + // if this is a submenu entry, redraw the menus list box + if ( pMenuEntry->IsPopup() ) + { + ReloadTopLevelListBox(); } + + // delete data for menu entry + delete pMenuEntry; + + GetSaveInData()->SetModified(); + pMenu->SetModified(); } short SvxMenuConfigPage::QueryReset() @@ -489,23 +489,23 @@ IMPL_LINK_NOARG(SvxMenuConfigPage, ResetMenuHdl, weld::Button&, void) // Resetting individual top-level menus is not possible at the moment. // So we are resetting only if it is a context menu - if (!m_bIsMenuBar && xQueryBox->run() == RET_YES) - { - sal_Int32 nPos = m_xTopLevelListBox->get_active(); - ContextMenuSaveInData* pSaveInData = static_cast< ContextMenuSaveInData* >(GetSaveInData()); + if (!(!m_bIsMenuBar && xQueryBox->run() == RET_YES)) + return; - pSaveInData->ResetContextMenu(pMenuData); + sal_Int32 nPos = m_xTopLevelListBox->get_active(); + ContextMenuSaveInData* pSaveInData = static_cast< ContextMenuSaveInData* >(GetSaveInData()); - // ensure that the UI is cleared before populating it - m_xTopLevelListBox->clear(); - m_xContentsListBox->clear(); + pSaveInData->ResetContextMenu(pMenuData); - ReloadTopLevelListBox(); + // ensure that the UI is cleared before populating it + m_xTopLevelListBox->clear(); + m_xContentsListBox->clear(); - // Reselect the reset menu - m_xTopLevelListBox->set_active(nPos); - SelectElement(); - } + ReloadTopLevelListBox(); + + // Reselect the reset menu + m_xTopLevelListBox->set_active(nPos); + SelectElement(); } SaveInData* SvxMenuConfigPage::CreateSaveInData( diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx index 6fa173e958a1..dfe66d4e3721 100644 --- a/cui/source/customize/SvxToolbarConfigPage.cxx +++ b/cui/source/customize/SvxToolbarConfigPage.cxx @@ -204,39 +204,39 @@ void SvxToolbarConfigPage::DeleteSelectedContent() { int nActEntry = m_xContentsListBox->get_selected_index(); - if (nActEntry != -1) - { - // get currently selected entry - SvxConfigEntry* pEntry = - reinterpret_cast(m_xContentsListBox->get_id(nActEntry).toInt64()); + if (nActEntry == -1) + return; - SvxConfigEntry* pToolbar = GetTopLevelSelection(); + // get currently selected entry + SvxConfigEntry* pEntry = + reinterpret_cast(m_xContentsListBox->get_id(nActEntry).toInt64()); - // remove entry from the list for this toolbar - SvxConfigPageHelper::RemoveEntry( pToolbar->GetEntries(), pEntry ); + SvxConfigEntry* pToolbar = GetTopLevelSelection(); - // remove toolbar entry from UI - m_xContentsListBox->remove(nActEntry); + // remove entry from the list for this toolbar + SvxConfigPageHelper::RemoveEntry( pToolbar->GetEntries(), pEntry ); - // delete data for toolbar entry - delete pEntry; + // remove toolbar entry from UI + m_xContentsListBox->remove(nActEntry); - static_cast(GetSaveInData())->ApplyToolbar( pToolbar ); - UpdateButtonStates(); + // delete data for toolbar entry + delete pEntry; + + static_cast(GetSaveInData())->ApplyToolbar( pToolbar ); + UpdateButtonStates(); - // if this is the last entry in the toolbar and it is a user - // defined toolbar pop up a dialog asking the user if they - // want to delete the toolbar - if ( m_xContentsListBox->n_children() == 0 && - GetTopLevelSelection()->IsDeletable() ) + // if this is the last entry in the toolbar and it is a user + // defined toolbar pop up a dialog asking the user if they + // want to delete the toolbar + if ( m_xContentsListBox->n_children() == 0 && + GetTopLevelSelection()->IsDeletable() ) + { + std::unique_ptr xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), + VclMessageType::Question, VclButtonsType::YesNo, + CuiResId(RID_SXVSTR_CONFIRM_DELETE_TOOLBAR))); + if (xQueryBox->run() == RET_YES) { - std::unique_ptr xQueryBox(Application::CreateMessageDialog(GetFrameWeld(), - VclMessageType::Question, VclButtonsType::YesNo, - CuiResId(RID_SXVSTR_CONFIRM_DELETE_TOOLBAR))); - if (xQueryBox->run() == RET_YES) - { - DeleteSelectedTopLevel(); - } + DeleteSelectedTopLevel(); } } } diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index ab240c2eba27..cc1c210819c9 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -1970,22 +1970,22 @@ void ToolbarSaveInData::SetSystemStyle( window = VCLUnoHelper::GetWindow( xWindow ).get(); } - if ( window != nullptr && window->GetType() == WindowType::TOOLBOX ) - { - ToolBox* toolbox = static_cast(window); + if ( !(window != nullptr && window->GetType() == WindowType::TOOLBOX) ) + return; - if ( nStyle == 0 ) - { - toolbox->SetButtonType( ButtonType::SYMBOLONLY ); - } - else if ( nStyle == 1 ) - { - toolbox->SetButtonType( ButtonType::TEXT ); - } - if ( nStyle == 2 ) - { - toolbox->SetButtonType( ButtonType::SYMBOLTEXT ); - } + ToolBox* toolbox = static_cast(window); + + if ( nStyle == 0 ) + { + toolbox->SetButtonType( ButtonType::SYMBOLONLY ); + } + else if ( nStyle == 1 ) + { + toolbox->SetButtonType( ButtonType::TEXT ); + } + if ( nStyle == 2 ) + { + toolbox->SetButtonType( ButtonType::SYMBOLTEXT ); } } @@ -1993,38 +1993,38 @@ void ToolbarSaveInData::SetSystemStyle( const OUString& rResourceURL, sal_Int32 nStyle ) { - if ( rResourceURL.startsWith( "private" ) && + if ( !(rResourceURL.startsWith( "private" ) && m_xPersistentWindowState.is() && - m_xPersistentWindowState->hasByName( rResourceURL ) ) + m_xPersistentWindowState->hasByName( rResourceURL )) ) + return; + + try { - try - { - uno::Sequence< beans::PropertyValue > aProps; + uno::Sequence< beans::PropertyValue > aProps; - uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) ); + uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) ); - if ( a >>= aProps ) + if ( a >>= aProps ) + { + for ( sal_Int32 i = 0; i < aProps.getLength(); ++i ) { - for ( sal_Int32 i = 0; i < aProps.getLength(); ++i ) + if ( aProps[ i ].Name == ITEM_DESCRIPTOR_STYLE ) { - if ( aProps[ i ].Name == ITEM_DESCRIPTOR_STYLE ) - { - aProps[ i ].Value <<= nStyle; - break; - } + aProps[ i ].Value <<= nStyle; + break; } } + } - uno::Reference< container::XNameReplace > - xNameReplace( m_xPersistentWindowState, uno::UNO_QUERY ); + uno::Reference< container::XNameReplace > + xNameReplace( m_xPersistentWindowState, uno::UNO_QUERY ); - xNameReplace->replaceByName( rResourceURL, uno::Any( aProps ) ); - } - catch ( uno::Exception& ) - { - // do nothing, a default value is returned - SAL_WARN("cui.customize", "Exception setting toolbar style"); - } + xNameReplace->replaceByName( rResourceURL, uno::Any( aProps ) ); + } + catch ( uno::Exception& ) + { + // do nothing, a default value is returned + SAL_WARN("cui.customize", "Exception setting toolbar style"); } } @@ -2856,18 +2856,18 @@ IMPL_LINK_NOARG(SvxIconSelectorDialog, DeleteHdl, weld::Button&, void) std::unique_ptr xWarn(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::OkCancel, message)); - if (xWarn->run() == RET_OK) - { - sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId(); + if (xWarn->run() != RET_OK) + return; - OUString aSelImageText = m_xTbSymbol->GetItemText( nId ); - uno::Sequence< OUString > URLs { aSelImageText }; - m_xTbSymbol->RemoveItem(nId); - m_xImportedImageManager->removeImages( SvxConfigPageHelper::GetImageType(), URLs ); - if ( m_xImportedImageManager->isModified() ) - { - m_xImportedImageManager->store(); - } + sal_uInt16 nId = m_xTbSymbol->GetSelectedItemId(); + + OUString aSelImageText = m_xTbSymbol->GetItemText( nId ); + uno::Sequence< OUString > URLs { aSelImageText }; + m_xTbSymbol->RemoveItem(nId); + m_xImportedImageManager->removeImages( SvxConfigPageHelper::GetImageType(), URLs ); + if ( m_xImportedImageManager->isModified() ) + { + m_xImportedImageManager->store(); } } @@ -3066,20 +3066,20 @@ void SvxIconSelectorDialog::ImportGraphics( } } - if ( rejectedCount != 0 ) - { - OUStringBuffer message; - OUString fPath; - if (rejectedCount > 1) - fPath = rPaths[0].copy(8) + "/"; - for ( sal_Int32 i = 0; i < rejectedCount; ++i ) - { - message.append(fPath).append(rejected[i]).append("\n"); - } + if ( rejectedCount == 0 ) + return; - SvxIconChangeDialog aDialog(m_xDialog.get(), message.makeStringAndClear()); - aDialog.run(); + OUStringBuffer message; + OUString fPath; + if (rejectedCount > 1) + fPath = rPaths[0].copy(8) + "/"; + for ( sal_Int32 i = 0; i < rejectedCount; ++i ) + { + message.append(fPath).append(rejected[i]).append("\n"); } + + SvxIconChangeDialog aDialog(m_xDialog.get(), message.makeStringAndClear()); + aDialog.run(); } bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL ) diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx index cdf07498f83e..7b45afa8652e 100644 --- a/cui/source/customize/macropg.cxx +++ b/cui/source/customize/macropg.cxx @@ -534,19 +534,19 @@ void SvxMacroTabPage_::InitAndSetHandler( const Reference< container::XNameRepla { } } - if(m_xDocEvents.is()) + if(!m_xDocEvents.is()) + return; + + eventNames = m_xDocEvents->getElementNames(); + nEventCount = eventNames.getLength(); + for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent ) { - eventNames = m_xDocEvents->getElementNames(); - nEventCount = eventNames.getLength(); - for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent ) + try + { + m_docEventsHash[ eventNames[nEvent] ] = GetPairFromAny( m_xDocEvents->getByName( eventNames[nEvent] ) ); + } + catch (const Exception&) { - try - { - m_docEventsHash[ eventNames[nEvent] ] = GetPairFromAny( m_xDocEvents->getByName( eventNames[nEvent] ) ); - } - catch (const Exception&) - { - } } } } diff --git a/cui/source/dialogs/QrCodeGenDialog.cxx b/cui/source/dialogs/QrCodeGenDialog.cxx index cec3b82a3567..85ed9309df9c 100644 --- a/cui/source/dialogs/QrCodeGenDialog.cxx +++ b/cui/source/dialogs/QrCodeGenDialog.cxx @@ -186,69 +186,69 @@ void QrCodeGenDialog::Apply() // Set QRCode properties xShapeProps->setPropertyValue("QRCodeProperties", Any(aQRCode)); - if (!bIsExistingQRCode) - { - // Default size - Reference xShape(xShapeProps, UNO_QUERY); - awt::Size aShapeSize; - aShapeSize.Height = 4000; - aShapeSize.Width = 4000; - xShape->setSize(aShapeSize); + if (bIsExistingQRCode) + return; - // Default anchoring - xShapeProps->setPropertyValue("AnchorType", Any(TextContentAnchorType_AT_PARAGRAPH)); + // Default size + Reference xShape(xShapeProps, UNO_QUERY); + awt::Size aShapeSize; + aShapeSize.Height = 4000; + aShapeSize.Width = 4000; + xShape->setSize(aShapeSize); - const Reference xServiceInfo(m_xModel, UNO_QUERY_THROW); + // Default anchoring + xShapeProps->setPropertyValue("AnchorType", Any(TextContentAnchorType_AT_PARAGRAPH)); - // Writer - if (xServiceInfo->supportsService("com.sun.star.text.TextDocument")) - { - Reference xTextContent(xShape, UNO_QUERY_THROW); - Reference xViewCursorSupplier(m_xModel->getCurrentController(), - UNO_QUERY_THROW); - Reference xCursor = xViewCursorSupplier->getViewCursor(); - // use cursor's XText - it might be in table cell, frame, ... - Reference const xText(xCursor->getText()); - assert(xText.is()); - xText->insertTextContent(xCursor, xTextContent, true); - return; - } + const Reference xServiceInfo(m_xModel, UNO_QUERY_THROW); - // Calc - else if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument")) - { - Reference xSheetCell(m_xModel->getCurrentSelection(), UNO_QUERY_THROW); - awt::Point aCellPosition; - xSheetCell->getPropertyValue("Position") >>= aCellPosition; - xShape->setPosition(aCellPosition); - - Reference xView(m_xModel->getCurrentController(), UNO_QUERY_THROW); - Reference xSheet(xView->getActiveSheet(), UNO_SET_THROW); - Reference xDrawPageSupplier(xSheet, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage, UNO_QUERY_THROW); - - xShapes->add(xShape); - return; - } + // Writer + if (xServiceInfo->supportsService("com.sun.star.text.TextDocument")) + { + Reference xTextContent(xShape, UNO_QUERY_THROW); + Reference xViewCursorSupplier(m_xModel->getCurrentController(), + UNO_QUERY_THROW); + Reference xCursor = xViewCursorSupplier->getViewCursor(); + // use cursor's XText - it might be in table cell, frame, ... + Reference const xText(xCursor->getText()); + assert(xText.is()); + xText->insertTextContent(xCursor, xTextContent, true); + return; + } - //Impress and Draw - else if (xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument") - || xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument")) - { - Reference xView(m_xModel->getCurrentController(), UNO_QUERY_THROW); - Reference xPage(xView->getCurrentPage(), UNO_SET_THROW); - Reference xShapes(xPage, UNO_QUERY_THROW); + // Calc + else if (xServiceInfo->supportsService("com.sun.star.sheet.SpreadsheetDocument")) + { + Reference xSheetCell(m_xModel->getCurrentSelection(), UNO_QUERY_THROW); + awt::Point aCellPosition; + xSheetCell->getPropertyValue("Position") >>= aCellPosition; + xShape->setPosition(aCellPosition); + + Reference xView(m_xModel->getCurrentController(), UNO_QUERY_THROW); + Reference xSheet(xView->getActiveSheet(), UNO_SET_THROW); + Reference xDrawPageSupplier(xSheet, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage, UNO_QUERY_THROW); + + xShapes->add(xShape); + return; + } - xShapes->add(xShape); - return; - } + //Impress and Draw + else if (xServiceInfo->supportsService("com.sun.star.presentation.PresentationDocument") + || xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument")) + { + Reference xView(m_xModel->getCurrentController(), UNO_QUERY_THROW); + Reference xPage(xView->getCurrentPage(), UNO_SET_THROW); + Reference xShapes(xPage, UNO_QUERY_THROW); - else - { - //Not implemented for math,base and other apps. - throw uno::RuntimeException("Not implemented"); - } + xShapes->add(xShape); + return; + } + + else + { + //Not implemented for math,base and other apps. + throw uno::RuntimeException("Not implemented"); } } diff --git a/cui/source/dialogs/SignSignatureLineDialog.cxx b/cui/source/dialogs/SignSignatureLineDialog.cxx index 00ad09f4cbef..e7a6417d5571 100644 --- a/cui/source/dialogs/SignSignatureLineDialog.cxx +++ b/cui/source/dialogs/SignSignatureLineDialog.cxx @@ -132,24 +132,24 @@ IMPL_LINK_NOARG(SignSignatureLineDialog, loadImage, weld::Button&, void) Reference xContext = comphelper::getProcessComponentContext(); Reference xFilePicker = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_PREVIEW); - if (xFilePicker->execute()) - { - Sequence aSelectedFiles = xFilePicker->getSelectedFiles(); - if (!aSelectedFiles.hasElements()) - return; + if (!xFilePicker->execute()) + return; - Reference xProvider = GraphicProvider::create(xContext); - Sequence aMediaProperties(1); - aMediaProperties[0].Name = "URL"; - aMediaProperties[0].Value <<= aSelectedFiles[0]; - m_xSignatureImage = xProvider->queryGraphic(aMediaProperties); - m_sOriginalImageBtnLabel = m_xBtnLoadImage->get_label(); + Sequence aSelectedFiles = xFilePicker->getSelectedFiles(); + if (!aSelectedFiles.hasElements()) + return; - INetURLObject aObj(aSelectedFiles[0]); - m_xBtnLoadImage->set_label(aObj.GetLastName()); + Reference xProvider = GraphicProvider::create(xContext); + Sequence aMediaProperties(1); + aMediaProperties[0].Name = "URL"; + aMediaProperties[0].Value <<= aSelectedFiles[0]; + m_xSignatureImage = xProvider->queryGraphic(aMediaProperties); + m_sOriginalImageBtnLabel = m_xBtnLoadImage->get_label(); - ValidateFields(); - } + INetURLObject aObj(aSelectedFiles[0]); + m_xBtnLoadImage->set_label(aObj.GetLastName()); + + ValidateFields(); } IMPL_LINK_NOARG(SignSignatureLineDialog, clearImage, weld::Button&, void) diff --git a/cui/source/dialogs/SignatureLineDialog.cxx b/cui/source/dialogs/SignatureLineDialog.cxx index 45a11c9fc111..e295e288e388 100644 --- a/cui/source/dialogs/SignatureLineDialog.cxx +++ b/cui/source/dialogs/SignatureLineDialog.cxx @@ -160,52 +160,51 @@ void SignatureLineDialog::Apply() xShapeProps->setPropertyValue("SignatureLineShowSignDate", Any(bShowSignDate)); xShapeProps->setPropertyValue("SignatureLineCanAddComment", Any(bCanAddComments)); - if (!bIsExistingSignatureLine) + if (bIsExistingSignatureLine) + return; + + // Default size + Reference xShape(xShapeProps, UNO_QUERY); + awt::Size aShapeSize; + aShapeSize.Height = 3000; + aShapeSize.Width = 6000; + xShape->setSize(aShapeSize); + + // Default anchoring + xShapeProps->setPropertyValue("AnchorType", Any(TextContentAnchorType_AT_PARAGRAPH)); + + // Writer + const Reference xTextDocument(m_xModel, UNO_QUERY); + if (xTextDocument.is()) { - // Default size - Reference xShape(xShapeProps, UNO_QUERY); - awt::Size aShapeSize; - aShapeSize.Height = 3000; - aShapeSize.Width = 6000; - xShape->setSize(aShapeSize); - - // Default anchoring - xShapeProps->setPropertyValue("AnchorType", Any(TextContentAnchorType_AT_PARAGRAPH)); - - // Writer - const Reference xTextDocument(m_xModel, UNO_QUERY); - if (xTextDocument.is()) - { - Reference xTextContent(xShape, UNO_QUERY_THROW); - Reference xViewCursorSupplier(m_xModel->getCurrentController(), - UNO_QUERY_THROW); - Reference xCursor = xViewCursorSupplier->getViewCursor(); - // use cursor's XText - it might be in table cell, frame, ... - Reference const xText(xCursor->getText()); - assert(xText.is()); - xText->insertTextContent(xCursor, xTextContent, true); - return; - } - - // Calc - const Reference xSpreadsheetDocument(m_xModel, UNO_QUERY); - if (xSpreadsheetDocument.is()) - { - Reference xSheetCell(m_xModel->getCurrentSelection(), UNO_QUERY_THROW); - awt::Point aCellPosition; - xSheetCell->getPropertyValue("Position") >>= aCellPosition; - xShape->setPosition(aCellPosition); - - Reference xView(m_xModel->getCurrentController(), UNO_QUERY_THROW); - Reference xSheet(xView->getActiveSheet(), UNO_SET_THROW); - Reference xDrawPageSupplier(xSheet, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage, UNO_QUERY_THROW); - - xShapes->add(xShape); - return; - } + Reference xTextContent(xShape, UNO_QUERY_THROW); + Reference xViewCursorSupplier(m_xModel->getCurrentController(), + UNO_QUERY_THROW); + Reference xCursor = xViewCursorSupplier->getViewCursor(); + // use cursor's XText - it might be in table cell, frame, ... + Reference const xText(xCursor->getText()); + assert(xText.is()); + xText->insertTextContent(xCursor, xTextContent, true); + return; } + + // Calc + const Reference xSpreadsheetDocument(m_xModel, UNO_QUERY); + if (!xSpreadsheetDocument.is()) + return; + + Reference xSheetCell(m_xModel->getCurrentSelection(), UNO_QUERY_THROW); + awt::Point aCellPosition; + xSheetCell->getPropertyValue("Position") >>= aCellPosition; + xShape->setPosition(aCellPosition); + + Reference xView(m_xModel->getCurrentController(), UNO_QUERY_THROW); + Reference xSheet(xView->getActiveSheet(), UNO_SET_THROW); + Reference xDrawPageSupplier(xSheet, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage, UNO_QUERY_THROW); + + xShapes->add(xShape); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index fd47ab92d728..cfa05034727e 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -349,35 +349,35 @@ void SpellDialog::SpellContinue_Impl(bool bUseSavedSentence, bool bIgnoreCurrent //then GetNextSentence() has to be called followed again by MarkNextError() //MarkNextError is not initially called if the UndoEdit mode is active bool bNextSentence = false; - if((!m_xSentenceED->IsUndoEditMode() && m_xSentenceED->MarkNextError( bIgnoreCurrentError, xSpell )) || - ( bNextSentence = GetNextSentence_Impl(bUseSavedSentence, m_xSentenceED->IsUndoEditMode()) && m_xSentenceED->MarkNextError( false, xSpell ))) + if(!((!m_xSentenceED->IsUndoEditMode() && m_xSentenceED->MarkNextError( bIgnoreCurrentError, xSpell )) || + ( bNextSentence = GetNextSentence_Impl(bUseSavedSentence, m_xSentenceED->IsUndoEditMode()) && m_xSentenceED->MarkNextError( false, xSpell )))) + return; + + SpellErrorDescription aSpellErrorDescription; + bool bSpellErrorDescription = m_xSentenceED->GetAlternatives(aSpellErrorDescription); + if (bSpellErrorDescription) { - SpellErrorDescription aSpellErrorDescription; - bool bSpellErrorDescription = m_xSentenceED->GetAlternatives(aSpellErrorDescription); - if (bSpellErrorDescription) + UpdateBoxes_Impl(); + weld::Widget* aControls[] = { - UpdateBoxes_Impl(); - weld::Widget* aControls[] = - { - m_xNotInDictFT.get(), - m_xSentenceED->GetDrawingArea(), - m_xLanguageFT.get(), - nullptr - }; - sal_Int32 nIdx = 0; - do - { - aControls[nIdx]->set_sensitive(true); - } - while(aControls[++nIdx]); - - } - if( bNextSentence ) + m_xNotInDictFT.get(), + m_xSentenceED->GetDrawingArea(), + m_xLanguageFT.get(), + nullptr + }; + sal_Int32 nIdx = 0; + do { - //remove undo if a new sentence is active - m_xSentenceED->ResetUndo(); - m_xUndoPB->set_sensitive(false); + aControls[nIdx]->set_sensitive(true); } + while(aControls[++nIdx]); + + } + if( bNextSentence ) + { + //remove undo if a new sentence is active + m_xSentenceED->ResetUndo(); + m_xUndoPB->set_sensitive(false); } } /* Initialize, asynchronous to prevent virtual calls @@ -898,18 +898,18 @@ void SpellDialog::ToplevelFocusChanged() * The only sensible thing would be to call the new Method differently, * e.g. DialogGot/LostFocus or so. */ - if (m_xDialog->get_visible() && !bFocusLocked) + if (!(m_xDialog->get_visible() && !bFocusLocked)) + return; + + if (m_xDialog->has_toplevel_focus()) { - if (m_xDialog->has_toplevel_focus()) - { - //notify the child window of the focus change - rParent.GetFocus(); - } - else - { - //notify the child window of the focus change - rParent.LoseFocus(); - } + //notify the child window of the focus change + rParent.GetFocus(); + } + else + { + //notify the child window of the focus change + rParent.LoseFocus(); } } diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx index 565c3ca2c8b1..fbba1abd1e90 100644 --- a/cui/source/dialogs/colorpicker.cxx +++ b/cui/source/dialogs/colorpicker.cxx @@ -493,19 +493,19 @@ void ColorFieldControl::Modify() void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, double y ) { bool bUpdateBitmap = (maColor!= aColor) || (meMode != eMode); - if( bUpdateBitmap || (mdX != x) || (mdY != y) ) - { - maColor = aColor; - meMode = eMode; - mdX = x; - mdY = y; + if( !(bUpdateBitmap || (mdX != x) || (mdY != y)) ) + return; - if (bUpdateBitmap) - UpdateBitmap(); - UpdatePosition(); - if (bUpdateBitmap) - Invalidate(); - } + maColor = aColor; + meMode = eMode; + mdX = x; + mdY = y; + + if (bUpdateBitmap) + UpdateBitmap(); + UpdatePosition(); + if (bUpdateBitmap) + Invalidate(); } void ColorFieldControl::UpdatePosition() diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index 919fae2f3e5f..de0b0c1663f5 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -809,36 +809,36 @@ void TPGalleryThemeProperties::SearchFiles() IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, weld::Button&, void) { - if( bInputAllowed ) + if( !bInputAllowed ) + return; + + try { - try - { - // setup folder picker - css::uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); - xFolderPicker = FolderPicker::create(xContext); + // setup folder picker + css::uno::Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + xFolderPicker = FolderPicker::create(xContext); - OUString aDlgPathName( SvtPathOptions().GetGraphicPath() ); - xFolderPicker->setDisplayDirectory(aDlgPathName); + OUString aDlgPathName( SvtPathOptions().GetGraphicPath() ); + xFolderPicker->setDisplayDirectory(aDlgPathName); - aPreviewTimer.Stop(); + aPreviewTimer.Stop(); - css::uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY ); - if ( xAsyncDlg.is() ) - xAsyncDlg->startExecuteModal( xDialogListener.get() ); - else + css::uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( xFolderPicker, UNO_QUERY ); + if ( xAsyncDlg.is() ) + xAsyncDlg->startExecuteModal( xDialogListener.get() ); + else + { + if( xFolderPicker->execute() == RET_OK ) { - if( xFolderPicker->execute() == RET_OK ) - { - aURL = INetURLObject( xFolderPicker->getDirectory() ); - bSearchRecursive = true; // UI choice no longer possible, windows file picker allows no user controls - SearchFiles(); - } + aURL = INetURLObject( xFolderPicker->getDirectory() ); + bSearchRecursive = true; // UI choice no longer possible, windows file picker allows no user controls + SearchFiles(); } } - catch (const IllegalArgumentException&) - { - OSL_FAIL( "Folder picker failed with illegal arguments" ); - } + } + catch (const IllegalArgumentException&) + { + OSL_FAIL( "Folder picker failed with illegal arguments" ); } } @@ -858,20 +858,20 @@ void TPGalleryThemeProperties::TakeFiles() IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickPreviewHdl, weld::ToggleButton&, void) { - if ( bInputAllowed ) - { - aPreviewTimer.Stop(); - aPreviewString.clear(); + if ( !bInputAllowed ) + return; - if (!m_xCbxPreview->get_active()) - { - xMediaPlayer.clear(); - m_aWndPreview.SetGraphic(Graphic()); - m_aWndPreview.Invalidate(); - } - else - DoPreview(); + aPreviewTimer.Stop(); + aPreviewString.clear(); + + if (!m_xCbxPreview->get_active()) + { + xMediaPlayer.clear(); + m_aWndPreview.SetGraphic(Graphic()); + m_aWndPreview.Invalidate(); } + else + DoPreview(); } void TPGalleryThemeProperties::DoPreview() @@ -879,49 +879,49 @@ void TPGalleryThemeProperties::DoPreview() int nIndex = m_xLbxFound->get_selected_index(); OUString aString(m_xLbxFound->get_text(nIndex)); - if (aString != aPreviewString) - { - INetURLObject _aURL(aFoundList[nIndex]); - bInputAllowed = false; + if (aString == aPreviewString) + return; - if (!m_aWndPreview.SetGraphic(_aURL)) - { - weld::WaitObject aWaitObject(GetFrameWeld()); - ErrorHandler::HandleError(ERRCODE_IO_NOTEXISTSPATH, GetFrameWeld()); - } + INetURLObject _aURL(aFoundList[nIndex]); + bInputAllowed = false; + + if (!m_aWndPreview.SetGraphic(_aURL)) + { + weld::WaitObject aWaitObject(GetFrameWeld()); + ErrorHandler::HandleError(ERRCODE_IO_NOTEXISTSPATH, GetFrameWeld()); + } #if HAVE_FEATURE_AVMEDIA - else if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ), "" ) ) - { - xMediaPlayer = ::avmedia::MediaWindow::createPlayer( _aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), "" ); - if( xMediaPlayer.is() ) - xMediaPlayer->start(); - } -#endif - bInputAllowed = true; - aPreviewString = aString; + else if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ), "" ) ) + { + xMediaPlayer = ::avmedia::MediaWindow::createPlayer( _aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), "" ); + if( xMediaPlayer.is() ) + xMediaPlayer->start(); } +#endif + bInputAllowed = true; + aPreviewString = aString; } IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeHdl, weld::Button&, void) { - if( bInputAllowed ) - { - aPreviewTimer.Stop(); + if( !bInputAllowed ) + return; - if (!m_xLbxFound->count_selected_rows() || !bEntriesFound) - { - SvxOpenGraphicDialog aDlg(CuiResId(RID_SVXSTR_KEY_GALLERY_DIR), GetFrameWeld()); - aDlg.EnableLink(false); - aDlg.AsLink(false); + aPreviewTimer.Stop(); - if( !aDlg.Execute() ) - pData->pTheme->InsertURL( INetURLObject( aDlg.GetPath() ) ); - } - else - { - bTakeAll = false; - TakeFiles(); - } + if (!m_xLbxFound->count_selected_rows() || !bEntriesFound) + { + SvxOpenGraphicDialog aDlg(CuiResId(RID_SVXSTR_KEY_GALLERY_DIR), GetFrameWeld()); + aDlg.EnableLink(false); + aDlg.AsLink(false); + + if( !aDlg.Execute() ) + pData->pTheme->InsertURL( INetURLObject( aDlg.GetPath() ) ); + } + else + { + bTakeAll = false; + TakeFiles(); } } @@ -937,31 +937,31 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickTakeAllHdl, weld::Button&, void) IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFoundHdl, weld::TreeView&, void) { - if (bInputAllowed) - { - bool bPreviewPossible = false; + if (!bInputAllowed) + return; - aPreviewTimer.Stop(); + bool bPreviewPossible = false; - if( bEntriesFound ) - { - if (m_xLbxFound->count_selected_rows() == 1) - { - m_xCbxPreview->set_sensitive(true); - bPreviewPossible = true; - } - else - m_xCbxPreview->set_sensitive(false); + aPreviewTimer.Stop(); - if( !aFoundList.empty() ) - m_xBtnTakeAll->set_sensitive(true); - else - m_xBtnTakeAll->set_sensitive(false); + if( bEntriesFound ) + { + if (m_xLbxFound->count_selected_rows() == 1) + { + m_xCbxPreview->set_sensitive(true); + bPreviewPossible = true; } + else + m_xCbxPreview->set_sensitive(false); - if (bPreviewPossible && m_xCbxPreview->get_active()) - aPreviewTimer.Start(); + if( !aFoundList.empty() ) + m_xBtnTakeAll->set_sensitive(true); + else + m_xBtnTakeAll->set_sensitive(false); } + + if (bPreviewPossible && m_xCbxPreview->get_active()) + aPreviewTimer.Start(); } IMPL_LINK_NOARG(TPGalleryThemeProperties, DClickFoundHdl, weld::TreeView&, bool) diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx index 1a3a7b520501..9ca722680a15 100644 --- a/cui/source/dialogs/cuihyperdlg.cxx +++ b/cui/source/dialogs/cuihyperdlg.cxx @@ -61,21 +61,21 @@ void SvxHlinkCtrl::dispose() void SvxHlinkCtrl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) { - if (eState == SfxItemState::DEFAULT && pParent) + if (!(eState == SfxItemState::DEFAULT && pParent)) + return; + + switch ( nSID ) { - switch ( nSID ) + case SID_HYPERLINK_GETLINK : { - case SID_HYPERLINK_GETLINK : - { - pParent->SetPage( static_cast(pState) ); - } - break; - case SID_READONLY_MODE : - { - pParent->SetReadOnlyMode( static_cast(pState)->GetValue() ); - } - break; + pParent->SetPage( static_cast(pState) ); + } + break; + case SID_READONLY_MODE : + { + pParent->SetReadOnlyMode( static_cast(pState)->GetValue() ); } + break; } } diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx index a90d1725a50d..3c68eb9b5991 100644 --- a/cui/source/dialogs/hangulhanjadlg.cxx +++ b/cui/source/dialogs/hangulhanjadlg.cxx @@ -323,21 +323,21 @@ namespace svx void SuggestionDisplay::DisplayListBox( bool bDisplayListBox ) { - if( m_bDisplayListBox != bDisplayListBox ) - { - weld::Widget& rOldControl = implGetCurrentControl(); - bool bHasFocus = rOldControl.has_focus(); + if( m_bDisplayListBox == bDisplayListBox ) + return; - m_bDisplayListBox = bDisplayListBox; + weld::Widget& rOldControl = implGetCurrentControl(); + bool bHasFocus = rOldControl.has_focus(); - if( bHasFocus ) - { - weld::Widget& rNewControl = implGetCurrentControl(); - rNewControl.grab_focus(); - } + m_bDisplayListBox = bDisplayListBox; - implUpdateDisplay(); + if( bHasFocus ) + { + weld::Widget& rNewControl = implGetCurrentControl(); + rNewControl.grab_focus(); } + + implUpdateDisplay(); } IMPL_LINK_NOARG(SuggestionDisplay, SelectSuggestionValueSetHdl, SvtValueSet*, void) @@ -598,24 +598,24 @@ namespace svx m_xIgnoreAll->set_sensitive( m_bDocumentMode ); // switch the def button depending if we're working for document text - if (bOldDocumentMode != m_bDocumentMode) - { - weld::Widget* pOldDefButton = nullptr; - weld::Widget* pNewDefButton = nullptr; - if (m_bDocumentMode) - { - pOldDefButton = m_xFind.get(); - pNewDefButton = m_xReplace.get(); - } - else - { - pOldDefButton = m_xReplace.get(); - pNewDefButton = m_xFind.get(); - } + if (bOldDocumentMode == m_bDocumentMode) + return; - pOldDefButton->set_has_default(false); - pNewDefButton->set_has_default(true); + weld::Widget* pOldDefButton = nullptr; + weld::Widget* pNewDefButton = nullptr; + if (m_bDocumentMode) + { + pOldDefButton = m_xFind.get(); + pNewDefButton = m_xReplace.get(); } + else + { + pOldDefButton = m_xReplace.get(); + pNewDefButton = m_xFind.get(); + } + + pOldDefButton->set_has_default(false); + pNewDefButton->set_has_default(true); } OUString HangulHanjaConversionDialog::GetCurrentSuggestion( ) const @@ -810,30 +810,30 @@ namespace svx OUString aName; HangulHanjaNewDictDialog aNewDlg(m_xDialog.get()); aNewDlg.run(); - if (aNewDlg.GetName(aName)) + if (!aNewDlg.GetName(aName)) + return; + + if( !m_xConversionDictionaryList.is() ) + return; + + try { - if( m_xConversionDictionaryList.is() ) - { - try - { - Reference< XConversionDictionary > xDic = - m_xConversionDictionaryList->addNewDictionary( aName, LanguageTag::convertToLocale( LANGUAGE_KOREAN ), ConversionDictionaryType::HANGUL_HANJA ); + Reference< XConversionDictionary > xDic = + m_xConversionDictionaryList->addNewDictionary( aName, LanguageTag::convertToLocale( LANGUAGE_KOREAN ), ConversionDictionaryType::HANGUL_HANJA ); - if( xDic.is() ) - { - //adapt local caches: - m_aDictList.push_back( xDic ); - AddDict( xDic->getName(), xDic->isActive() ); - } - } - catch( const ElementExistException& ) - { - } - catch( const NoSupportException& ) - { - } + if( xDic.is() ) + { + //adapt local caches: + m_aDictList.push_back( xDic ); + AddDict( xDic->getName(), xDic->isActive() ); } } + catch( const ElementExistException& ) + { + } + catch( const NoSupportException& ) + { + } } IMPL_LINK_NOARG(HangulHanjaOptionsDialog, EditDictHdl, weld::Button&, void) @@ -850,30 +850,30 @@ namespace svx IMPL_LINK_NOARG(HangulHanjaOptionsDialog, DeleteDictHdl, weld::Button&, void) { int nSelPos = m_xDictsLB->get_selected_index(); - if (nSelPos != -1) + if (nSelPos == -1) + return; + + Reference< XConversionDictionary > xDic( m_aDictList[ nSelPos ] ); + if( !(m_xConversionDictionaryList.is() && xDic.is()) ) + return; + + Reference< XNameContainer > xNameCont = m_xConversionDictionaryList->getDictionaryContainer(); + if( !xNameCont.is() ) + return; + + try { - Reference< XConversionDictionary > xDic( m_aDictList[ nSelPos ] ); - if( m_xConversionDictionaryList.is() && xDic.is() ) - { - Reference< XNameContainer > xNameCont = m_xConversionDictionaryList->getDictionaryContainer(); - if( xNameCont.is() ) - { - try - { - xNameCont->removeByName( xDic->getName() ); + xNameCont->removeByName( xDic->getName() ); - //adapt local caches: - m_aDictList.erase(m_aDictList.begin()+nSelPos ); - m_xDictsLB->remove(nSelPos); - } - catch( const ElementExistException& ) - { - } - catch( const NoSupportException& ) - { - } - } - } + //adapt local caches: + m_aDictList.erase(m_aDictList.begin()+nSelPos ); + m_xDictsLB->remove(nSelPos); + } + catch( const ElementExistException& ) + { + } + catch( const NoSupportException& ) + { } } diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx index f800edba1cea..fa4529735185 100644 --- a/cui/source/dialogs/hldocntp.cxx +++ b/cui/source/dialogs/hldocntp.cxx @@ -358,52 +358,52 @@ void SvxHyperlinkNewDocTp::DoApply() // create a real URL-String INetURLObject aURL; - if ( ImplGetURLObject( aStrNewName, m_xCbbPath->GetBaseURL(), aURL ) ) + if ( !ImplGetURLObject( aStrNewName, m_xCbbPath->GetBaseURL(), aURL ) ) + return; + + // create Document + aStrNewName = aURL.GetURLPath( INetURLObject::DecodeMechanism::NONE ); + bool bCreate = true; + try { - // create Document - aStrNewName = aURL.GetURLPath( INetURLObject::DecodeMechanism::NONE ); - bool bCreate = true; - try - { - // check if file exists, warn before we overwrite it - std::unique_ptr pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ); + // check if file exists, warn before we overwrite it + std::unique_ptr pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ); - bool bOk = pIStm && ( pIStm->GetError() == ERRCODE_NONE); + bool bOk = pIStm && ( pIStm->GetError() == ERRCODE_NONE); - pIStm.reset(); + pIStm.reset(); - if( bOk ) - { - std::unique_ptr xWarn(Application::CreateMessageDialog(mpDialog->getDialog(), - VclMessageType::Warning, VclButtonsType::YesNo, - CuiResId(RID_SVXSTR_HYPERDLG_QUERYOVERWRITE))); - bCreate = xWarn->run() == RET_YES; - } - } - catch (const uno::Exception&) + if( bOk ) { + std::unique_ptr xWarn(Application::CreateMessageDialog(mpDialog->getDialog(), + VclMessageType::Warning, VclButtonsType::YesNo, + CuiResId(RID_SVXSTR_HYPERDLG_QUERYOVERWRITE))); + bCreate = xWarn->run() == RET_YES; } + } + catch (const uno::Exception&) + { + } - if (bCreate && !aStrNewName.isEmpty()) - { - ExecuteInfo* pExecuteInfo = new ExecuteInfo; + if (!(bCreate && !aStrNewName.isEmpty())) + return; - pExecuteInfo->bRbtEditLater = m_xRbtEditLater->get_active(); - pExecuteInfo->bRbtEditNow = m_xRbtEditNow->get_active(); - // get private-url - sal_Int32 nPos = m_xLbDocTypes->get_selected_index(); - if (nPos == -1) - nPos = 0; - pExecuteInfo->aURL = aURL; - pExecuteInfo->aStrDocName = reinterpret_cast(m_xLbDocTypes->get_id(nPos).toInt64())->aStrURL; + ExecuteInfo* pExecuteInfo = new ExecuteInfo; - // current document - pExecuteInfo->xFrame = GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(); - pExecuteInfo->pDispatcher = GetDispatcher(); + pExecuteInfo->bRbtEditLater = m_xRbtEditLater->get_active(); + pExecuteInfo->bRbtEditNow = m_xRbtEditNow->get_active(); + // get private-url + sal_Int32 nPos = m_xLbDocTypes->get_selected_index(); + if (nPos == -1) + nPos = 0; + pExecuteInfo->aURL = aURL; + pExecuteInfo->aStrDocName = reinterpret_cast(m_xLbDocTypes->get_id(nPos).toInt64())->aStrURL; - Application::PostUserEvent(LINK(nullptr, SvxHyperlinkNewDocTp, DispatchDocument), pExecuteInfo); - } - } + // current document + pExecuteInfo->xFrame = GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(); + pExecuteInfo->pDispatcher = GetDispatcher(); + + Application::PostUserEvent(LINK(nullptr, SvxHyperlinkNewDocTp, DispatchDocument), pExecuteInfo); } /************************************************************************* @@ -434,46 +434,46 @@ IMPL_LINK_NOARG(SvxHyperlinkNewDocTp, ClickNewHdl_Impl, weld::Button&, void) xFolderPicker->setDisplayDirectory( aStrPath ); sal_Int16 nResult = xFolderPicker->execute(); DisableClose( false ); - if( ExecutableDialogResults::OK == nResult ) - { - char const sSlash[] = "/"; + if( ExecutableDialogResults::OK != nResult ) + return; - INetURLObject aURL( aStrURL, INetProtocol::File ); - OUString aStrName; - if( bHandleFileName ) - aStrName = bZeroPath? aTempStrURL : aURL.getName(); + char const sSlash[] = "/"; - m_xCbbPath->SetBaseURL( xFolderPicker->getDirectory() ); - OUString aStrTmp( xFolderPicker->getDirectory() ); + INetURLObject aURL( aStrURL, INetProtocol::File ); + OUString aStrName; + if( bHandleFileName ) + aStrName = bZeroPath? aTempStrURL : aURL.getName(); - if( aStrTmp[ aStrTmp.getLength() - 1 ] != sSlash[0] ) - aStrTmp += sSlash; + m_xCbbPath->SetBaseURL( xFolderPicker->getDirectory() ); + OUString aStrTmp( xFolderPicker->getDirectory() ); - // append old file name - if( bHandleFileName ) - aStrTmp += aStrName; + if( aStrTmp[ aStrTmp.getLength() - 1 ] != sSlash[0] ) + aStrTmp += sSlash; - INetURLObject aNewURL( aStrTmp ); + // append old file name + if( bHandleFileName ) + aStrTmp += aStrName; - if (!aStrName.isEmpty() && !aNewURL.getExtension().isEmpty() && - m_xLbDocTypes->get_selected_index() != -1) - { - // get private-url - const sal_Int32 nPos = m_xLbDocTypes->get_selected_index(); - aNewURL.setExtension(reinterpret_cast(m_xLbDocTypes->get_id(nPos).toInt64())->aStrExt); - } + INetURLObject aNewURL( aStrTmp ); - if( aNewURL.GetProtocol() == INetProtocol::File ) - { - osl::FileBase::getSystemPathFromFileURL(aNewURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aStrTmp); - } - else - { - aStrTmp = aNewURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ); - } + if (!aStrName.isEmpty() && !aNewURL.getExtension().isEmpty() && + m_xLbDocTypes->get_selected_index() != -1) + { + // get private-url + const sal_Int32 nPos = m_xLbDocTypes->get_selected_index(); + aNewURL.setExtension(reinterpret_cast(m_xLbDocTypes->get_id(nPos).toInt64())->aStrExt); + } - m_xCbbPath->set_entry_text( aStrTmp ); + if( aNewURL.GetProtocol() == INetProtocol::File ) + { + osl::FileBase::getSystemPathFromFileURL(aNewURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aStrTmp); } + else + { + aStrTmp = aNewURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ); + } + + m_xCbbPath->set_entry_text( aStrTmp ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/dialogs/hldoctp.cxx b/cui/source/dialogs/hldoctp.cxx index 3ac1ee03318d..8bfe89465962 100644 --- a/cui/source/dialogs/hldoctp.cxx +++ b/cui/source/dialogs/hldoctp.cxx @@ -184,19 +184,19 @@ IMPL_LINK_NOARG(SvxHyperlinkDocTp, ClickFileopenHdl_Impl, weld::Button&, void) ErrCode nError = aDlg.Execute(); DisableClose( false ); - if ( ERRCODE_NONE == nError ) - { - OUString aURL( aDlg.GetPath() ); - OUString aPath; + if ( ERRCODE_NONE != nError ) + return; - osl::FileBase::getSystemPathFromFileURL(aURL, aPath); + OUString aURL( aDlg.GetPath() ); + OUString aPath; - m_xCbbPath->SetBaseURL( aURL ); - m_xCbbPath->set_entry_text(aPath); + osl::FileBase::getSystemPathFromFileURL(aURL, aPath); - if ( aOldURL != GetCurrentURL() ) - ModifiedPathHdl_Impl(*m_xCbbPath->getWidget()); - } + m_xCbbPath->SetBaseURL( aURL ); + m_xCbbPath->set_entry_text(aPath); + + if ( aOldURL != GetCurrentURL() ) + ModifiedPathHdl_Impl(*m_xCbbPath->getWidget()); } /************************************************************************* diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx index aeecd54a85c3..6182adfd951f 100644 --- a/cui/source/dialogs/hltpbase.cxx +++ b/cui/source/dialogs/hltpbase.cxx @@ -331,47 +331,47 @@ IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, weld::Button&, voi SvxHyperlinkItem *pHyperlinkItem = const_cast(static_cast( GetItemSet().GetItem (SID_HYPERLINK_GETLINK))); - if ( pHyperlinkItem->GetMacroEvents() != HyperDialogEvent::NONE ) + if ( pHyperlinkItem->GetMacroEvents() == HyperDialogEvent::NONE ) + return; + + // get macros from itemset + const SvxMacroTableDtor* pMacroTbl = pHyperlinkItem->GetMacroTable(); + SvxMacroItem aItem ( SID_ATTR_MACROITEM ); + if( pMacroTbl ) + aItem.SetMacroTable( *pMacroTbl ); + + // create empty itemset for macro-dlg + std::unique_ptr pItemSet( new SfxItemSet(SfxGetpApp()->GetPool(), + svl::Items{} ) ); + pItemSet->Put ( aItem ); + + DisableClose( true ); + + SfxMacroAssignDlg aDlg(mpDialog->getDialog(), mxDocumentFrame, *pItemSet); + + // add events + SfxMacroTabPage *pMacroPage = aDlg.GetTabPage(); + + if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOverObject ) + pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT1), + SvMacroItemId::OnMouseOver ); + if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseClickObject ) + pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT2), + SvMacroItemId::OnClick); + if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOutObject ) + pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT3), + SvMacroItemId::OnMouseOut); + // execute dlg + short nRet = aDlg.run(); + DisableClose( false ); + if ( RET_OK == nRet ) { - // get macros from itemset - const SvxMacroTableDtor* pMacroTbl = pHyperlinkItem->GetMacroTable(); - SvxMacroItem aItem ( SID_ATTR_MACROITEM ); - if( pMacroTbl ) - aItem.SetMacroTable( *pMacroTbl ); - - // create empty itemset for macro-dlg - std::unique_ptr pItemSet( new SfxItemSet(SfxGetpApp()->GetPool(), - svl::Items{} ) ); - pItemSet->Put ( aItem ); - - DisableClose( true ); - - SfxMacroAssignDlg aDlg(mpDialog->getDialog(), mxDocumentFrame, *pItemSet); - - // add events - SfxMacroTabPage *pMacroPage = aDlg.GetTabPage(); - - if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOverObject ) - pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT1), - SvMacroItemId::OnMouseOver ); - if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseClickObject ) - pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT2), - SvMacroItemId::OnClick); - if ( pHyperlinkItem->GetMacroEvents() & HyperDialogEvent::MouseOutObject ) - pMacroPage->AddEvent( CuiResId(RID_SVXSTR_HYPDLG_MACROACT3), - SvMacroItemId::OnMouseOut); - // execute dlg - short nRet = aDlg.run(); - DisableClose( false ); - if ( RET_OK == nRet ) + const SfxItemSet* pOutSet = aDlg.GetOutputItemSet(); + const SfxPoolItem* pItem; + if( SfxItemState::SET == pOutSet->GetItemState( SID_ATTR_MACROITEM, false, &pItem )) { - const SfxItemSet* pOutSet = aDlg.GetOutputItemSet(); - const SfxPoolItem* pItem; - if( SfxItemState::SET == pOutSet->GetItemState( SID_ATTR_MACROITEM, false, &pItem )) - { - pHyperlinkItem->SetMacroTable( static_cast(pItem)->GetMacroTable() ); - } + pHyperlinkItem->SetMacroTable( static_cast(pItem)->GetMacroTable() ); } } } diff --git a/cui/source/dialogs/hyphen.cxx b/cui/source/dialogs/hyphen.cxx index 48e7c4574ca1..f7b6549fc042 100644 --- a/cui/source/dialogs/hyphen.cxx +++ b/cui/source/dialogs/hyphen.cxx @@ -312,24 +312,24 @@ IMPL_LINK_NOARG(SvxHyphenWordDialog, CutHdl_Impl, weld::Button&, void) IMPL_LINK_NOARG(SvxHyphenWordDialog, HyphenateAllHdl_Impl, weld::Button&, void) { - if( !m_bBusy ) + if( m_bBusy ) + return; + + try { - try - { - uno::Reference< linguistic2::XLinguProperties > xProp( LinguMgr::GetLinguPropertySet() ); + uno::Reference< linguistic2::XLinguProperties > xProp( LinguMgr::GetLinguPropertySet() ); - xProp->setIsHyphAuto( true ); + xProp->setIsHyphAuto( true ); - m_bBusy = true; - ContinueHyph_Impl( /*m_nHyphPos*/m_nOldPos ); - m_bBusy = false; + m_bBusy = true; + ContinueHyph_Impl( /*m_nHyphPos*/m_nOldPos ); + m_bBusy = false; - xProp->setIsHyphAuto( false ); - } - catch (uno::Exception &) - { - SAL_WARN( "cui.dialogs", "Hyphenate All failed" ); - } + xProp->setIsHyphAuto( false ); + } + catch (uno::Exception &) + { + SAL_WARN( "cui.dialogs", "Hyphenate All failed" ); } } diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx index fdeb3a36b780..bca5984f8817 100644 --- a/cui/source/dialogs/iconcdlg.cxx +++ b/cui/source/dialogs/iconcdlg.cxx @@ -157,55 +157,55 @@ void SvxHpLinkDlg::DeActivatePageImpl () DeactivateRC nRet = DeactivateRC::LeavePage; - if ( pData ) - { - IconChoicePage * pPage = pData->xPage.get(); + if ( !pData ) + return; - if ( !pExampleSet && pPage->HasExchangeSupport() && pSet ) - pExampleSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() ); + IconChoicePage * pPage = pData->xPage.get(); - if ( pSet ) - { - SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() ); + if ( !pExampleSet && pPage->HasExchangeSupport() && pSet ) + pExampleSet = new SfxItemSet( *pSet->GetPool(), pSet->GetRanges() ); - if ( pPage->HasExchangeSupport() ) - nRet = pPage->DeactivatePage( &aTmp ); + if ( pSet ) + { + SfxItemSet aTmp( *pSet->GetPool(), pSet->GetRanges() ); - if ( ( DeactivateRC::LeavePage & nRet ) && - aTmp.Count() ) - { - if (pExampleSet) - pExampleSet->Put(aTmp); - pOutSet->Put( aTmp ); - } + if ( pPage->HasExchangeSupport() ) + nRet = pPage->DeactivatePage( &aTmp ); + + if ( ( DeactivateRC::LeavePage & nRet ) && + aTmp.Count() ) + { + if (pExampleSet) + pExampleSet->Put(aTmp); + pOutSet->Put( aTmp ); } - else + } + else + { + if ( pPage->HasExchangeSupport() ) //!!! { - if ( pPage->HasExchangeSupport() ) //!!! + if ( !pExampleSet ) { - if ( !pExampleSet ) - { - SfxItemPool* pPool = pPage->GetItemSet().GetPool(); - pExampleSet = - new SfxItemSet( *pPool, GetInputRanges( *pPool ) ); - } - nRet = pPage->DeactivatePage( pExampleSet ); + SfxItemPool* pPool = pPage->GetItemSet().GetPool(); + pExampleSet = + new SfxItemSet( *pPool, GetInputRanges( *pPool ) ); } - else - nRet = pPage->DeactivatePage( nullptr ); + nRet = pPage->DeactivatePage( pExampleSet ); } + else + nRet = pPage->DeactivatePage( nullptr ); + } - if ( nRet & DeactivateRC::RefreshSet ) + if ( nRet & DeactivateRC::RefreshSet ) + { + // TODO refresh input set + // flag all pages to be newly initialized + for (auto & pObj : maPageList) { - // TODO refresh input set - // flag all pages to be newly initialized - for (auto & pObj : maPageList) - { - if ( pObj->xPage.get() != pPage ) - pObj->bRefresh = true; - else - pObj->bRefresh = false; - } + if ( pObj->xPage.get() != pPage ) + pObj->bRefresh = true; + else + pObj->bRefresh = false; } } } diff --git a/cui/source/dialogs/linkdlg.cxx b/cui/source/dialogs/linkdlg.cxx index bd6225ac89a1..764d29e0c191 100644 --- a/cui/source/dialogs/linkdlg.cxx +++ b/cui/source/dialogs/linkdlg.cxx @@ -252,39 +252,39 @@ IMPL_LINK_NOARG(SvBaseLinksDlg, UpdateNowClickHdl, weld::Button&, void) aPosArr.push_back( nFndPos ); } - if( !aLnkArr.empty() ) + if( aLnkArr.empty() ) + return; + + for( size_t n = 0; n < aLnkArr.size(); ++n ) { - for( size_t n = 0; n < aLnkArr.size(); ++n ) - { - tools::SvRef xLink = aLnkArr[ n ]; + tools::SvRef xLink = aLnkArr[ n ]; - // first look for the entry in the array - for(const auto & i : pLinkMgr->GetLinks()) - if( xLink == i ) - { - SetType( *xLink, aPosArr[ n ], xLink->GetUpdateMode() ); - break; - } - } + // first look for the entry in the array + for(const auto & i : pLinkMgr->GetLinks()) + if( xLink == i ) + { + SetType( *xLink, aPosArr[ n ], xLink->GetUpdateMode() ); + break; + } + } - // if somebody is of the opinion to swap his links (SD) - LinkManager* pNewMgr = pLinkMgr; - pLinkMgr = nullptr; - SetManager( pNewMgr ); + // if somebody is of the opinion to swap his links (SD) + LinkManager* pNewMgr = pLinkMgr; + pLinkMgr = nullptr; + SetManager( pNewMgr ); - OUString sId = OUString::number(reinterpret_cast(aLnkArr[0])); - int nE = m_xTbLinks->find_id(sId); - if (nE == -1) - nE = m_xTbLinks->get_selected_index(); - int nSelEntry = m_xTbLinks->get_selected_index(); - if (nE != nSelEntry) - m_xTbLinks->unselect(nSelEntry); - m_xTbLinks->select(nE); - m_xTbLinks->scroll_to_row(nE); + OUString sId = OUString::number(reinterpret_cast(aLnkArr[0])); + int nE = m_xTbLinks->find_id(sId); + if (nE == -1) + nE = m_xTbLinks->get_selected_index(); + int nSelEntry = m_xTbLinks->get_selected_index(); + if (nE != nSelEntry) + m_xTbLinks->unselect(nSelEntry); + m_xTbLinks->select(nE); + m_xTbLinks->scroll_to_row(nE); - pNewMgr->CloseCachedComps(); - } + pNewMgr->CloseCachedComps(); } IMPL_LINK_NOARG(SvBaseLinksDlg, ChangeSourceClickHdl, weld::Button&, void) @@ -421,22 +421,22 @@ IMPL_LINK_NOARG( SvBaseLinksDlg, BreakLinkClickHdl, weld::Button&, void ) // then remove all selected entries } } - if(bModified) + if(!bModified) + return; + + if (!m_xTbLinks->n_children()) { - if (!m_xTbLinks->n_children()) - { - m_xRbAutomatic->set_sensitive(false); - m_xRbManual->set_sensitive(false); - m_xPbUpdateNow->set_sensitive(false); - m_xPbChangeSource->set_sensitive(false); - m_xPbBreakLink->set_sensitive(false); + m_xRbAutomatic->set_sensitive(false); + m_xRbManual->set_sensitive(false); + m_xPbUpdateNow->set_sensitive(false); + m_xPbChangeSource->set_sensitive(false); + m_xPbBreakLink->set_sensitive(false); - m_xFtFullSourceName->set_label( "" ); - m_xFtFullTypeName->set_label( "" ); - } - if( pLinkMgr && pLinkMgr->GetPersist() ) - pLinkMgr->GetPersist()->SetModified(); + m_xFtFullSourceName->set_label( "" ); + m_xFtFullTypeName->set_label( "" ); } + if( pLinkMgr && pLinkMgr->GetPersist() ) + pLinkMgr->GetPersist()->SetModified(); } IMPL_LINK_NOARG( SvBaseLinksDlg, UpdateWaitingHdl, Timer*, void ) @@ -461,37 +461,37 @@ IMPL_LINK( SvBaseLinksDlg, EndEditHdl, sfx2::SvBaseLink&, _rLink, void ) int nPos; GetSelEntry( &nPos ); - if( _rLink.WasLastEditOK() ) - { - // StarImpress/Draw swap the LinkObjects themselves! - // So search for the link in the manager; if it does not exist - // anymore, fill the list completely new. Otherwise only the - // edited link needs to be refreshed. - bool bLinkFnd = false; - for( size_t n = pLinkMgr->GetLinks().size(); n; ) - if( &_rLink == &(*pLinkMgr->GetLinks()[ --n ]) ) - { - bLinkFnd = true; - break; - } + if( !_rLink.WasLastEditOK() ) + return; - if( bLinkFnd ) + // StarImpress/Draw swap the LinkObjects themselves! + // So search for the link in the manager; if it does not exist + // anymore, fill the list completely new. Otherwise only the + // edited link needs to be refreshed. + bool bLinkFnd = false; + for( size_t n = pLinkMgr->GetLinks().size(); n; ) + if( &_rLink == &(*pLinkMgr->GetLinks()[ --n ]) ) { - m_xTbLinks->remove(nPos); - int nToUnselect = m_xTbLinks->get_selected_index(); - InsertEntry(_rLink, nPos, true); - if (nToUnselect != -1) - m_xTbLinks->unselect(nToUnselect); + bLinkFnd = true; + break; } - else - { - LinkManager* pNewMgr = pLinkMgr; - pLinkMgr = nullptr; - SetManager( pNewMgr ); - } - if (pLinkMgr && pLinkMgr->GetPersist()) - pLinkMgr->GetPersist()->SetModified(); + + if( bLinkFnd ) + { + m_xTbLinks->remove(nPos); + int nToUnselect = m_xTbLinks->get_selected_index(); + InsertEntry(_rLink, nPos, true); + if (nToUnselect != -1) + m_xTbLinks->unselect(nToUnselect); } + else + { + LinkManager* pNewMgr = pLinkMgr; + pLinkMgr = nullptr; + SetManager( pNewMgr ); + } + if (pLinkMgr && pLinkMgr->GetPersist()) + pLinkMgr->GetPersist()->SetModified(); } OUString SvBaseLinksDlg::ImplGetStateStr( const SvBaseLink& rLnk ) @@ -526,30 +526,30 @@ void SvBaseLinksDlg::SetManager( LinkManager* pNewMgr ) m_xTbLinks->clear(); pLinkMgr = pNewMgr; - if( pLinkMgr ) + if( !pLinkMgr ) + return; + + SvBaseLinks& rLnks = const_cast(pLinkMgr->GetLinks()); + for( size_t n = 0; n < rLnks.size(); ++n ) { - SvBaseLinks& rLnks = const_cast(pLinkMgr->GetLinks()); - for( size_t n = 0; n < rLnks.size(); ++n ) + tools::SvRef& rLinkRef = rLnks[ n ]; + if( !rLinkRef.is() ) { - tools::SvRef& rLinkRef = rLnks[ n ]; - if( !rLinkRef.is() ) - { - rLnks.erase( rLnks.begin() + n ); - --n; - continue; - } - if( rLinkRef->IsVisible() ) - InsertEntry( *rLinkRef ); + rLnks.erase( rLnks.begin() + n ); + --n; + continue; } + if( rLinkRef->IsVisible() ) + InsertEntry( *rLinkRef ); + } - m_xTbLinks->thaw(); + m_xTbLinks->thaw(); - if( !rLnks.empty() ) - { - m_xTbLinks->set_cursor(0); - m_xTbLinks->select(0); - LinksSelectHdl( nullptr ); - } + if( !rLnks.empty() ) + { + m_xTbLinks->set_cursor(0); + m_xTbLinks->select(0); + LinksSelectHdl( nullptr ); } } @@ -611,24 +611,24 @@ void SvBaseLinksDlg::SetType(SvBaseLink& rLink, void SvBaseLinksDlg::SetActLink( SvBaseLink const * pLink ) { - if( pLinkMgr ) + if( !pLinkMgr ) + return; + + const SvBaseLinks& rLnks = pLinkMgr->GetLinks(); + int nSelect = 0; + for(const auto & rLinkRef : rLnks) { - const SvBaseLinks& rLnks = pLinkMgr->GetLinks(); - int nSelect = 0; - for(const auto & rLinkRef : rLnks) + // #109573# only visible links have been inserted into the TreeListBox, + // invisible ones have to be skipped here + if( rLinkRef->IsVisible() ) { - // #109573# only visible links have been inserted into the TreeListBox, - // invisible ones have to be skipped here - if( rLinkRef->IsVisible() ) + if( pLink == rLinkRef.get() ) { - if( pLink == rLinkRef.get() ) - { - m_xTbLinks->select(nSelect); - LinksSelectHdl( nullptr ); - return ; - } - ++nSelect; + m_xTbLinks->select(nSelect); + LinksSelectHdl( nullptr ); + return ; } + ++nSelect; } } } diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx index c81542b44840..48dc545f93ea 100644 --- a/cui/source/dialogs/multipat.cxx +++ b/cui/source/dialogs/multipat.cxx @@ -89,29 +89,29 @@ IMPL_LINK_NOARG(SvxMultiPathDialog, AddHdl_Impl, weld::Button&, void) Reference < XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference < XFolderPicker2 > xFolderPicker = FolderPicker::create(xContext); - if ( xFolderPicker->execute() == ExecutableDialogResults::OK ) - { - INetURLObject aPath( xFolderPicker->getDirectory() ); - aPath.removeFinalSlash(); - OUString aURL = aPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - OUString sInsPath; - osl::FileBase::getSystemPathFromFileURL(aURL, sInsPath); + if ( xFolderPicker->execute() != ExecutableDialogResults::OK ) + return; - if (m_xRadioLB->find_text(sInsPath) != -1) - { - OUString sMsg( CuiResId( RID_MULTIPATH_DBL_ERR ) ); - sMsg = sMsg.replaceFirst( "%1", sInsPath ); - std::unique_ptr xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Info, VclButtonsType::Ok, sMsg)); - xInfoBox->run(); - } - else - { - AppendEntry(sInsPath, aURL); - } + INetURLObject aPath( xFolderPicker->getDirectory() ); + aPath.removeFinalSlash(); + OUString aURL = aPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + OUString sInsPath; + osl::FileBase::getSystemPathFromFileURL(aURL, sInsPath); - SelectHdl_Impl(*m_xRadioLB); + if (m_xRadioLB->find_text(sInsPath) != -1) + { + OUString sMsg( CuiResId( RID_MULTIPATH_DBL_ERR ) ); + sMsg = sMsg.replaceFirst( "%1", sInsPath ); + std::unique_ptr xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Info, VclButtonsType::Ok, sMsg)); + xInfoBox->run(); + } + else + { + AppendEntry(sInsPath, aURL); } + + SelectHdl_Impl(*m_xRadioLB); } IMPL_LINK_NOARG(SvxPathSelectDialog, AddHdl_Impl, weld::Button&, void) @@ -119,29 +119,29 @@ IMPL_LINK_NOARG(SvxPathSelectDialog, AddHdl_Impl, weld::Button&, void) Reference < XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference < XFolderPicker2 > xFolderPicker = FolderPicker::create(xContext); - if ( xFolderPicker->execute() == ExecutableDialogResults::OK ) - { - INetURLObject aPath( xFolderPicker->getDirectory() ); - aPath.removeFinalSlash(); - OUString aURL = aPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ); - OUString sInsPath; - osl::FileBase::getSystemPathFromFileURL(aURL, sInsPath); + if ( xFolderPicker->execute() != ExecutableDialogResults::OK ) + return; - if (m_xPathLB->find_text(sInsPath) != -1) - { - OUString sMsg( CuiResId( RID_MULTIPATH_DBL_ERR ) ); - sMsg = sMsg.replaceFirst( "%1", sInsPath ); - std::unique_ptr xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Info, VclButtonsType::Ok, sMsg)); - xInfoBox->run(); - } - else - { - m_xPathLB->append(aURL, sInsPath); - } + INetURLObject aPath( xFolderPicker->getDirectory() ); + aPath.removeFinalSlash(); + OUString aURL = aPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + OUString sInsPath; + osl::FileBase::getSystemPathFromFileURL(aURL, sInsPath); - SelectHdl_Impl(*m_xPathLB); + if (m_xPathLB->find_text(sInsPath) != -1) + { + OUString sMsg( CuiResId( RID_MULTIPATH_DBL_ERR ) ); + sMsg = sMsg.replaceFirst( "%1", sInsPath ); + std::unique_ptr xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Info, VclButtonsType::Ok, sMsg)); + xInfoBox->run(); + } + else + { + m_xPathLB->append(aURL, sInsPath); } + + SelectHdl_Impl(*m_xPathLB); } IMPL_LINK_NOARG(SvxMultiPathDialog, DelHdl_Impl, weld::Button&, void) diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx index c9a93d21d9c5..3731163a1f19 100644 --- a/cui/source/dialogs/screenshotannotationdlg.cxx +++ b/cui/source/dialogs/screenshotannotationdlg.cxx @@ -297,53 +297,53 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, saveButtonHandler, weld::Button&, xFilePicker->setDefaultName(OStringToOUString(aDerivedFileName, RTL_TEXTENCODING_UTF8)); xFilePicker->setMultiSelectionMode(false); - if (xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK) - { - maLastFolderURL = xFilePicker->getDisplayDirectory(); - const uno::Sequence< OUString > files(xFilePicker->getSelectedFiles()); + if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK) + return; - if (files.hasElements()) - { - OUString aConfirmedName = files[0]; + maLastFolderURL = xFilePicker->getDisplayDirectory(); + const uno::Sequence< OUString > files(xFilePicker->getSelectedFiles()); - if (!aConfirmedName.isEmpty()) - { - INetURLObject aConfirmedURL(aConfirmedName); - OUString aCurrentExtension(aConfirmedURL.getExtension()); + if (!files.hasElements()) + return; - if (!aCurrentExtension.isEmpty() && aCurrentExtension != "png") - { - aConfirmedURL.removeExtension(); - aCurrentExtension.clear(); - } + OUString aConfirmedName = files[0]; - if (aCurrentExtension.isEmpty()) - { - aConfirmedURL.setExtension("png"); - } + if (aConfirmedName.isEmpty()) + return; - // open stream - SvFileStream aNew(aConfirmedURL.PathToFileName(), StreamMode::WRITE | StreamMode::TRUNC); + INetURLObject aConfirmedURL(aConfirmedName); + OUString aCurrentExtension(aConfirmedURL.getExtension()); - if (aNew.IsOpen()) - { - // prepare bitmap to save - do use the original screenshot here, - // not the dimmed one - RepaintToBuffer(); - - // extract Bitmap - const BitmapEx aTargetBitmap( - mxVirtualBufferDevice->GetBitmapEx( - Point(0, 0), - mxVirtualBufferDevice->GetOutputSizePixel())); - - // write as PNG - vcl::PNGWriter aPNGWriter(aTargetBitmap); - aPNGWriter.Write(aNew); - } - } - } + if (!aCurrentExtension.isEmpty() && aCurrentExtension != "png") + { + aConfirmedURL.removeExtension(); + aCurrentExtension.clear(); + } + + if (aCurrentExtension.isEmpty()) + { + aConfirmedURL.setExtension("png"); } + + // open stream + SvFileStream aNew(aConfirmedURL.PathToFileName(), StreamMode::WRITE | StreamMode::TRUNC); + + if (!aNew.IsOpen()) + return; + + // prepare bitmap to save - do use the original screenshot here, + // not the dimmed one + RepaintToBuffer(); + + // extract Bitmap + const BitmapEx aTargetBitmap( + mxVirtualBufferDevice->GetBitmapEx( + Point(0, 0), + mxVirtualBufferDevice->GetOutputSizePixel())); + + // write as PNG + vcl::PNGWriter aPNGWriter(aTargetBitmap); + aPNGWriter.Write(aNew); } weld::ScreenShotEntry* ScreenshotAnnotationDlg_Impl::CheckHit(const basegfx::B2IPoint& rPosition) @@ -378,42 +378,42 @@ void ScreenshotAnnotationDlg_Impl::PaintScreenShotEntry( double fLineWidth, double fTransparency) { - if (mxPicture && mxVirtualBufferDevice) + if (!(mxPicture && mxVirtualBufferDevice)) + return; + + basegfx::B2DRange aB2DRange(rEntry.getB2IRange()); + + // grow in pixels to be a little bit 'outside'. This also + // ensures that getWidth()/getHeight() ain't 0.0 (see division below) + static const double fGrowTopLeft(1.5); + static const double fGrowBottomRight(0.5); + aB2DRange.expand(aB2DRange.getMinimum() - basegfx::B2DPoint(fGrowTopLeft, fGrowTopLeft)); + aB2DRange.expand(aB2DRange.getMaximum() + basegfx::B2DPoint(fGrowBottomRight, fGrowBottomRight)); + + // edge rounding in pixel. Need to convert, value for + // createPolygonFromRect is relative [0.0 .. 1.0] + static const double fEdgeRoundPixel(8.0); + const basegfx::B2DPolygon aPolygon( + basegfx::utils::createPolygonFromRect( + aB2DRange, + fEdgeRoundPixel / aB2DRange.getWidth(), + fEdgeRoundPixel / aB2DRange.getHeight())); + + mxVirtualBufferDevice->SetLineColor(rColor); + + // try to use transparency + if (!mxVirtualBufferDevice->DrawPolyLineDirect( + basegfx::B2DHomMatrix(), + aPolygon, + fLineWidth, + fTransparency, + nullptr, // MM01 + basegfx::B2DLineJoin::Round)) { - basegfx::B2DRange aB2DRange(rEntry.getB2IRange()); - - // grow in pixels to be a little bit 'outside'. This also - // ensures that getWidth()/getHeight() ain't 0.0 (see division below) - static const double fGrowTopLeft(1.5); - static const double fGrowBottomRight(0.5); - aB2DRange.expand(aB2DRange.getMinimum() - basegfx::B2DPoint(fGrowTopLeft, fGrowTopLeft)); - aB2DRange.expand(aB2DRange.getMaximum() + basegfx::B2DPoint(fGrowBottomRight, fGrowBottomRight)); - - // edge rounding in pixel. Need to convert, value for - // createPolygonFromRect is relative [0.0 .. 1.0] - static const double fEdgeRoundPixel(8.0); - const basegfx::B2DPolygon aPolygon( - basegfx::utils::createPolygonFromRect( - aB2DRange, - fEdgeRoundPixel / aB2DRange.getWidth(), - fEdgeRoundPixel / aB2DRange.getHeight())); - - mxVirtualBufferDevice->SetLineColor(rColor); - - // try to use transparency - if (!mxVirtualBufferDevice->DrawPolyLineDirect( - basegfx::B2DHomMatrix(), + // no transparency, draw without + mxVirtualBufferDevice->DrawPolyLine( aPolygon, - fLineWidth, - fTransparency, - nullptr, // MM01 - basegfx::B2DLineJoin::Round)) - { - // no transparency, draw without - mxVirtualBufferDevice->DrawPolyLine( - aPolygon, - fLineWidth); - } + fLineWidth); } } @@ -430,43 +430,43 @@ void ScreenshotAnnotationDlg_Impl::RepaintToBuffer( bool bUseDimmed, bool bPaintHilight) { - if (mxVirtualBufferDevice) + if (!mxVirtualBufferDevice) + return; + + // reset with original screenshot bitmap + mxVirtualBufferDevice->DrawBitmapEx( + Point(0, 0), + bUseDimmed ? maDimmedDialogBitmap : maParentDialogBitmap); + + // get various options + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor()); + const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01); + const bool bIsAntiAliasing(aSvtOptionsDrawinglayer.IsAntiAliasing()); + const AntialiasingFlags nOldAA(mxVirtualBufferDevice->GetAntialiasing()); + + if (bIsAntiAliasing) { - // reset with original screenshot bitmap - mxVirtualBufferDevice->DrawBitmapEx( - Point(0, 0), - bUseDimmed ? maDimmedDialogBitmap : maParentDialogBitmap); - - // get various options - const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; - const Color aHilightColor(aSvtOptionsDrawinglayer.getHilightColor()); - const double fTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent() * 0.01); - const bool bIsAntiAliasing(aSvtOptionsDrawinglayer.IsAntiAliasing()); - const AntialiasingFlags nOldAA(mxVirtualBufferDevice->GetAntialiasing()); - - if (bIsAntiAliasing) - { - mxVirtualBufferDevice->SetAntialiasing(AntialiasingFlags::EnableB2dDraw); - } + mxVirtualBufferDevice->SetAntialiasing(AntialiasingFlags::EnableB2dDraw); + } - // paint selected entries - for (auto&& rCandidate : maSelected) - { - static const double fLineWidthEntries(5.0); - PaintScreenShotEntry(*rCandidate, COL_LIGHTRED, fLineWidthEntries, fTransparence * 0.2); - } + // paint selected entries + for (auto&& rCandidate : maSelected) + { + static const double fLineWidthEntries(5.0); + PaintScreenShotEntry(*rCandidate, COL_LIGHTRED, fLineWidthEntries, fTransparence * 0.2); + } - // paint highlighted entry - if (mpHilighted && bPaintHilight) - { - static const double fLineWidthHilight(7.0); - PaintScreenShotEntry(*mpHilighted, aHilightColor, fLineWidthHilight, fTransparence); - } + // paint highlighted entry + if (mpHilighted && bPaintHilight) + { + static const double fLineWidthHilight(7.0); + PaintScreenShotEntry(*mpHilighted, aHilightColor, fLineWidthHilight, fTransparence); + } - if (bIsAntiAliasing) - { - mxVirtualBufferDevice->SetAntialiasing(nOldAA); - } + if (bIsAntiAliasing) + { + mxVirtualBufferDevice->SetAntialiasing(nOldAA); } } diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx index 80bab2715ca4..1716316fb32f 100644 --- a/cui/source/dialogs/scriptdlg.cxx +++ b/cui/source/dialogs/scriptdlg.cxx @@ -553,133 +553,133 @@ IMPL_LINK(SvxScriptOrgDialog, ButtonHdl, weld::Button&, rButton, void) StoreCurrentSelection(); m_xDialog->response(RET_CANCEL); } - if (&rButton == m_xEditButton.get() || + if (!(&rButton == m_xEditButton.get() || &rButton == m_xCreateButton.get() || &rButton == m_xDelButton.get() || &rButton == m_xRunButton.get() || - &rButton == m_xRenameButton.get()) + &rButton == m_xRenameButton.get())) - { - std::unique_ptr xIter = m_xScriptsBox->make_iterator(); - if (!m_xScriptsBox->get_selected(xIter.get())) - return; - SFEntry* userData = reinterpret_cast(m_xScriptsBox->get_id(*xIter).toInt64()); - if (!userData) - return; + return; - Reference< browse::XBrowseNode > node; - Reference< XModel > xModel; + std::unique_ptr xIter = m_xScriptsBox->make_iterator(); + if (!m_xScriptsBox->get_selected(xIter.get())) + return; + SFEntry* userData = reinterpret_cast(m_xScriptsBox->get_id(*xIter).toInt64()); + if (!userData) + return; - node = userData->GetNode(); - xModel = userData->GetModel(); + Reference< browse::XBrowseNode > node; + Reference< XModel > xModel; + + node = userData->GetNode(); + xModel = userData->GetModel(); + + if ( !node.is() ) + { + return; + } - if ( !node.is() ) + if (&rButton == m_xRunButton.get()) + { + OUString tmpString; + Reference< beans::XPropertySet > xProp( node, UNO_QUERY ); + Reference< provider::XScriptProvider > mspNode; + if( !xProp.is() ) { return; } - if (&rButton == m_xRunButton.get()) + if ( xModel.is() ) { - OUString tmpString; - Reference< beans::XPropertySet > xProp( node, UNO_QUERY ); - Reference< provider::XScriptProvider > mspNode; - if( !xProp.is() ) + Reference< XEmbeddedScripts > xEmbeddedScripts( xModel, UNO_QUERY); + if( !xEmbeddedScripts.is() ) { return; } - if ( xModel.is() ) + if (!xEmbeddedScripts->getAllowMacroExecution()) { - Reference< XEmbeddedScripts > xEmbeddedScripts( xModel, UNO_QUERY); - if( !xEmbeddedScripts.is() ) - { - return; - } - - if (!xEmbeddedScripts->getAllowMacroExecution()) - { - // Please FIXME: Show a message box if AllowMacroExecution is false - return; - } + // Please FIXME: Show a message box if AllowMacroExecution is false + return; } + } - std::unique_ptr xParentIter = m_xScriptsBox->make_iterator(xIter.get()); - bool bParent = m_xScriptsBox->iter_parent(*xParentIter); - while (bParent && !mspNode.is() ) - { - SFEntry* mspUserData = reinterpret_cast(m_xScriptsBox->get_id(*xParentIter).toInt64()); - mspNode.set( mspUserData->GetNode() , UNO_QUERY ); - bParent = m_xScriptsBox->iter_parent(*xParentIter); - } - xProp->getPropertyValue("URI") >>= tmpString; - const OUString scriptURL( tmpString ); + std::unique_ptr xParentIter = m_xScriptsBox->make_iterator(xIter.get()); + bool bParent = m_xScriptsBox->iter_parent(*xParentIter); + while (bParent && !mspNode.is() ) + { + SFEntry* mspUserData = reinterpret_cast(m_xScriptsBox->get_id(*xParentIter).toInt64()); + mspNode.set( mspUserData->GetNode() , UNO_QUERY ); + bParent = m_xScriptsBox->iter_parent(*xParentIter); + } + xProp->getPropertyValue("URI") >>= tmpString; + const OUString scriptURL( tmpString ); - if ( mspNode.is() ) + if ( mspNode.is() ) + { + try { - try - { - Reference< provider::XScript > xScript( - mspNode->getScript( scriptURL ), UNO_SET_THROW ); + Reference< provider::XScript > xScript( + mspNode->getScript( scriptURL ), UNO_SET_THROW ); - const Sequence< Any > args(0); - Sequence< sal_Int16 > outIndex; - Sequence< Any > outArgs( 0 ); - xScript->invoke( args, outIndex, outArgs ); - } - catch ( reflection::InvocationTargetException& ite ) - { - ShowErrorDialog(css::uno::Any(ite)); - } - catch ( provider::ScriptFrameworkErrorException& ite ) - { - ShowErrorDialog(css::uno::Any(ite)); - } - catch ( RuntimeException& re ) - { - ShowErrorDialog(css::uno::Any(re)); - } - catch ( Exception& e ) - { - ShowErrorDialog(css::uno::Any(e)); - } + const Sequence< Any > args(0); + Sequence< sal_Int16 > outIndex; + Sequence< Any > outArgs( 0 ); + xScript->invoke( args, outIndex, outArgs ); } - StoreCurrentSelection(); - m_xDialog->response(RET_CANCEL); - } - else if ( &rButton == m_xEditButton.get() ) - { - Reference< script::XInvocation > xInv( node, UNO_QUERY ); - if ( xInv.is() ) + catch ( reflection::InvocationTargetException& ite ) { - StoreCurrentSelection(); - m_xDialog->response(RET_CANCEL); - Sequence< Any > args(0); - Sequence< Any > outArgs( 0 ); - Sequence< sal_Int16 > outIndex; - try - { - // ISSUE need code to run script here - xInv->invoke( "Editable", args, outIndex, outArgs ); - } - catch( Exception const & ) - { - TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to invoke" ); - } + ShowErrorDialog(css::uno::Any(ite)); + } + catch ( provider::ScriptFrameworkErrorException& ite ) + { + ShowErrorDialog(css::uno::Any(ite)); + } + catch ( RuntimeException& re ) + { + ShowErrorDialog(css::uno::Any(re)); + } + catch ( Exception& e ) + { + ShowErrorDialog(css::uno::Any(e)); } } - else if ( &rButton == m_xCreateButton.get() ) - { - createEntry(*xIter); - } - else if ( &rButton == m_xDelButton.get() ) - { - deleteEntry(*xIter); - } - else if ( &rButton == m_xRenameButton.get() ) + StoreCurrentSelection(); + m_xDialog->response(RET_CANCEL); + } + else if ( &rButton == m_xEditButton.get() ) + { + Reference< script::XInvocation > xInv( node, UNO_QUERY ); + if ( xInv.is() ) { - renameEntry(*xIter); + StoreCurrentSelection(); + m_xDialog->response(RET_CANCEL); + Sequence< Any > args(0); + Sequence< Any > outArgs( 0 ); + Sequence< sal_Int16 > outIndex; + try + { + // ISSUE need code to run script here + xInv->invoke( "Editable", args, outIndex, outArgs ); + } + catch( Exception const & ) + { + TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to invoke" ); + } } } + else if ( &rButton == m_xCreateButton.get() ) + { + createEntry(*xIter); + } + else if ( &rButton == m_xDelButton.get() ) + { + deleteEntry(*xIter); + } + else if ( &rButton == m_xRenameButton.get() ) + { + renameEntry(*xIter); + } } Reference< browse::XBrowseNode > SvxScriptOrgDialog::getBrowseNode(const weld::TreeIter& rEntry) diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx index 24df2e4930c6..98fd6d19fe15 100644 --- a/cui/source/options/dbregister.cxx +++ b/cui/source/options/dbregister.cxx @@ -271,20 +271,20 @@ void DbRegistrationOptionsPage::openLinkDialog(const OUString& sOldName, const O aDlg.setLink(sOldName, sOldLocation); aDlg.setNameValidator(LINK( this, DbRegistrationOptionsPage, NameValidator ) ); - if (aDlg.run() == RET_OK) + if (aDlg.run() != RET_OK) + return; + + OUString sNewName,sNewLocation; + aDlg.getLink(sNewName,sNewLocation); + if ( nEntry == -1 || sNewName != sOldName || sNewLocation != sOldLocation ) { - OUString sNewName,sNewLocation; - aDlg.getLink(sNewName,sNewLocation); - if ( nEntry == -1 || sNewName != sOldName || sNewLocation != sOldLocation ) + if (nEntry != -1) { - if (nEntry != -1) - { - delete reinterpret_cast(m_xPathBox->get_id(nEntry).toInt64()); - m_xPathBox->remove(nEntry); - } - insertNewEntry( sNewName, sNewLocation, false ); - m_bModified = true; + delete reinterpret_cast(m_xPathBox->get_id(nEntry).toInt64()); + m_xPathBox->remove(nEntry); } + insertNewEntry( sNewName, sNewLocation, false ); + m_bModified = true; } } diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx index bb1b4fbc196b..f5afdca178dd 100644 --- a/cui/source/options/optaboutconfig.cxx +++ b/cui/source/options/optaboutconfig.cxx @@ -570,218 +570,218 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void ) return; UserData *pUserData = reinterpret_cast(m_xPrefBox->get_id(*m_xScratchIter).toInt64()); - if (pUserData && pUserData->bIsPropertyPath) - { - //if selection is a node - OUString sPropertyName = m_xPrefBox->get_text(*m_xScratchIter, 1); - OUString sPropertyType = m_xPrefBox->get_text(*m_xScratchIter, 2); - OUString sPropertyValue = m_xPrefBox->get_text(*m_xScratchIter, 3); + if (!(pUserData && pUserData->bIsPropertyPath)) + return; - auto pProperty = std::make_shared( pUserData->sPropertyPath, sPropertyName, Any( sPropertyValue ) ); - bool bSaveChanges = false; + //if selection is a node + OUString sPropertyName = m_xPrefBox->get_text(*m_xScratchIter, 1); + OUString sPropertyType = m_xPrefBox->get_text(*m_xScratchIter, 2); + OUString sPropertyValue = m_xPrefBox->get_text(*m_xScratchIter, 3); - bool bOpenDialog = true; - OUString sDialogValue; - OUString sNewValue; + auto pProperty = std::make_shared( pUserData->sPropertyPath, sPropertyName, Any( sPropertyValue ) ); + bool bSaveChanges = false; - if( sPropertyType == "boolean" ) - { - bool bValue; - if( sPropertyValue == "true" ) - { - sDialogValue = "false"; - bValue = false; - } - else - { - sDialogValue = "true"; - bValue = true; - } + bool bOpenDialog = true; + OUString sDialogValue; + OUString sNewValue; - pProperty->Value <<= bValue; - bOpenDialog = false; - bSaveChanges = true; - } - else if ( sPropertyType == "void" ) + if( sPropertyType == "boolean" ) + { + bool bValue; + if( sPropertyValue == "true" ) { - bOpenDialog = false; + sDialogValue = "false"; + bValue = false; } else { - sDialogValue = sPropertyValue; - bOpenDialog = true; + sDialogValue = "true"; + bValue = true; } - try + pProperty->Value <<= bValue; + bOpenDialog = false; + bSaveChanges = true; + } + else if ( sPropertyType == "void" ) + { + bOpenDialog = false; + } + else + { + sDialogValue = sPropertyValue; + bOpenDialog = true; + } + + try + { + if( bOpenDialog ) { - if( bOpenDialog ) + //Cosmetic length limit for integer values. + int limit=0; + if( sPropertyType == "short" ) + limit = SHORT_LEN_LIMIT; + else if( sPropertyType == "long" ) + limit = LONG_LEN_LIMIT; + else if( sPropertyType == "hyper" ) + limit = HYPER_LEN_LIMIT; + + CuiAboutConfigValueDialog aValueDialog(m_xDialog.get(), sDialogValue, limit); + + if (aValueDialog.run() == RET_OK ) { - //Cosmetic length limit for integer values. - int limit=0; - if( sPropertyType == "short" ) - limit = SHORT_LEN_LIMIT; + sNewValue = aValueDialog.getValue(); + bSaveChanges = true; + if ( sPropertyType == "short") + { + sal_Int16 nShort; + sal_Int32 nNumb = sNewValue.toInt32(); + + //if the value is 0 and length is not 1, there is something wrong + if( ( nNumb==0 && sNewValue.getLength()!=1 ) || nNumb > SAL_MAX_INT16 || nNumb < SAL_MIN_INT16) + throw uno::Exception("out of range short", nullptr); + nShort = static_cast(nNumb); + pProperty->Value <<= nShort; + } else if( sPropertyType == "long" ) - limit = LONG_LEN_LIMIT; - else if( sPropertyType == "hyper" ) - limit = HYPER_LEN_LIMIT; - - CuiAboutConfigValueDialog aValueDialog(m_xDialog.get(), sDialogValue, limit); - - if (aValueDialog.run() == RET_OK ) { - sNewValue = aValueDialog.getValue(); - bSaveChanges = true; - if ( sPropertyType == "short") - { - sal_Int16 nShort; - sal_Int32 nNumb = sNewValue.toInt32(); - - //if the value is 0 and length is not 1, there is something wrong - if( ( nNumb==0 && sNewValue.getLength()!=1 ) || nNumb > SAL_MAX_INT16 || nNumb < SAL_MIN_INT16) - throw uno::Exception("out of range short", nullptr); - nShort = static_cast(nNumb); - pProperty->Value <<= nShort; - } - else if( sPropertyType == "long" ) - { - sal_Int32 nLong = sNewValue.toInt32(); - if( nLong==0 && sNewValue.getLength()!=1) - throw uno::Exception("out of range long", nullptr); - pProperty->Value <<= nLong; - } - else if( sPropertyType == "hyper") - { - sal_Int64 nHyper = sNewValue.toInt64(); - if( nHyper==0 && sNewValue.getLength()!=1) - throw uno::Exception("out of range hyper", nullptr); - pProperty->Value <<= nHyper; - } - else if( sPropertyType == "double") - { - double nDoub = sNewValue.toDouble(); - if( nDoub ==0 && sNewValue.getLength()!=1) - throw uno::Exception("out of range double", nullptr); - pProperty->Value <<= nDoub; - } - else if( sPropertyType == "float") - { - float nFloat = sNewValue.toFloat(); - if( nFloat ==0 && sNewValue.getLength()!=1) - throw uno::Exception("out of range float", nullptr); - pProperty->Value <<= nFloat; - } - else if( sPropertyType == "string" ) - { - pProperty->Value <<= sNewValue; - } - else if( sPropertyType == "[]short" ) + sal_Int32 nLong = sNewValue.toInt32(); + if( nLong==0 && sNewValue.getLength()!=1) + throw uno::Exception("out of range long", nullptr); + pProperty->Value <<= nLong; + } + else if( sPropertyType == "hyper") + { + sal_Int64 nHyper = sNewValue.toInt64(); + if( nHyper==0 && sNewValue.getLength()!=1) + throw uno::Exception("out of range hyper", nullptr); + pProperty->Value <<= nHyper; + } + else if( sPropertyType == "double") + { + double nDoub = sNewValue.toDouble(); + if( nDoub ==0 && sNewValue.getLength()!=1) + throw uno::Exception("out of range double", nullptr); + pProperty->Value <<= nDoub; + } + else if( sPropertyType == "float") + { + float nFloat = sNewValue.toFloat(); + if( nFloat ==0 && sNewValue.getLength()!=1) + throw uno::Exception("out of range float", nullptr); + pProperty->Value <<= nFloat; + } + else if( sPropertyType == "string" ) + { + pProperty->Value <<= sNewValue; + } + else if( sPropertyType == "[]short" ) + { + //create string sequence from comma separated string + //uno::Sequence< OUString > seqStr; + std::vector< OUString > seqStr = commaStringToSequence( sNewValue ); + + //create appropriate sequence with same size as string sequence + uno::Sequence< sal_Int16 > seqShort( seqStr.size() ); + //convert all strings to appropriate type + for( size_t i = 0; i < seqStr.size(); ++i ) { - //create string sequence from comma separated string - //uno::Sequence< OUString > seqStr; - std::vector< OUString > seqStr = commaStringToSequence( sNewValue ); - - //create appropriate sequence with same size as string sequence - uno::Sequence< sal_Int16 > seqShort( seqStr.size() ); - //convert all strings to appropriate type - for( size_t i = 0; i < seqStr.size(); ++i ) - { - seqShort[i] = static_cast(seqStr[i].toInt32()); - } - pProperty->Value <<= seqShort; + seqShort[i] = static_cast(seqStr[i].toInt32()); } - else if( sPropertyType == "[]long" ) - { - std::vector< OUString > seqStrLong = commaStringToSequence( sNewValue ); + pProperty->Value <<= seqShort; + } + else if( sPropertyType == "[]long" ) + { + std::vector< OUString > seqStrLong = commaStringToSequence( sNewValue ); - uno::Sequence< sal_Int32 > seqLong( seqStrLong.size() ); - for( size_t i = 0; i < seqStrLong.size(); ++i ) - { - seqLong[i] = seqStrLong[i].toInt32(); - } - pProperty->Value <<= seqLong; - } - else if( sPropertyType == "[]hyper" ) + uno::Sequence< sal_Int32 > seqLong( seqStrLong.size() ); + for( size_t i = 0; i < seqStrLong.size(); ++i ) { - std::vector< OUString > seqStrHyper = commaStringToSequence( sNewValue ); - uno::Sequence< sal_Int64 > seqHyper( seqStrHyper.size() ); - for( size_t i = 0; i < seqStrHyper.size(); ++i ) - { - seqHyper[i] = seqStrHyper[i].toInt64(); - } - pProperty->Value <<= seqHyper; + seqLong[i] = seqStrLong[i].toInt32(); } - else if( sPropertyType == "[]double" ) + pProperty->Value <<= seqLong; + } + else if( sPropertyType == "[]hyper" ) + { + std::vector< OUString > seqStrHyper = commaStringToSequence( sNewValue ); + uno::Sequence< sal_Int64 > seqHyper( seqStrHyper.size() ); + for( size_t i = 0; i < seqStrHyper.size(); ++i ) { - std::vector< OUString > seqStrDoub = commaStringToSequence( sNewValue ); - uno::Sequence< double > seqDoub( seqStrDoub.size() ); - for( size_t i = 0; i < seqStrDoub.size(); ++i ) - { - seqDoub[i] = seqStrDoub[i].toDouble(); - } - pProperty->Value <<= seqDoub; + seqHyper[i] = seqStrHyper[i].toInt64(); } - else if( sPropertyType == "[]float" ) + pProperty->Value <<= seqHyper; + } + else if( sPropertyType == "[]double" ) + { + std::vector< OUString > seqStrDoub = commaStringToSequence( sNewValue ); + uno::Sequence< double > seqDoub( seqStrDoub.size() ); + for( size_t i = 0; i < seqStrDoub.size(); ++i ) { - std::vector< OUString > seqStrFloat = commaStringToSequence( sNewValue ); - uno::Sequence< sal_Int16 > seqFloat( seqStrFloat.size() ); - for( size_t i = 0; i < seqStrFloat.size(); ++i ) - { - seqFloat[i] = seqStrFloat[i].toFloat(); - } - pProperty->Value <<= seqFloat; + seqDoub[i] = seqStrDoub[i].toDouble(); } - else if( sPropertyType == "[]string" ) + pProperty->Value <<= seqDoub; + } + else if( sPropertyType == "[]float" ) + { + std::vector< OUString > seqStrFloat = commaStringToSequence( sNewValue ); + uno::Sequence< sal_Int16 > seqFloat( seqStrFloat.size() ); + for( size_t i = 0; i < seqStrFloat.size(); ++i ) { - pProperty->Value <<= comphelper::containerToSequence( commaStringToSequence( sNewValue )); + seqFloat[i] = seqStrFloat[i].toFloat(); } - else //unknown - throw uno::Exception("unknown property type " + sPropertyType, nullptr); - - sDialogValue = sNewValue; + pProperty->Value <<= seqFloat; } + else if( sPropertyType == "[]string" ) + { + pProperty->Value <<= comphelper::containerToSequence( commaStringToSequence( sNewValue )); + } + else //unknown + throw uno::Exception("unknown property type " + sPropertyType, nullptr); + + sDialogValue = sNewValue; } + } + + if(bSaveChanges) + { + AddToModifiedVector( pProperty ); - if(bSaveChanges) + //update listbox value. + m_xPrefBox->set_text(*m_xScratchIter, sDialogValue, 3); + //update m_prefBoxEntries + auto it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(), + [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool + { + return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath + && rEntry.sStatus == sPropertyName; + } + ); + if (it != m_prefBoxEntries.end()) { - AddToModifiedVector( pProperty ); - - //update listbox value. - m_xPrefBox->set_text(*m_xScratchIter, sDialogValue, 3); - //update m_prefBoxEntries - auto it = std::find_if(m_prefBoxEntries.begin(), m_prefBoxEntries.end(), - [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool - { - return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath - && rEntry.sStatus == sPropertyName; - } - ); - if (it != m_prefBoxEntries.end()) - { - it->sValue = sDialogValue; + it->sValue = sDialogValue; - auto modifiedIt = std::find_if( - m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(), - [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool - { - return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath - && rEntry.sStatus == sPropertyName; - } - ); + auto modifiedIt = std::find_if( + m_modifiedPrefBoxEntries.begin(), m_modifiedPrefBoxEntries.end(), + [&pUserData, &sPropertyName](const prefBoxEntry& rEntry) -> bool + { + return rEntry.pUserData->sPropertyPath == pUserData->sPropertyPath + && rEntry.sStatus == sPropertyName; + } + ); - if (modifiedIt != m_modifiedPrefBoxEntries.end()) - { - modifiedIt->sValue = sDialogValue; - } - else - { - m_modifiedPrefBoxEntries.push_back(*it); - } + if (modifiedIt != m_modifiedPrefBoxEntries.end()) + { + modifiedIt->sValue = sDialogValue; + } + else + { + m_modifiedPrefBoxEntries.push_back(*it); } } } - catch( uno::Exception& ) - { - } + } + catch( uno::Exception& ) + { } } diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index 4e322d0818a8..4ca091bb6c45 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -225,29 +225,29 @@ IMPL_LINK_NOARG( SvxDefaultColorOptPage, RemoveChartColor, weld::Button&, void ) if (nIndex == -1) return; - if( m_SvxChartColorTableUniquePtr ) - { - OSL_ENSURE(m_SvxChartColorTableUniquePtr->size() > 1, "don't delete the last chart color"); + if( !m_SvxChartColorTableUniquePtr ) + return; - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletechartcolordialog.ui")); - std::unique_ptr xQuery(xBuilder->weld_message_dialog("QueryDeleteChartColorDialog")); + OSL_ENSURE(m_SvxChartColorTableUniquePtr->size() > 1, "don't delete the last chart color"); - if (RET_YES == xQuery->run()) - { - m_SvxChartColorTableUniquePtr->remove(nIndex); + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletechartcolordialog.ui")); + std::unique_ptr xQuery(xBuilder->weld_message_dialog("QueryDeleteChartColorDialog")); - FillBoxChartColorLB(); + if (RET_YES != xQuery->run()) + return; - m_xLbChartColors->grab_focus(); + m_SvxChartColorTableUniquePtr->remove(nIndex); - if (nIndex == m_xLbChartColors->n_children() && m_xLbChartColors->n_children() > 0) - m_xLbChartColors->select(m_SvxChartColorTableUniquePtr->size() - 1); - else if (m_xLbChartColors->n_children() > 0) - m_xLbChartColors->select( nIndex ); - else - m_xPBRemove->set_sensitive(true); - } - } + FillBoxChartColorLB(); + + m_xLbChartColors->grab_focus(); + + if (nIndex == m_xLbChartColors->n_children() && m_xLbChartColors->n_children() > 0) + m_xLbChartColors->select(m_SvxChartColorTableUniquePtr->size() - 1); + else if (m_xLbChartColors->n_children() > 0) + m_xLbChartColors->select( nIndex ); + else + m_xPBRemove->set_sensitive(true); } IMPL_LINK_NOARG( SvxDefaultColorOptPage, SelectPaletteLbHdl, weld::ComboBox&, void) diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx index 0f05784d5bae..384f5f23ed16 100644 --- a/cui/source/options/optcolor.cxx +++ b/cui/source/options/optcolor.cxx @@ -414,41 +414,42 @@ void ColorConfigWindow_Impl::CreateEntries() // extended entries ExtendedColorConfig aExtConfig; - if (unsigned const nExtGroupCount = aExtConfig.GetComponentCount()) + unsigned const nExtGroupCount = aExtConfig.GetComponentCount(); + if (!nExtGroupCount) + return; + + size_t nLineNum = vChapters.size() + vEntries.size() + 1; + for (unsigned j = 0; j != nExtGroupCount; ++j) { - size_t nLineNum = vChapters.size() + vEntries.size() + 1; - for (unsigned j = 0; j != nExtGroupCount; ++j) + vExtBuilders.emplace_back(Application::CreateBuilder(m_xGrid.get(), "cui/ui/chapterfragment.ui")); + vExtContainers.emplace_back(vExtBuilders.back()->weld_container("ChapterFragment")); + + vExtContainers.back()->set_grid_width(3); + vExtContainers.back()->set_grid_left_attach(0); + vExtContainers.back()->set_grid_top_attach(nLineNum); + + OUString const sComponentName = aExtConfig.GetComponentName(j); + vChapters.push_back(std::make_shared( + *vExtBuilders.back(), "chapter", true)); + vChapters.back()->SetText(aExtConfig.GetComponentDisplayName(sComponentName)); + ++nLineNum; + unsigned nColorCount = aExtConfig.GetComponentColorCount(sComponentName); + for (unsigned i = 0; i != nColorCount; ++i) { - vExtBuilders.emplace_back(Application::CreateBuilder(m_xGrid.get(), "cui/ui/chapterfragment.ui")); - vExtContainers.emplace_back(vExtBuilders.back()->weld_container("ChapterFragment")); + vExtBuilders.emplace_back(Application::CreateBuilder(m_xGrid.get(), "cui/ui/colorfragment.ui")); + vExtContainers.emplace_back(vExtBuilders.back()->weld_container("ColorFragment")); vExtContainers.back()->set_grid_width(3); vExtContainers.back()->set_grid_left_attach(0); vExtContainers.back()->set_grid_top_attach(nLineNum); - OUString const sComponentName = aExtConfig.GetComponentName(j); - vChapters.push_back(std::make_shared( - *vExtBuilders.back(), "chapter", true)); - vChapters.back()->SetText(aExtConfig.GetComponentDisplayName(sComponentName)); + ExtendedColorConfigValue const aColorEntry = + aExtConfig.GetComponentColorConfigValue(sComponentName, i); + vEntries.push_back(std::make_shared(m_pTopLevel, *vExtBuilders.back(), + "label", "button", aColorEntry.getDefaultColor(), + nCheckBoxLabelOffset, false, true)); + vEntries.back()->SetText(aColorEntry.getDisplayName()); ++nLineNum; - unsigned nColorCount = aExtConfig.GetComponentColorCount(sComponentName); - for (unsigned i = 0; i != nColorCount; ++i) - { - vExtBuilders.emplace_back(Application::CreateBuilder(m_xGrid.get(), "cui/ui/colorfragment.ui")); - vExtContainers.emplace_back(vExtBuilders.back()->weld_container("ColorFragment")); - - vExtContainers.back()->set_grid_width(3); - vExtContainers.back()->set_grid_left_attach(0); - vExtContainers.back()->set_grid_top_attach(nLineNum); - - ExtendedColorConfigValue const aColorEntry = - aExtConfig.GetComponentColorConfigValue(sComponentName, i); - vEntries.push_back(std::make_shared(m_pTopLevel, *vExtBuilders.back(), - "label", "button", aColorEntry.getDefaultColor(), - nCheckBoxLabelOffset, false, true)); - vEntries.back()->SetText(aColorEntry.getDisplayName()); - ++nLineNum; - } } } } @@ -673,22 +674,22 @@ IMPL_LINK(ColorConfigCtrl_Impl, ControlFocusHdl, weld::Widget&, rCtrl, void) bool const shouldScrollUp = nSelectedItemTop <= nWinTop; bool const isNeedToScroll = shouldScrollDown || shouldScrollUp || nCtrlPosY < 0; - if (isNeedToScroll) + if (!isNeedToScroll) + return; + + if (shouldScrollDown) { - if (shouldScrollDown) - { - int nOffset = nSelectedItemBottom - nWinBottom; - nThumbPos += nOffset + 2; - } - else - { - int nOffset = nWinTop - nSelectedItemTop; - nThumbPos -= nOffset + 2; - if(nThumbPos < 0) - nThumbPos = 0; - } - m_xVScroll->vadjustment_set_value(nThumbPos); + int nOffset = nSelectedItemBottom - nWinBottom; + nThumbPos += nOffset + 2; + } + else + { + int nOffset = nWinTop - nSelectedItemTop; + nThumbPos -= nOffset + 2; + if(nThumbPos < 0) + nThumbPos = 0; } + m_xVScroll->vadjustment_set_value(nThumbPos); } // SvxColorOptionsTabPage diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx index 0e42e8d5cc34..f1678a5458e9 100644 --- a/cui/source/options/optdict.cxx +++ b/cui/source/options/optdict.cxx @@ -392,22 +392,22 @@ void SvxEditDictionaryDialog::RemoveDictEntry(int nEntry) IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectBookHdl_Impl, weld::ComboBox&, void) { int nPos = m_xAllDictsLB->get_active(); - if (nPos != -1) - { - m_xNewReplacePB->set_sensitive( false ); - m_xDeletePB->set_sensitive( false ); - // display dictionary - ShowWords_Impl( nPos ); - // enable or disable new and delete button according to file attributes - Reference< XDictionary > xDic( aDics.getConstArray()[ nPos ], UNO_QUERY ); - if (xDic.is()) - SetLanguage_Impl( LanguageTag( xDic->getLocale() ).getLanguageType() ); + if (nPos == -1) + return; - SetDicReadonly_Impl(xDic); - bool bEnable = !IsDicReadonly_Impl(); - m_xLangFT->set_sensitive( bEnable ); - m_xLangLB->set_sensitive( bEnable ); - } + m_xNewReplacePB->set_sensitive( false ); + m_xDeletePB->set_sensitive( false ); + // display dictionary + ShowWords_Impl( nPos ); + // enable or disable new and delete button according to file attributes + Reference< XDictionary > xDic( aDics.getConstArray()[ nPos ], UNO_QUERY ); + if (xDic.is()) + SetLanguage_Impl( LanguageTag( xDic->getLocale() ).getLanguageType() ); + + SetDicReadonly_Impl(xDic); + bool bEnable = !IsDicReadonly_Impl(); + m_xLangFT->set_sensitive( bEnable ); + m_xLangLB->set_sensitive( bEnable ); } IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectLangHdl_Impl, weld::ComboBox&, void) @@ -417,31 +417,31 @@ IMPL_LINK_NOARG(SvxEditDictionaryDialog, SelectLangHdl_Impl, weld::ComboBox&, vo Reference< XDictionary > xDic( aDics.getConstArray()[ nDicPos ], UNO_QUERY ); LanguageType nOldLang = LanguageTag( xDic->getLocale() ).getLanguageType(); - if ( nLang != nOldLang ) + if ( nLang == nOldLang ) + return; + + std::unique_ptr xBox(Application::CreateMessageDialog(m_xDialog.get(), + VclMessageType::Question, VclButtonsType::YesNo, + CuiResId(RID_SVXSTR_CONFIRM_SET_LANGUAGE))); + OUString sTxt(xBox->get_primary_text()); + sTxt = sTxt.replaceFirst("%1", m_xAllDictsLB->get_active_text()); + xBox->set_primary_text(sTxt); + + if (xBox->run() == RET_YES) { - std::unique_ptr xBox(Application::CreateMessageDialog(m_xDialog.get(), - VclMessageType::Question, VclButtonsType::YesNo, - CuiResId(RID_SVXSTR_CONFIRM_SET_LANGUAGE))); - OUString sTxt(xBox->get_primary_text()); - sTxt = sTxt.replaceFirst("%1", m_xAllDictsLB->get_active_text()); - xBox->set_primary_text(sTxt); - - if (xBox->run() == RET_YES) - { - xDic->setLocale( LanguageTag::convertToLocale( nLang ) ); - bool bNegativ = xDic->getDictionaryType() == DictionaryType_NEGATIVE; - - const OUString sName( - ::GetDicInfoStr( xDic->getName(), - LanguageTag( xDic->getLocale() ).getLanguageType(), - bNegativ ) ); - m_xAllDictsLB->remove(nDicPos); - m_xAllDictsLB->insert_text(nDicPos, sName); - m_xAllDictsLB->set_active(nDicPos); - } - else - SetLanguage_Impl( nOldLang ); + xDic->setLocale( LanguageTag::convertToLocale( nLang ) ); + bool bNegativ = xDic->getDictionaryType() == DictionaryType_NEGATIVE; + + const OUString sName( + ::GetDicInfoStr( xDic->getName(), + LanguageTag( xDic->getLocale() ).getLanguageType(), + bNegativ ) ); + m_xAllDictsLB->remove(nDicPos); + m_xAllDictsLB->insert_text(nDicPos, sName); + m_xAllDictsLB->set_active(nDicPos); } + else + SetLanguage_Impl( nOldLang ); } void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId ) diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 50fdda97d17b..e0a95eea2282 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -139,20 +139,20 @@ void OpenGLCfg::reset() OpenGLCfg::~OpenGLCfg() { - if (mbModified) + if (!mbModified) + return; + + try + { + std::shared_ptr batch(comphelper::ConfigurationChanges::create()); + if (!officecfg::Office::Common::VCL::UseOpenGL::isReadOnly()) + officecfg::Office::Common::VCL::UseOpenGL::set(mbUseOpenGL, batch); + if (!officecfg::Office::Common::VCL::ForceOpenGL::isReadOnly()) + officecfg::Office::Common::VCL::ForceOpenGL::set(mbForceOpenGL, batch); + batch->commit(); + } + catch (...) { - try - { - std::shared_ptr batch(comphelper::ConfigurationChanges::create()); - if (!officecfg::Office::Common::VCL::UseOpenGL::isReadOnly()) - officecfg::Office::Common::VCL::UseOpenGL::set(mbUseOpenGL, batch); - if (!officecfg::Office::Common::VCL::ForceOpenGL::isReadOnly()) - officecfg::Office::Common::VCL::ForceOpenGL::set(mbForceOpenGL, batch); - batch->commit(); - } - catch (...) - { - } } } @@ -223,22 +223,22 @@ void SkiaCfg::reset() SkiaCfg::~SkiaCfg() { - if (mbModified) + if (!mbModified) + return; + + try + { + std::shared_ptr batch(comphelper::ConfigurationChanges::create()); + if (!officecfg::Office::Common::VCL::UseSkia::isReadOnly()) + officecfg::Office::Common::VCL::UseSkia::set(mbUseSkia, batch); + if (!officecfg::Office::Common::VCL::ForceSkia::isReadOnly()) + officecfg::Office::Common::VCL::ForceSkia::set(mbForceSkia, batch); + if (!officecfg::Office::Common::VCL::ForceSkiaRaster::isReadOnly()) + officecfg::Office::Common::VCL::ForceSkiaRaster::set(mbForceSkiaRaster, batch); + batch->commit(); + } + catch (...) { - try - { - std::shared_ptr batch(comphelper::ConfigurationChanges::create()); - if (!officecfg::Office::Common::VCL::UseSkia::isReadOnly()) - officecfg::Office::Common::VCL::UseSkia::set(mbUseSkia, batch); - if (!officecfg::Office::Common::VCL::ForceSkia::isReadOnly()) - officecfg::Office::Common::VCL::ForceSkia::set(mbForceSkia, batch); - if (!officecfg::Office::Common::VCL::ForceSkiaRaster::isReadOnly()) - officecfg::Office::Common::VCL::ForceSkiaRaster::set(mbForceSkiaRaster, batch); - batch->commit(); - } - catch (...) - { - } } } diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx index d54e965c3f05..6fcef33199c3 100644 --- a/cui/source/options/optgenrl.cxx +++ b/cui/source/options/optgenrl.cxx @@ -399,21 +399,21 @@ IMPL_LINK( SvxGeneralTabPage, ModifyHdl_Impl, weld::Entry&, rEdit, void ) nField = i; } // updating the initial - if (nField < nInits && rShortName.xEdit->get_sensitive()) + if (!(nField < nInits && rShortName.xEdit->get_sensitive())) + return; + + OUString sShortName = rShortName.xEdit->get_text(); + // clear short name if it contains more characters than the number of initials + if (o3tl::make_unsigned(sShortName.getLength()) > nInits) { - OUString sShortName = rShortName.xEdit->get_text(); - // clear short name if it contains more characters than the number of initials - if (o3tl::make_unsigned(sShortName.getLength()) > nInits) - { - rShortName.xEdit->set_text(OUString()); - } - while (o3tl::make_unsigned(sShortName.getLength()) < nInits) - sShortName += " "; - OUString sName = rEdit.get_text(); - OUString sLetter = sName.isEmpty() - ? OUString(u' ') : sName.copy(0, 1); - rShortName.xEdit->set_text(sShortName.replaceAt(nField, 1, sLetter).trim()); + rShortName.xEdit->set_text(OUString()); } + while (o3tl::make_unsigned(sShortName.getLength()) < nInits) + sShortName += " "; + OUString sName = rEdit.get_text(); + OUString sLetter = sName.isEmpty() + ? OUString(u' ') : sName.copy(0, 1); + rShortName.xEdit->set_text(sShortName.replaceAt(nField, 1, sLetter).trim()); } diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index 86a0431e03ad..0644d84ec394 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -907,28 +907,28 @@ void SvxEMailTabPage::Reset( const SfxItemSet* ) IMPL_LINK_NOARG(SvxEMailTabPage, FileDialogHdl_Impl, weld::Button&, void) { - if (!pImpl->bROProgram) - { - FileDialogHelper aHelper(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, GetFrameWeld()); - OUString sPath = m_xMailerURLED->get_text(); - if ( sPath.isEmpty() ) - sPath = "/usr/bin"; + if (pImpl->bROProgram) + return; + + FileDialogHelper aHelper(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, GetFrameWeld()); + OUString sPath = m_xMailerURLED->get_text(); + if ( sPath.isEmpty() ) + sPath = "/usr/bin"; - OUString sUrl; - osl::FileBase::getFileURLFromSystemPath(sPath, sUrl); - aHelper.SetDisplayDirectory(sUrl); - aHelper.AddFilter( m_sDefaultFilterName, "*"); + OUString sUrl; + osl::FileBase::getFileURLFromSystemPath(sPath, sUrl); + aHelper.SetDisplayDirectory(sUrl); + aHelper.AddFilter( m_sDefaultFilterName, "*"); - if ( ERRCODE_NONE == aHelper.Execute() ) + if ( ERRCODE_NONE == aHelper.Execute() ) + { + sUrl = aHelper.GetPath(); + if (osl::FileBase::getSystemPathFromFileURL(sUrl, sPath) + != osl::FileBase::E_None) { - sUrl = aHelper.GetPath(); - if (osl::FileBase::getSystemPathFromFileURL(sUrl, sPath) - != osl::FileBase::E_None) - { - sPath.clear(); - } - m_xMailerURLED->set_text(sPath); + sPath.clear(); } + m_xMailerURLED->set_text(sPath); } } diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx index 01fc840ae473..8c0060fcdd01 100644 --- a/cui/source/options/optjava.cxx +++ b/cui/source/options/optjava.cxx @@ -334,18 +334,18 @@ void SvxJavaOptionsPage::LoadJREs() std::unique_ptr pSelectedJava; eErr = jfw_getSelectedJRE( &pSelectedJava ); - if ( JFW_E_NONE == eErr && pSelectedJava ) + if ( !(JFW_E_NONE == eErr && pSelectedJava) ) + return; + + sal_Int32 i = 0; + for (auto const & pCmpInfo: m_parJavaInfo) { - sal_Int32 i = 0; - for (auto const & pCmpInfo: m_parJavaInfo) + if ( jfw_areEqualJavaInfo( pCmpInfo.get(), pSelectedJava.get() ) ) { - if ( jfw_areEqualJavaInfo( pCmpInfo.get(), pSelectedJava.get() ) ) - { - HandleCheckEntry(i); - break; - } - ++i; + HandleCheckEntry(i); + break; } + ++i; } #else (void) this; @@ -626,21 +626,21 @@ IMPL_LINK_NOARG(SvxJavaParameterDlg, ModifyHdl_Impl, weld::Entry&, void) IMPL_LINK_NOARG(SvxJavaParameterDlg, AssignHdl_Impl, weld::Button&, void) { OUString sParam = comphelper::string::strip(m_xParameterEdit->get_text(), ' '); - if (!sParam.isEmpty()) + if (sParam.isEmpty()) + return; + + int nPos = m_xAssignedList->find_text(sParam); + if (nPos == -1) { - int nPos = m_xAssignedList->find_text(sParam); - if (nPos == -1) - { - m_xAssignedList->append_text(sParam); - m_xAssignedList->select(m_xAssignedList->n_children() - 1); - } - else - m_xAssignedList->select(nPos); - m_xParameterEdit->set_text(OUString()); - ModifyHdl_Impl(*m_xParameterEdit); - EnableEditButton(); - EnableRemoveButton(); + m_xAssignedList->append_text(sParam); + m_xAssignedList->select(m_xAssignedList->n_children() - 1); } + else + m_xAssignedList->select(nPos); + m_xParameterEdit->set_text(OUString()); + ModifyHdl_Impl(*m_xParameterEdit); + EnableEditButton(); + EnableRemoveButton(); } IMPL_LINK_NOARG(SvxJavaParameterDlg, EditHdl_Impl, weld::Button&, void) @@ -686,23 +686,23 @@ void SvxJavaParameterDlg::EditParameter() int nPos = m_xAssignedList->get_selected_index(); m_xParameterEdit->set_text(OUString()); - if (nPos != -1) - { - InputDialog aParamEditDlg(m_xDialog.get(), CuiResId(RID_SVXSTR_JAVA_START_PARAM)); - OUString editableClassPath = m_xAssignedList->get_selected_text(); - aParamEditDlg.SetEntryText(editableClassPath); - aParamEditDlg.HideHelpBtn(); + if (nPos == -1) + return; - if (!aParamEditDlg.run()) - return; - OUString editedClassPath = comphelper::string::strip(aParamEditDlg.GetEntryText(), ' '); + InputDialog aParamEditDlg(m_xDialog.get(), CuiResId(RID_SVXSTR_JAVA_START_PARAM)); + OUString editableClassPath = m_xAssignedList->get_selected_text(); + aParamEditDlg.SetEntryText(editableClassPath); + aParamEditDlg.HideHelpBtn(); - if ( !editedClassPath.isEmpty() && editableClassPath != editedClassPath ) - { - m_xAssignedList->remove(nPos); - m_xAssignedList->insert_text(nPos, editedClassPath); - m_xAssignedList->select(nPos); - } + if (!aParamEditDlg.run()) + return; + OUString editedClassPath = comphelper::string::strip(aParamEditDlg.GetEntryText(), ' '); + + if ( !editedClassPath.isEmpty() && editableClassPath != editedClassPath ) + { + m_xAssignedList->remove(nPos); + m_xAssignedList->insert_text(nPos, editedClassPath); + m_xAssignedList->select(nPos); } } diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx index 738a6986cd6e..c139060bc00c 100644 --- a/cui/source/options/optlingu.cxx +++ b/cui/source/options/optlingu.cxx @@ -748,79 +748,79 @@ void SvxLinguData_Impl::Reconfigure( const OUString &rDisplayName, bool bEnable } } DBG_ASSERT( pInfo, "DisplayName entry not found" ); - if (pInfo) - { - pInfo->bConfigured = bEnable; + if (!pInfo) + return; - Sequence< Locale > aLocales; - const Locale *pLocale = nullptr; - sal_Int32 nLocales = 0; - sal_Int32 i; + pInfo->bConfigured = bEnable; - // update configured spellchecker entries - if (pInfo->xSpell.is()) - { - aLocales = pInfo->xSpell->getLocales(); - pLocale = aLocales.getConstArray(); - nLocales = aLocales.getLength(); - for (i = 0; i < nLocales; ++i) - { - LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); - if (!aCfgSpellTable.count( nLang ) && bEnable) - aCfgSpellTable[ nLang ] = Sequence< OUString >(); - if (aCfgSpellTable.count( nLang )) - AddRemove( aCfgSpellTable[ nLang ], pInfo->sSpellImplName, bEnable ); - } - } + Sequence< Locale > aLocales; + const Locale *pLocale = nullptr; + sal_Int32 nLocales = 0; + sal_Int32 i; - // update configured grammar checker entries - if (pInfo->xGrammar.is()) + // update configured spellchecker entries + if (pInfo->xSpell.is()) + { + aLocales = pInfo->xSpell->getLocales(); + pLocale = aLocales.getConstArray(); + nLocales = aLocales.getLength(); + for (i = 0; i < nLocales; ++i) { - aLocales = pInfo->xGrammar->getLocales(); - pLocale = aLocales.getConstArray(); - nLocales = aLocales.getLength(); - for (i = 0; i < nLocales; ++i) - { - LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); - if (!aCfgGrammarTable.count( nLang ) && bEnable) - aCfgGrammarTable[ nLang ] = Sequence< OUString >(); - if (aCfgGrammarTable.count( nLang )) - AddRemove( aCfgGrammarTable[ nLang ], pInfo->sGrammarImplName, bEnable ); - } + LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); + if (!aCfgSpellTable.count( nLang ) && bEnable) + aCfgSpellTable[ nLang ] = Sequence< OUString >(); + if (aCfgSpellTable.count( nLang )) + AddRemove( aCfgSpellTable[ nLang ], pInfo->sSpellImplName, bEnable ); } + } - // update configured hyphenator entries - if (pInfo->xHyph.is()) + // update configured grammar checker entries + if (pInfo->xGrammar.is()) + { + aLocales = pInfo->xGrammar->getLocales(); + pLocale = aLocales.getConstArray(); + nLocales = aLocales.getLength(); + for (i = 0; i < nLocales; ++i) { - aLocales = pInfo->xHyph->getLocales(); - pLocale = aLocales.getConstArray(); - nLocales = aLocales.getLength(); - for (i = 0; i < nLocales; ++i) - { - LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); - if (!aCfgHyphTable.count( nLang ) && bEnable) - aCfgHyphTable[ nLang ] = Sequence< OUString >(); - if (aCfgHyphTable.count( nLang )) - AddRemove( aCfgHyphTable[ nLang ], pInfo->sHyphImplName, bEnable ); - } + LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); + if (!aCfgGrammarTable.count( nLang ) && bEnable) + aCfgGrammarTable[ nLang ] = Sequence< OUString >(); + if (aCfgGrammarTable.count( nLang )) + AddRemove( aCfgGrammarTable[ nLang ], pInfo->sGrammarImplName, bEnable ); } + } - // update configured spellchecker entries - if (pInfo->xThes.is()) + // update configured hyphenator entries + if (pInfo->xHyph.is()) + { + aLocales = pInfo->xHyph->getLocales(); + pLocale = aLocales.getConstArray(); + nLocales = aLocales.getLength(); + for (i = 0; i < nLocales; ++i) { - aLocales = pInfo->xThes->getLocales(); - pLocale = aLocales.getConstArray(); - nLocales = aLocales.getLength(); - for (i = 0; i < nLocales; ++i) - { - LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); - if (!aCfgThesTable.count( nLang ) && bEnable) - aCfgThesTable[ nLang ] = Sequence< OUString >(); - if (aCfgThesTable.count( nLang )) - AddRemove( aCfgThesTable[ nLang ], pInfo->sThesImplName, bEnable ); - } + LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); + if (!aCfgHyphTable.count( nLang ) && bEnable) + aCfgHyphTable[ nLang ] = Sequence< OUString >(); + if (aCfgHyphTable.count( nLang )) + AddRemove( aCfgHyphTable[ nLang ], pInfo->sHyphImplName, bEnable ); } } + + // update configured spellchecker entries + if (!pInfo->xThes.is()) + return; + + aLocales = pInfo->xThes->getLocales(); + pLocale = aLocales.getConstArray(); + nLocales = aLocales.getLength(); + for (i = 0; i < nLocales; ++i) + { + LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] ); + if (!aCfgThesTable.count( nLang ) && bEnable) + aCfgThesTable[ nLang ] = Sequence< OUString >(); + if (aCfgThesTable.count( nLang )) + AddRemove( aCfgThesTable[ nLang ], pInfo->sThesImplName, bEnable ); + } } @@ -1125,28 +1125,28 @@ void SvxLinguTabPage::UpdateDicBox_Impl() void SvxLinguTabPage::UpdateModulesBox_Impl() { - if (pLinguData) - { - const ServiceInfoArr &rAllDispSrvcArr = pLinguData->GetDisplayServiceArray(); - const sal_uInt32 nDispSrvcCount = pLinguData->GetDisplayServiceCount(); + if (!pLinguData) + return; - m_xLinguModulesCLB->clear(); + const ServiceInfoArr &rAllDispSrvcArr = pLinguData->GetDisplayServiceArray(); + const sal_uInt32 nDispSrvcCount = pLinguData->GetDisplayServiceCount(); - for (sal_uInt32 i = 0; i < nDispSrvcCount; ++i) - { - const ServiceInfo_Impl &rInfo = rAllDispSrvcArr[i]; - m_xLinguModulesCLB->append(); - m_xLinguModulesCLB->set_id(i, OUString::number(reinterpret_cast(&rInfo))); - m_xLinguModulesCLB->set_toggle(i, rInfo.bConfigured ? TRISTATE_TRUE : TRISTATE_FALSE, 0); - m_xLinguModulesCLB->set_text(i, rInfo.sDisplayName, 1); - } - if (nDispSrvcCount) - { - m_xLinguModulesCLB->select(0); - SelectHdl_Impl(*m_xLinguModulesCLB); - } - m_xLinguModulesEditPB->set_sensitive( nDispSrvcCount > 0 ); + m_xLinguModulesCLB->clear(); + + for (sal_uInt32 i = 0; i < nDispSrvcCount; ++i) + { + const ServiceInfo_Impl &rInfo = rAllDispSrvcArr[i]; + m_xLinguModulesCLB->append(); + m_xLinguModulesCLB->set_id(i, OUString::number(reinterpret_cast(&rInfo))); + m_xLinguModulesCLB->set_toggle(i, rInfo.bConfigured ? TRISTATE_TRUE : TRISTATE_FALSE, 0); + m_xLinguModulesCLB->set_text(i, rInfo.sDisplayName, 1); } + if (nDispSrvcCount) + { + m_xLinguModulesCLB->select(0); + SelectHdl_Impl(*m_xLinguModulesCLB); + } + m_xLinguModulesEditPB->set_sensitive( nDispSrvcCount > 0 ); } void SvxLinguTabPage::Reset( const SfxItemSet* rSet ) @@ -1606,42 +1606,42 @@ SvxEditModulesDlg::~SvxEditModulesDlg() IMPL_LINK( SvxEditModulesDlg, SelectHdl_Impl, weld::TreeView&, rBox, void ) { int nCurPos = rBox.get_selected_index(); - if (nCurPos != -1) + if (nCurPos == -1) + return; + + bool bDisableUp = true; + bool bDisableDown = true; + ModuleUserData_Impl* pData = reinterpret_cast(rBox.get_id(nCurPos).toInt64()); + if (!pData->IsParent() && pData->GetType() != TYPE_HYPH) { - bool bDisableUp = true; - bool bDisableDown = true; - ModuleUserData_Impl* pData = reinterpret_cast(rBox.get_id(nCurPos).toInt64()); - if (!pData->IsParent() && pData->GetType() != TYPE_HYPH) + if (nCurPos < rBox.n_children() - 1) { - if (nCurPos < rBox.n_children() - 1) - { - bDisableDown = reinterpret_cast(rBox.get_id(nCurPos + 1).toInt64())->IsParent(); - } - if (nCurPos > 1) - { - bDisableUp = reinterpret_cast(rBox.get_id(nCurPos - 1).toInt64())->IsParent(); - } + bDisableDown = reinterpret_cast(rBox.get_id(nCurPos + 1).toInt64())->IsParent(); + } + if (nCurPos > 1) + { + bDisableUp = reinterpret_cast(rBox.get_id(nCurPos - 1).toInt64())->IsParent(); } - m_xPrioUpPB->set_sensitive(!bDisableUp); - m_xPrioDownPB->set_sensitive(!bDisableDown); } + m_xPrioUpPB->set_sensitive(!bDisableUp); + m_xPrioDownPB->set_sensitive(!bDisableDown); } IMPL_LINK( SvxEditModulesDlg, BoxCheckButtonHdl_Impl, const row_col&, rRowCol, void ) { auto nPos = rRowCol.first; ModuleUserData_Impl* pData = reinterpret_cast(m_xModulesCLB->get_id(nPos).toInt64()); - if (!pData->IsParent() && pData->GetType() == TYPE_HYPH) + if (!(!pData->IsParent() && pData->GetType() == TYPE_HYPH)) + return; + + // make hyphenator checkboxes function as radio-buttons + // (at most one box may be checked) + for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i) { - // make hyphenator checkboxes function as radio-buttons - // (at most one box may be checked) - for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i) + pData = reinterpret_cast(m_xModulesCLB->get_id(i).toInt64()); + if (!pData->IsParent() && pData->GetType() == TYPE_HYPH && i != nPos) { - pData = reinterpret_cast(m_xModulesCLB->get_id(i).toInt64()); - if (!pData->IsParent() && pData->GetType() == TYPE_HYPH && i != nPos) - { - m_xModulesCLB->set_toggle(i, TRISTATE_FALSE, 0); - } + m_xModulesCLB->set_toggle(i, TRISTATE_FALSE, 0); } } } @@ -1932,27 +1932,27 @@ IMPL_LINK( SvxEditModulesDlg, UpDownHdl_Impl, weld::Button&, rBtn, void ) { bool bUp = m_xPrioUpPB.get() == &rBtn; int nCurPos = m_xModulesCLB->get_selected_index(); - if (nCurPos != -1) - { - m_xModulesCLB->freeze(); + if (nCurPos == -1) + return; - OUString sId(m_xModulesCLB->get_id(nCurPos)); - OUString sStr(m_xModulesCLB->get_text(nCurPos)); - bool bIsChecked = m_xModulesCLB->get_toggle(nCurPos, nCurPos); + m_xModulesCLB->freeze(); - m_xModulesCLB->remove(nCurPos); + OUString sId(m_xModulesCLB->get_id(nCurPos)); + OUString sStr(m_xModulesCLB->get_text(nCurPos)); + bool bIsChecked = m_xModulesCLB->get_toggle(nCurPos, nCurPos); - int nDestPos = bUp ? nCurPos - 1 : nCurPos + 1; + m_xModulesCLB->remove(nCurPos); - m_xModulesCLB->insert_text(nDestPos, sStr); - m_xModulesCLB->set_id(nDestPos, sId); - m_xModulesCLB->set_toggle(nDestPos, bIsChecked ? TRISTATE_TRUE : TRISTATE_FALSE, 0); + int nDestPos = bUp ? nCurPos - 1 : nCurPos + 1; - m_xModulesCLB->thaw(); + m_xModulesCLB->insert_text(nDestPos, sStr); + m_xModulesCLB->set_id(nDestPos, sId); + m_xModulesCLB->set_toggle(nDestPos, bIsChecked ? TRISTATE_TRUE : TRISTATE_FALSE, 0); - m_xModulesCLB->select(nDestPos); - SelectHdl_Impl(*m_xModulesCLB); - } + m_xModulesCLB->thaw(); + + m_xModulesCLB->select(nDestPos); + SelectHdl_Impl(*m_xModulesCLB); } IMPL_LINK_NOARG(SvxEditModulesDlg, ClickHdl_Impl, weld::Button&, void) diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index 4d0bdd08bec1..809bab6b4e86 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -433,21 +433,21 @@ void SvxPathTabPage::ChangeCurrentEntry( const OUString& _rFolder ) !sNewPathStr.equalsIgnoreAsciiCase( sWritable ); #endif - if ( bChanged ) + if ( !bChanged ) + return; + + m_xPathBox->set_text(nEntry, Convert_Impl(sNewPathStr), 1); + pPathImpl->eState = SfxItemState::SET; + pPathImpl->sWritablePath = sNewPathStr; + if ( SvtPathOptions::PATH_WORK == pPathImpl->nRealId ) { - m_xPathBox->set_text(nEntry, Convert_Impl(sNewPathStr), 1); - pPathImpl->eState = SfxItemState::SET; - pPathImpl->sWritablePath = sNewPathStr; - if ( SvtPathOptions::PATH_WORK == pPathImpl->nRealId ) - { - // Remove view options entry so the new work path - // will be used for the next open dialog. - SvtViewOptions aDlgOpt( EViewType::Dialog, IODLG_CONFIGNAME ); - aDlgOpt.Delete(); - // Reset also last used dir in the sfx application instance - SfxApplication *pSfxApp = SfxGetpApp(); - pSfxApp->ResetLastDir(); - } + // Remove view options entry so the new work path + // will be used for the next open dialog. + SvtViewOptions aDlgOpt( EViewType::Dialog, IODLG_CONFIGNAME ); + aDlgOpt.Delete(); + // Reset also last used dir in the sfx application instance + SfxApplication *pSfxApp = SfxGetpApp(); + pSfxApp->ResetLastDir(); } } diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx index 72f736ce406b..c165a3f9478b 100644 --- a/cui/source/options/optsave.cxx +++ b/cui/source/options/optsave.cxx @@ -466,20 +466,20 @@ void SvxSaveTabPage::Reset( const SfxItemSet* ) IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Button&, rBox, void) { - if (&rBox == m_xAutoSaveCB.get()) + if (&rBox != m_xAutoSaveCB.get()) + return; + + if (m_xAutoSaveCB->get_active()) { - if (m_xAutoSaveCB->get_active()) - { - m_xAutoSaveEdit->set_sensitive(true); - m_xMinuteFT->set_sensitive(true); - m_xUserAutoSaveCB->set_sensitive(true); - } - else - { - m_xAutoSaveEdit->set_sensitive(false); - m_xMinuteFT->set_sensitive(false); - m_xUserAutoSaveCB->set_sensitive(false); - } + m_xAutoSaveEdit->set_sensitive(true); + m_xMinuteFT->set_sensitive(true); + m_xUserAutoSaveCB->set_sensitive(true); + } + else + { + m_xAutoSaveEdit->set_sensitive(false); + m_xMinuteFT->set_sensitive(false); + m_xUserAutoSaveCB->set_sensitive(false); } } diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 59c73e393739..afd797d702e5 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -622,20 +622,20 @@ IMPL_LINK_NOARG(OfaTreeOptionsDialog, ShowPageHdl_Impl, weld::TreeView&, void) IMPL_LINK_NOARG(OfaTreeOptionsDialog, BackHdl_Impl, weld::Button&, void) { - if (xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry)) + if (!(xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry))) + return; + + OptionsPageInfo* pPageInfo = reinterpret_cast(xTreeLB->get_id(*xCurrentPageEntry).toInt64()); + if (pPageInfo->m_xPage) { - OptionsPageInfo* pPageInfo = reinterpret_cast(xTreeLB->get_id(*xCurrentPageEntry).toInt64()); - if (pPageInfo->m_xPage) - { - std::unique_ptr xParent = xTreeLB->make_iterator(xCurrentPageEntry.get()); - xTreeLB->iter_parent(*xParent); - OptionsGroupInfo* pGroupInfo = - reinterpret_cast(xTreeLB->get_id(*xParent).toInt64()); - pPageInfo->m_xPage->Reset( pGroupInfo->m_pInItemSet.get() ); - } - else if ( pPageInfo->m_xExtPage ) - pPageInfo->m_xExtPage->ResetPage(); + std::unique_ptr xParent = xTreeLB->make_iterator(xCurrentPageEntry.get()); + xTreeLB->iter_parent(*xParent); + OptionsGroupInfo* pGroupInfo = + reinterpret_cast(xTreeLB->get_id(*xParent).toInt64()); + pPageInfo->m_xPage->Reset( pGroupInfo->m_pInItemSet.get() ); } + else if ( pPageInfo->m_xExtPage ) + pPageInfo->m_xExtPage->ResetPage(); } void OfaTreeOptionsDialog::ApplyOptions(bool deactivate) @@ -1574,23 +1574,23 @@ void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame ) } // Internet options - if ( !lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) ) - { - setGroupName("Internet", CuiResId(SID_INET_DLG_RES[0].first)); - nGroup = AddGroup(CuiResId(SID_INET_DLG_RES[0].first), nullptr, nullptr, SID_INET_DLG ); + if ( lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) ) + return; - for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_INET_DLG_RES); ++i ) - { - nPageId = static_cast(SID_INET_DLG_RES[i].second); - if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) - continue; + setGroupName("Internet", CuiResId(SID_INET_DLG_RES[0].first)); + nGroup = AddGroup(CuiResId(SID_INET_DLG_RES[0].first), nullptr, nullptr, SID_INET_DLG ); + + for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_INET_DLG_RES); ++i ) + { + nPageId = static_cast(SID_INET_DLG_RES[i].second); + if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) ) + continue; #if defined(_WIN32) - // Disable E-mail tab-page on Windows - if ( nPageId == RID_SVXPAGE_INET_MAIL ) - continue; + // Disable E-mail tab-page on Windows + if ( nPageId == RID_SVXPAGE_INET_MAIL ) + continue; #endif - AddTabPage( nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup ); - } + AddTabPage( nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup ); } } diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 4952e7b8203c..5b623de576ef 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -159,21 +159,21 @@ IMPL_LINK_NOARG(OfaAutoCorrDlg, SelectLanguageHdl, weld::ComboBox&, void) { LanguageType eNewLang = m_xLanguageLB->get_active_id(); // save old settings and fill anew - if(eNewLang != eLastDialogLanguage) + if(eNewLang == eLastDialogLanguage) + return; + + OString sPageId = GetCurPageId(); + if (sPageId == "replace") { - OString sPageId = GetCurPageId(); - if (sPageId == "replace") - { - OfaAutocorrReplacePage* pPage = static_cast(GetTabPage(sPageId)); - assert(pPage); - pPage->SetLanguage(eNewLang); - } - else if (sPageId == "exceptions") - { - OfaAutocorrExceptPage* pPage = static_cast(GetTabPage(sPageId)); - assert(pPage); - pPage->SetLanguage(eNewLang); - } + OfaAutocorrReplacePage* pPage = static_cast(GetTabPage(sPageId)); + assert(pPage); + pPage->SetLanguage(eNewLang); + } + else if (sPageId == "exceptions") + { + OfaAutocorrExceptPage* pPage = static_cast(GetTabPage(sPageId)); + assert(pPage); + pPage->SetLanguage(eNewLang); } } @@ -1791,28 +1791,28 @@ IMPL_LINK(OfaQuoteTabPage, QuoteHdl, weld::Button&, rBtn, void) } aMap.SetChar( cDlg ); aMap.DisableFontSelection(); - if (aMap.run() == RET_OK) + if (aMap.run() != RET_OK) + return; + + sal_UCS4 cNewChar = aMap.GetChar(); + switch( nMode ) { - sal_UCS4 cNewChar = aMap.GetChar(); - switch( nMode ) - { - case SGL_START: - cSglStartQuote = cNewChar; - m_xSglStartExFT->set_label(ChangeStringExt_Impl(cNewChar)); - break; - case SGL_END: - cSglEndQuote = cNewChar; - m_xSglEndExFT->set_label(ChangeStringExt_Impl(cNewChar)); - break; - case DBL_START: - cStartQuote = cNewChar; - m_xDblStartExFT->set_label(ChangeStringExt_Impl(cNewChar)); - break; - case DBL_END: - cEndQuote = cNewChar; - m_xDblEndExFT->set_label(ChangeStringExt_Impl(cNewChar)); - break; - } + case SGL_START: + cSglStartQuote = cNewChar; + m_xSglStartExFT->set_label(ChangeStringExt_Impl(cNewChar)); + break; + case SGL_END: + cSglEndQuote = cNewChar; + m_xSglEndExFT->set_label(ChangeStringExt_Impl(cNewChar)); + break; + case DBL_START: + cStartQuote = cNewChar; + m_xDblStartExFT->set_label(ChangeStringExt_Impl(cNewChar)); + break; + case DBL_END: + cEndQuote = cNewChar; + m_xDblEndExFT->set_label(ChangeStringExt_Impl(cNewChar)); + break; } } @@ -2065,26 +2065,26 @@ IMPL_LINK(OfaAutoCompleteTabPage, CheckHdl, weld::ToggleButton&, rBox, void) void OfaAutoCompleteTabPage::CopyToClipboard() const { auto rows = m_xLBEntries->get_selected_rows(); - if (m_pAutoCompleteList && !rows.empty()) - { - rtl::Reference pCntnr = new TransferDataContainer; + if (!(m_pAutoCompleteList && !rows.empty())) + return; - OStringBuffer sData; + rtl::Reference pCntnr = new TransferDataContainer; - rtl_TextEncoding nEncode = osl_getThreadTextEncoding(); + OStringBuffer sData; - for (auto a : rows) - { - sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode)); + rtl_TextEncoding nEncode = osl_getThreadTextEncoding(); + + for (auto a : rows) + { + sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode)); #if defined(_WIN32) - sData.append("\015\012"); + sData.append("\015\012"); #else - sData.append("\012"); + sData.append("\012"); #endif - } - pCntnr->CopyByteString( SotClipboardFormatId::STRING, sData.makeStringAndClear() ); - pCntnr->CopyToClipboard(GetSystemClipboard()); } + pCntnr->CopyByteString( SotClipboardFormatId::STRING, sData.makeStringAndClear() ); + pCntnr->CopyToClipboard(GetSystemClipboard()); } IMPL_LINK(OfaAutoCompleteTabPage, KeyReleaseHdl, const KeyEvent&, rEvent, bool) diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx index e72ddcb4854b..123481198e17 100644 --- a/cui/source/tabpages/backgrnd.cxx +++ b/cui/source/tabpages/backgrnd.cxx @@ -290,52 +290,52 @@ IMPL_LINK(SvxBkgTabPage, TblDestinationHdl_Impl, weld::ComboBox&, rBox, void) } sal_Int32 nSelPos = rBox.get_active(); - if (m_nActPos != nSelPos) + if (m_nActPos == nSelPos) + return; + + m_nActPos = nSelPos; + + // fill local item set with XATTR_FILL created from SvxBushItem for table destination slot Which + sal_uInt16 nWhich = maSet.GetPool()->GetWhich(lcl_GetTableDestSlot(nSelPos)); + if (SfxItemState::SET == maSet.GetItemState(nWhich)) + { + SvxBrushItem aBrushItem(static_cast(maSet.Get(nWhich))); + setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet); + } + else { - m_nActPos = nSelPos; + SelectFillType(*m_xBtnNone, &maSet); + return; + } - // fill local item set with XATTR_FILL created from SvxBushItem for table destination slot Which - sal_uInt16 nWhich = maSet.GetPool()->GetWhich(lcl_GetTableDestSlot(nSelPos)); - if (SfxItemState::SET == maSet.GetItemState(nWhich)) - { - SvxBrushItem aBrushItem(static_cast(maSet.Get(nWhich))); - setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet); - } - else + // show tab page + drawing::FillStyle eXFS = drawing::FillStyle_NONE; + if (maSet.GetItemState(XATTR_FILLSTYLE) != SfxItemState::DONTCARE) + { + XFillStyleItem aFillStyleItem(static_cast(maSet.Get(GetWhich( XATTR_FILLSTYLE)))); + eXFS = aFillStyleItem.GetValue(); + } + switch(eXFS) + { + default: + case drawing::FillStyle_NONE: { SelectFillType(*m_xBtnNone, &maSet); - return; + break; } - - // show tab page - drawing::FillStyle eXFS = drawing::FillStyle_NONE; - if (maSet.GetItemState(XATTR_FILLSTYLE) != SfxItemState::DONTCARE) + case drawing::FillStyle_SOLID: { - XFillStyleItem aFillStyleItem(static_cast(maSet.Get(GetWhich( XATTR_FILLSTYLE)))); - eXFS = aFillStyleItem.GetValue(); + SelectFillType(*m_xBtnColor, &maSet); + // color tab page Active and New preview controls are same after SelectFillType + // hack to restore color tab page Active preview + setSvxBrushItemAsFillAttributesToTargetSet(static_cast(m_pResetSet->Get(nWhich)), *m_pResetSet); + static_cast(GetFillTabPage())->SetCtlPreviewOld(*m_pResetSet); + break; } - switch(eXFS) + case drawing::FillStyle_BITMAP: { - default: - case drawing::FillStyle_NONE: - { - SelectFillType(*m_xBtnNone, &maSet); - break; - } - case drawing::FillStyle_SOLID: - { - SelectFillType(*m_xBtnColor, &maSet); - // color tab page Active and New preview controls are same after SelectFillType - // hack to restore color tab page Active preview - setSvxBrushItemAsFillAttributesToTargetSet(static_cast(m_pResetSet->Get(nWhich)), *m_pResetSet); - static_cast(GetFillTabPage())->SetCtlPreviewOld(*m_pResetSet); - break; - } - case drawing::FillStyle_BITMAP: - { - SelectFillType(*m_xBtnBitmap, &maSet); - break; - } + SelectFillType(*m_xBtnBitmap, &maSet); + break; } } } diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index d8ab1aa1e9d1..68eca4fb4d48 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -535,19 +535,19 @@ void SvxCharNamePage::FillStyleBox_Impl(const weld::Widget& rNameBox) pStyleBox->Fill(sFontName, pFontList); - if ( m_pImpl->m_bInSearchMode ) - { - // additional entries for the search: - // "not bold" and "not italic" - OUString aEntry = m_pImpl->m_aNoStyleText; - const char sS[] = "%1"; - aEntry = aEntry.replaceFirst( sS, pFontList->GetBoldStr() ); - m_pImpl->m_nExtraEntryPos = pStyleBox->get_count(); - pStyleBox->append_text( aEntry ); - aEntry = m_pImpl->m_aNoStyleText; - aEntry = aEntry.replaceFirst( sS, pFontList->GetItalicStr() ); - pStyleBox->append_text(aEntry); - } + if ( !m_pImpl->m_bInSearchMode ) + return; + + // additional entries for the search: + // "not bold" and "not italic" + OUString aEntry = m_pImpl->m_aNoStyleText; + const char sS[] = "%1"; + aEntry = aEntry.replaceFirst( sS, pFontList->GetBoldStr() ); + m_pImpl->m_nExtraEntryPos = pStyleBox->get_count(); + pStyleBox->append_text( aEntry ); + aEntry = m_pImpl->m_aNoStyleText; + aEntry = aEntry.replaceFirst( sS, pFontList->GetItalicStr() ); + pStyleBox->append_text(aEntry); } void SvxCharNamePage::FillSizeBox_Impl(const weld::Widget& rNameBox) @@ -2439,20 +2439,20 @@ void SvxCharEffectsPage::PageCreated(const SfxAllItemSet& aSet) if (pDisableCtlItem) DisableControls(pDisableCtlItem->GetValue()); - if (pFlagItem) - { - sal_uInt32 nFlags=pFlagItem->GetValue(); - if ( ( nFlags & SVX_ENABLE_FLASH ) == SVX_ENABLE_FLASH ) - m_xBlinkingBtn->show(); - if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) - // the writer uses SID_ATTR_BRUSH as font background - m_bPreviewBackgroundToCharacter = true; - if ((nFlags & SVX_ENABLE_CHAR_TRANSPARENCY) != SVX_ENABLE_CHAR_TRANSPARENCY) - { - // Only show these in case client code explicitly wants this. - m_xFontTransparencyFT->hide(); - m_xFontTransparencyMtr->hide(); - } + if (!pFlagItem) + return; + + sal_uInt32 nFlags=pFlagItem->GetValue(); + if ( ( nFlags & SVX_ENABLE_FLASH ) == SVX_ENABLE_FLASH ) + m_xBlinkingBtn->show(); + if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER ) + // the writer uses SID_ATTR_BRUSH as font background + m_bPreviewBackgroundToCharacter = true; + if ((nFlags & SVX_ENABLE_CHAR_TRANSPARENCY) != SVX_ENABLE_CHAR_TRANSPARENCY) + { + // Only show these in case client code explicitly wants this. + m_xFontTransparencyFT->hide(); + m_xFontTransparencyMtr->hide(); } } diff --git a/cui/source/tabpages/labdlg.cxx b/cui/source/tabpages/labdlg.cxx index cda75610365c..a1f916c70a8b 100644 --- a/cui/source/tabpages/labdlg.cxx +++ b/cui/source/tabpages/labdlg.cxx @@ -410,18 +410,18 @@ IMPL_LINK(SvxCaptionTabPage, PositionSelectHdl_Impl, weld::ComboBox&, rListBox, IMPL_LINK( SvxCaptionTabPage, LineOptHdl_Impl, weld::ToggleButton&, rButton, void ) { - if (&rButton == m_xCB_OPTIMAL.get()) + if (&rButton != m_xCB_OPTIMAL.get()) + return; + + if (m_xCB_OPTIMAL->get_active() || !m_xCB_OPTIMAL->get_sensitive()) { - if (m_xCB_OPTIMAL->get_active() || !m_xCB_OPTIMAL->get_sensitive()) - { - m_xFT_LENGTHFT->set_sensitive(false); - m_xMF_LENGTH->set_sensitive(false); - } - else - { - m_xFT_LENGTHFT->set_sensitive(true); - m_xMF_LENGTH->set_sensitive(true); - } + m_xFT_LENGTHFT->set_sensitive(false); + m_xMF_LENGTH->set_sensitive(false); + } + else + { + m_xFT_LENGTHFT->set_sensitive(true); + m_xMF_LENGTH->set_sensitive(true); } } diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx index 97ba2da968ea..deb9ee5a7d10 100644 --- a/cui/source/tabpages/numfmt.cxx +++ b/cui/source/tabpages/numfmt.cxx @@ -1534,52 +1534,52 @@ IMPL_LINK(SvxNumberFormatTabPage, OptEditHdl_Impl, weld::SpinButton&, rEdit, voi void SvxNumberFormatTabPage::OptHdl_Impl(const weld::Widget* pOptCtrl) { - if ( pOptCtrl == m_xEdLeadZeroes.get() + if ( !(pOptCtrl == m_xEdLeadZeroes.get() || pOptCtrl == m_xEdDecimals.get() || pOptCtrl == m_xEdDenominator.get() || pOptCtrl == m_xBtnNegRed.get() || pOptCtrl == m_xBtnThousand.get() - || pOptCtrl == m_xBtnEngineering.get()) + || pOptCtrl == m_xBtnEngineering.get())) + return; + + OUString aFormat; + bool bThousand = ( m_xBtnThousand->get_visible() && m_xBtnThousand->get_sensitive() && m_xBtnThousand->get_active() ) + || ( m_xBtnEngineering->get_visible() && m_xBtnEngineering->get_sensitive() && m_xBtnEngineering->get_active() ); + bool bNegRed = m_xBtnNegRed->get_sensitive() && m_xBtnNegRed->get_active(); + sal_uInt16 nPrecision = (m_xEdDecimals->get_sensitive() && m_xEdDecimals->get_visible()) + ? static_cast(m_xEdDecimals->get_value()) + : ( (m_xEdDenominator->get_sensitive() && m_xEdDenominator->get_visible()) + ? static_cast(m_xEdDenominator->get_value()) + : sal_uInt16(0) ); + sal_uInt16 nLeadZeroes = (m_xEdLeadZeroes->get_sensitive()) + ? static_cast(m_xEdLeadZeroes->get_value()) + : sal_uInt16(0); + if ( pNumFmtShell->GetStandardName() == m_xEdFormat->get_text() ) { - OUString aFormat; - bool bThousand = ( m_xBtnThousand->get_visible() && m_xBtnThousand->get_sensitive() && m_xBtnThousand->get_active() ) - || ( m_xBtnEngineering->get_visible() && m_xBtnEngineering->get_sensitive() && m_xBtnEngineering->get_active() ); - bool bNegRed = m_xBtnNegRed->get_sensitive() && m_xBtnNegRed->get_active(); - sal_uInt16 nPrecision = (m_xEdDecimals->get_sensitive() && m_xEdDecimals->get_visible()) - ? static_cast(m_xEdDecimals->get_value()) - : ( (m_xEdDenominator->get_sensitive() && m_xEdDenominator->get_visible()) - ? static_cast(m_xEdDenominator->get_value()) - : sal_uInt16(0) ); - sal_uInt16 nLeadZeroes = (m_xEdLeadZeroes->get_sensitive()) - ? static_cast(m_xEdLeadZeroes->get_value()) - : sal_uInt16(0); - if ( pNumFmtShell->GetStandardName() == m_xEdFormat->get_text() ) - { - m_xEdDecimals->set_value(nPrecision); - } + m_xEdDecimals->set_value(nPrecision); + } - pNumFmtShell->MakeFormat( aFormat, - bThousand, bNegRed, - nPrecision, nLeadZeroes, - static_cast(m_xLbFormat->get_selected_index()) ); + pNumFmtShell->MakeFormat( aFormat, + bThousand, bNegRed, + nPrecision, nLeadZeroes, + static_cast(m_xLbFormat->get_selected_index()) ); - m_xEdFormat->set_text( aFormat ); - MakePreviewText( aFormat ); + m_xEdFormat->set_text( aFormat ); + MakePreviewText( aFormat ); - if ( pNumFmtShell->FindEntry( aFormat ) ) - { - m_xIbAdd->set_sensitive(false ); - bool bUserDef=pNumFmtShell->IsUserDefined( aFormat ); - m_xIbRemove->set_sensitive(bUserDef); - m_xIbInfo->set_sensitive(bUserDef); - EditHdl_Impl(m_xEdFormat.get()); + if ( pNumFmtShell->FindEntry( aFormat ) ) + { + m_xIbAdd->set_sensitive(false ); + bool bUserDef=pNumFmtShell->IsUserDefined( aFormat ); + m_xIbRemove->set_sensitive(bUserDef); + m_xIbInfo->set_sensitive(bUserDef); + EditHdl_Impl(m_xEdFormat.get()); - } - else - { - EditHdl_Impl( nullptr ); - m_xLbFormat->select(-1); - } + } + else + { + EditHdl_Impl( nullptr ); + m_xLbFormat->select(-1); } } diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index f80ee6f1481a..c2f5eae08b20 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -172,31 +172,31 @@ SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(weld::Container* pPage, weld::D m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage, DoubleClickHdl_Impl)); Reference xDefNum = SvxNumOptionsTabPageHelper::GetNumberingProvider(); - if(xDefNum.is()) + if(!xDefNum.is()) + return; + + Sequence< Sequence< PropertyValue > > aNumberings; + const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale(); + try { - Sequence< Sequence< PropertyValue > > aNumberings; - const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale(); - try - { - aNumberings = - xDefNum->getDefaultContinuousNumberingLevels( rLocale ); + aNumberings = + xDefNum->getDefaultContinuousNumberingLevels( rLocale ); - sal_Int32 nLength = std::min(aNumberings.getLength(), NUM_VALUSET_COUNT); + sal_Int32 nLength = std::min(aNumberings.getLength(), NUM_VALUSET_COUNT); - const Sequence* pValuesArr = aNumberings.getConstArray(); - for(sal_Int32 i = 0; i < nLength; i++) - { - SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(pValuesArr[i]); - aNumSettingsArr.push_back(std::unique_ptr(pNew)); - } - } - catch(const Exception&) + const Sequence* pValuesArr = aNumberings.getConstArray(); + for(sal_Int32 i = 0; i < nLength; i++) { + SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(pValuesArr[i]); + aNumSettingsArr.push_back(std::unique_ptr(pNew)); } - Reference xFormat(xDefNum, UNO_QUERY); - m_xExamplesVS->SetNumberingSettings(aNumberings, xFormat, rLocale); } + catch(const Exception&) + { + } + Reference xFormat(xDefNum, UNO_QUERY); + m_xExamplesVS->SetNumberingSettings(aNumberings, xFormat, rLocale); } SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage() @@ -292,40 +292,40 @@ void SvxSingleNumPickTabPage::Reset( const SfxItemSet* rSet ) IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void) { - if(pActNum) - { - bPreset = false; - bModified = true; - sal_uInt16 nIdx = m_xExamplesVS->GetSelectedItemId() - 1; - DBG_ASSERT(aNumSettingsArr.size() > nIdx, "wrong index"); - if(aNumSettingsArr.size() <= nIdx) - return; - SvxNumSettings_Impl* _pSet = aNumSettingsArr[nIdx].get(); - SvxNumType eNewType = _pSet->nNumberType; - const sal_Unicode cLocalPrefix = !_pSet->sPrefix.isEmpty() ? _pSet->sPrefix[0] : 0; - const sal_Unicode cLocalSuffix = !_pSet->sSuffix.isEmpty() ? _pSet->sSuffix[0] : 0; + if(!pActNum) + return; - sal_uInt16 nMask = 1; - for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + bPreset = false; + bModified = true; + sal_uInt16 nIdx = m_xExamplesVS->GetSelectedItemId() - 1; + DBG_ASSERT(aNumSettingsArr.size() > nIdx, "wrong index"); + if(aNumSettingsArr.size() <= nIdx) + return; + SvxNumSettings_Impl* _pSet = aNumSettingsArr[nIdx].get(); + SvxNumType eNewType = _pSet->nNumberType; + const sal_Unicode cLocalPrefix = !_pSet->sPrefix.isEmpty() ? _pSet->sPrefix[0] : 0; + const sal_Unicode cLocalSuffix = !_pSet->sSuffix.isEmpty() ? _pSet->sSuffix[0] : 0; + + sal_uInt16 nMask = 1; + for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + { + if(nActNumLvl & nMask) { - if(nActNumLvl & nMask) - { - SvxNumberFormat aFmt(pActNum->GetLevel(i)); - aFmt.SetNumberingType(eNewType); - if(cLocalPrefix == ' ') - aFmt.SetPrefix( "" ); - else - aFmt.SetPrefix(_pSet->sPrefix); - if(cLocalSuffix == ' ') - aFmt.SetSuffix( "" ); - else - aFmt.SetSuffix(_pSet->sSuffix); - aFmt.SetCharFormatName(""); - aFmt.SetBulletRelSize(100); - pActNum->SetLevel(i, aFmt); - } - nMask <<= 1; + SvxNumberFormat aFmt(pActNum->GetLevel(i)); + aFmt.SetNumberingType(eNewType); + if(cLocalPrefix == ' ') + aFmt.SetPrefix( "" ); + else + aFmt.SetPrefix(_pSet->sPrefix); + if(cLocalSuffix == ' ') + aFmt.SetSuffix( "" ); + else + aFmt.SetSuffix(_pSet->sSuffix); + aFmt.SetCharFormatName(""); + aFmt.SetBulletRelSize(100); + pActNum->SetLevel(i, aFmt); } + nMask <<= 1; } } @@ -442,31 +442,31 @@ void SvxBulletPickTabPage::Reset( const SfxItemSet* rSet ) IMPL_LINK_NOARG(SvxBulletPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void) { - if(pActNum) - { - bPreset = false; - bModified = true; - sal_Unicode cChar = aBulletTypes[m_xExamplesVS->GetSelectedItemId() - 1]; - const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont(); + if(!pActNum) + return; - sal_uInt16 nMask = 1; - for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + bPreset = false; + bModified = true; + sal_Unicode cChar = aBulletTypes[m_xExamplesVS->GetSelectedItemId() - 1]; + const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont(); + + sal_uInt16 nMask = 1; + for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + { + if(nActNumLvl & nMask) { - if(nActNumLvl & nMask) - { - SvxNumberFormat aFmt(pActNum->GetLevel(i)); - aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL ); - // #i93908# clear suffix for bullet lists - aFmt.SetPrefix( OUString() ); - aFmt.SetSuffix( OUString() ); - aFmt.SetBulletFont(&rActBulletFont); - aFmt.SetBulletChar(cChar ); - aFmt.SetCharFormatName(sBulletCharFormatName); - aFmt.SetBulletRelSize(45); - pActNum->SetLevel(i, aFmt); - } - nMask <<= 1; + SvxNumberFormat aFmt(pActNum->GetLevel(i)); + aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL ); + // #i93908# clear suffix for bullet lists + aFmt.SetPrefix( OUString() ); + aFmt.SetSuffix( OUString() ); + aFmt.SetBulletFont(&rActBulletFont); + aFmt.SetBulletChar(cChar ); + aFmt.SetCharFormatName(sBulletCharFormatName); + aFmt.SetBulletRelSize(45); + pActNum->SetLevel(i, aFmt); } + nMask <<= 1; } } @@ -501,37 +501,37 @@ SvxNumPickTabPage::SvxNumPickTabPage(weld::Container* pPage, weld::DialogControl m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxNumPickTabPage, DoubleClickHdl_Impl)); Reference xDefNum = SvxNumOptionsTabPageHelper::GetNumberingProvider(); - if(xDefNum.is()) + if(!xDefNum.is()) + return; + + Sequence > aOutlineAccess; + const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale(); + try { - Sequence > aOutlineAccess; - const Locale& rLocale = Application::GetSettings().GetLanguageTag().getLocale(); - try + aOutlineAccess = xDefNum->getDefaultOutlineNumberings( rLocale ); + + for(sal_Int32 nItem = 0; + nItem < aOutlineAccess.getLength() && nItem < NUM_VALUSET_COUNT; + nItem++ ) { - aOutlineAccess = xDefNum->getDefaultOutlineNumberings( rLocale ); + SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ]; - for(sal_Int32 nItem = 0; - nItem < aOutlineAccess.getLength() && nItem < NUM_VALUSET_COUNT; - nItem++ ) + Reference xLevel = aOutlineAccess.getConstArray()[nItem]; + for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++) { - SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[ nItem ]; - - Reference xLevel = aOutlineAccess.getConstArray()[nItem]; - for(sal_Int32 nLevel = 0; nLevel < xLevel->getCount() && nLevel < 5; nLevel++) - { - Any aValueAny = xLevel->getByIndex(nLevel); - Sequence aLevelProps; - aValueAny >>= aLevelProps; - SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(aLevelProps); - rItemArr.push_back( std::unique_ptr(pNew) ); - } + Any aValueAny = xLevel->getByIndex(nLevel); + Sequence aLevelProps; + aValueAny >>= aLevelProps; + SvxNumSettings_Impl* pNew = lcl_CreateNumSettingsPtr(aLevelProps); + rItemArr.push_back( std::unique_ptr(pNew) ); } } - catch(const Exception&) - { - } - Reference xFormat(xDefNum, UNO_QUERY); - m_xExamplesVS->SetOutlineNumberingSettings(aOutlineAccess, xFormat, rLocale); } + catch(const Exception&) + { + } + Reference xFormat(xDefNum, UNO_QUERY); + m_xExamplesVS->SetOutlineNumberingSettings(aOutlineAccess, xFormat, rLocale); } SvxNumPickTabPage::~SvxNumPickTabPage() @@ -627,83 +627,83 @@ void SvxNumPickTabPage::Reset( const SfxItemSet* rSet ) // all levels are changed here IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void) { - if(pActNum) - { - bPreset = false; - bModified = true; + if(!pActNum) + return; - const FontList* pList = nullptr; + bPreset = false; + bModified = true; - SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[m_xExamplesVS->GetSelectedItemId() - 1]; + const FontList* pList = nullptr; - const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont(); - SvxNumSettings_Impl* pLevelSettings = nullptr; - for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) - { - if(rItemArr.size() > i) - pLevelSettings = rItemArr[i].get(); - if(!pLevelSettings) - break; - SvxNumberFormat aFmt(pActNum->GetLevel(i)); - aFmt.SetNumberingType( pLevelSettings->nNumberType ); - sal_uInt16 nUpperLevelOrChar = static_cast(pLevelSettings->nParentNumbering); - if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL) + SvxNumSettingsArr_Impl& rItemArr = aNumSettingsArrays[m_xExamplesVS->GetSelectedItemId() - 1]; + + const vcl::Font& rActBulletFont = lcl_GetDefaultBulletFont(); + SvxNumSettings_Impl* pLevelSettings = nullptr; + for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + { + if(rItemArr.size() > i) + pLevelSettings = rItemArr[i].get(); + if(!pLevelSettings) + break; + SvxNumberFormat aFmt(pActNum->GetLevel(i)); + aFmt.SetNumberingType( pLevelSettings->nNumberType ); + sal_uInt16 nUpperLevelOrChar = static_cast(pLevelSettings->nParentNumbering); + if(aFmt.GetNumberingType() == SVX_NUM_CHAR_SPECIAL) + { + // #i93908# clear suffix for bullet lists + aFmt.SetPrefix(OUString()); + aFmt.SetSuffix(OUString()); + if( !pLevelSettings->sBulletFont.isEmpty() && + pLevelSettings->sBulletFont != rActBulletFont.GetFamilyName()) { - // #i93908# clear suffix for bullet lists - aFmt.SetPrefix(OUString()); - aFmt.SetSuffix(OUString()); - if( !pLevelSettings->sBulletFont.isEmpty() && - pLevelSettings->sBulletFont != rActBulletFont.GetFamilyName()) + //search for the font + if(!pList) { - //search for the font - if(!pList) - { - SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); - const SvxFontListItem* pFontListItem = - static_cast( pCurDocShell - ->GetItem( SID_ATTR_CHAR_FONTLIST )); - pList = pFontListItem ? pFontListItem->GetFontList() : nullptr; - } - if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) ) - { - FontMetric aFontMetric = pList->Get( - pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE); - vcl::Font aFont(aFontMetric); - aFmt.SetBulletFont(&aFont); - } - else - { - //if it cannot be found then create a new one - vcl::Font aCreateFont( pLevelSettings->sBulletFont, - OUString(), Size( 0, 14 ) ); - aCreateFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW ); - aCreateFont.SetFamily( FAMILY_DONTKNOW ); - aCreateFont.SetPitch( PITCH_DONTKNOW ); - aCreateFont.SetWeight( WEIGHT_DONTKNOW ); - aCreateFont.SetTransparent( true ); - aFmt.SetBulletFont( &aCreateFont ); - } + SfxObjectShell* pCurDocShell = SfxObjectShell::Current(); + const SvxFontListItem* pFontListItem = + static_cast( pCurDocShell + ->GetItem( SID_ATTR_CHAR_FONTLIST )); + pList = pFontListItem ? pFontListItem->GetFontList() : nullptr; + } + if(pList && pList->IsAvailable( pLevelSettings->sBulletFont ) ) + { + FontMetric aFontMetric = pList->Get( + pLevelSettings->sBulletFont,WEIGHT_NORMAL, ITALIC_NONE); + vcl::Font aFont(aFontMetric); + aFmt.SetBulletFont(&aFont); } else - aFmt.SetBulletFont( &rActBulletFont ); - - aFmt.SetBulletChar( !pLevelSettings->sBulletChar.isEmpty() - ? pLevelSettings->sBulletChar[0] - : 0 ); - aFmt.SetCharFormatName( sBulletCharFormatName ); - aFmt.SetBulletRelSize(45); + { + //if it cannot be found then create a new one + vcl::Font aCreateFont( pLevelSettings->sBulletFont, + OUString(), Size( 0, 14 ) ); + aCreateFont.SetCharSet( RTL_TEXTENCODING_DONTKNOW ); + aCreateFont.SetFamily( FAMILY_DONTKNOW ); + aCreateFont.SetPitch( PITCH_DONTKNOW ); + aCreateFont.SetWeight( WEIGHT_DONTKNOW ); + aCreateFont.SetTransparent( true ); + aFmt.SetBulletFont( &aCreateFont ); + } } else - { - aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 0)); - aFmt.SetCharFormatName(sNumCharFmtName); - aFmt.SetBulletRelSize(100); - // #i93908# - aFmt.SetPrefix(pLevelSettings->sPrefix); - aFmt.SetSuffix(pLevelSettings->sSuffix); - } - pActNum->SetLevel(i, aFmt); + aFmt.SetBulletFont( &rActBulletFont ); + + aFmt.SetBulletChar( !pLevelSettings->sBulletChar.isEmpty() + ? pLevelSettings->sBulletChar[0] + : 0 ); + aFmt.SetCharFormatName( sBulletCharFormatName ); + aFmt.SetBulletRelSize(45); + } + else + { + aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != nUpperLevelOrChar ? pActNum->GetLevelCount() : 0)); + aFmt.SetCharFormatName(sNumCharFmtName); + aFmt.SetBulletRelSize(100); + // #i93908# + aFmt.SetPrefix(pLevelSettings->sPrefix); + aFmt.SetSuffix(pLevelSettings->sSuffix); } + pActNum->SetLevel(i, aFmt); } } @@ -869,38 +869,38 @@ void SvxBitmapPickTabPage::Reset( const SfxItemSet* rSet ) IMPL_LINK_NOARG(SvxBitmapPickTabPage, NumSelectHdl_Impl, SvtValueSet*, void) { - if(pActNum) - { - bPreset = false; - bModified = true; - sal_uInt16 nIdx = m_xExamplesVS->GetSelectedItemId() - 1; + if(!pActNum) + return; - sal_uInt16 nMask = 1; - for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + bPreset = false; + bModified = true; + sal_uInt16 nIdx = m_xExamplesVS->GetSelectedItemId() - 1; + + sal_uInt16 nMask = 1; + for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + { + if(nActNumLvl & nMask) { - if(nActNumLvl & nMask) - { - SvxNumberFormat aFmt(pActNum->GetLevel(i)); - aFmt.SetNumberingType(SVX_NUM_BITMAP); - aFmt.SetPrefix( "" ); - aFmt.SetSuffix( "" ); - aFmt.SetCharFormatName( "" ); + SvxNumberFormat aFmt(pActNum->GetLevel(i)); + aFmt.SetNumberingType(SVX_NUM_BITMAP); + aFmt.SetPrefix( "" ); + aFmt.SetSuffix( "" ); + aFmt.SetCharFormatName( "" ); - Graphic aGraphic; - if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nIdx, &aGraphic)) - { - Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic); - sal_Int16 eOrient = text::VertOrientation::LINE_CENTER; - aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit)); - SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH ); - aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient ); - } - else if(aGrfNames.size() > nIdx) - aFmt.SetGraphic( aGrfNames[nIdx] ); - pActNum->SetLevel(i, aFmt); + Graphic aGraphic; + if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nIdx, &aGraphic)) + { + Size aSize = SvxNumberFormat::GetGraphicSizeMM100(&aGraphic); + sal_Int16 eOrient = text::VertOrientation::LINE_CENTER; + aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit)); + SvxBrushItem aBrush(aGraphic, GPOS_AREA, SID_ATTR_BRUSH ); + aFmt.SetGraphicBrush( &aBrush, &aSize, &eOrient ); } - nMask <<= 1; + else if(aGrfNames.size() > nIdx) + aFmt.SetGraphic( aGrfNames[nIdx] ); + pActNum->SetLevel(i, aFmt); } + nMask <<= 1; } } @@ -935,76 +935,74 @@ IMPL_LINK_NOARG(SvxBitmapPickTabPage, ClickAddBrowseHdl_Impl, weld::Button&, voi DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); GraphicDescriptor aDescriptor(aURL); - if (aDescriptor.Detect()) - { - uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - uno::Reference xSimpleFileAccess( - ucb::SimpleFileAccess::create( ::comphelper::getComponentContext(xFactory) ) ); - if ( xSimpleFileAccess->exists( aUserImageURL )) - { - xSimpleFileAccess->copy( aUserImageURL, aUserGalleryURL ); - INetURLObject gURL( aUserGalleryURL ); - std::unique_ptr pIn(::utl::UcbStreamHelper::CreateStream( - gURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ )); - if ( pIn ) - { - Graphic aGraphic; - GraphicConverter::Import( *pIn, aGraphic ); - - BitmapEx aBitmap = aGraphic.GetBitmapEx(); - long nPixelX = aBitmap.GetSizePixel().Width(); - long nPixelY = aBitmap.GetSizePixel().Height(); - double ratio = nPixelY/static_cast(nPixelX); - if(nPixelX > 30) - { - nPixelX = 30; - nPixelY = static_cast(nPixelX*ratio); - } - if(nPixelY > 30) - { - nPixelY = 30; - nPixelX = static_cast(nPixelY/ratio); - } + if (!aDescriptor.Detect()) + return; - aBitmap.Scale( Size( nPixelX, nPixelY ), BmpScaleFlag::Fast ); - Graphic aScaledGraphic( aBitmap ); - GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); + uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); + uno::Reference xSimpleFileAccess( + ucb::SimpleFileAccess::create( ::comphelper::getComponentContext(xFactory) ) ); + if ( !xSimpleFileAccess->exists( aUserImageURL )) + return; - Sequence< PropertyValue > aFilterData( 2 ); - aFilterData[ 0 ].Name = "Compression"; - aFilterData[ 0 ].Value <<= sal_Int32(-1) ; - aFilterData[ 1 ].Name = "Quality"; - aFilterData[ 1 ].Value <<= sal_Int32(1); + xSimpleFileAccess->copy( aUserImageURL, aUserGalleryURL ); + INetURLObject gURL( aUserGalleryURL ); + std::unique_ptr pIn(::utl::UcbStreamHelper::CreateStream( + gURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ )); + if ( !pIn ) + return; - sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( gURL.GetFileExtension() ); - rFilter.ExportGraphic( aScaledGraphic, gURL , nFilterFormat, &aFilterData ); - GalleryExplorer::InsertURL( GALLERY_THEME_BULLETS, aUserGalleryURL ); + Graphic aGraphic; + GraphicConverter::Import( *pIn, aGraphic ); - aGrfNames.push_back(aUserGalleryURL); - size_t i = 0; - for (auto & grfName : aGrfNames) - { - m_xExamplesVS->InsertItem( i + 1, i); - INetURLObject aObj(grfName); - if(aObj.GetProtocol() == INetProtocol::File) - grfName = aObj.PathToFileName(); - m_xExamplesVS->SetItemText( i + 1, grfName ); - ++i; - } + BitmapEx aBitmap = aGraphic.GetBitmapEx(); + long nPixelX = aBitmap.GetSizePixel().Width(); + long nPixelY = aBitmap.GetSizePixel().Height(); + double ratio = nPixelY/static_cast(nPixelX); + if(nPixelX > 30) + { + nPixelX = 30; + nPixelY = static_cast(nPixelX*ratio); + } + if(nPixelY > 30) + { + nPixelY = 30; + nPixelX = static_cast(nPixelY/ratio); + } - if(aGrfNames.empty()) - { - m_xErrorText->show(); - } - else - { - m_xExamplesVS->Show(); - m_xExamplesVS->SetFormat(); - } + aBitmap.Scale( Size( nPixelX, nPixelY ), BmpScaleFlag::Fast ); + Graphic aScaledGraphic( aBitmap ); + GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); - } - } + Sequence< PropertyValue > aFilterData( 2 ); + aFilterData[ 0 ].Name = "Compression"; + aFilterData[ 0 ].Value <<= sal_Int32(-1) ; + aFilterData[ 1 ].Name = "Quality"; + aFilterData[ 1 ].Value <<= sal_Int32(1); + + sal_uInt16 nFilterFormat = rFilter.GetExportFormatNumberForShortName( gURL.GetFileExtension() ); + rFilter.ExportGraphic( aScaledGraphic, gURL , nFilterFormat, &aFilterData ); + GalleryExplorer::InsertURL( GALLERY_THEME_BULLETS, aUserGalleryURL ); + + aGrfNames.push_back(aUserGalleryURL); + size_t i = 0; + for (auto & grfName : aGrfNames) + { + m_xExamplesVS->InsertItem( i + 1, i); + INetURLObject aObj(grfName); + if(aObj.GetProtocol() == INetProtocol::File) + grfName = aObj.PathToFileName(); + m_xExamplesVS->SetItemText( i + 1, grfName ); + ++i; + } + if(aGrfNames.empty()) + { + m_xErrorText->show(); + } + else + { + m_xExamplesVS->Show(); + m_xExamplesVS->SetFormat(); } } @@ -1151,27 +1149,26 @@ void SvxNumOptionsTabPage::ActivatePage(const SfxItemSet& rSet) } bModified = (!pActNum->Get( 0 ) || bPreset); - if(*pActNum != *pSaveNum || - nActNumLvl != nTmpNumLvl) + if(*pActNum == *pSaveNum && nActNumLvl == nTmpNumLvl) + return; + + nActNumLvl = nTmpNumLvl; + sal_uInt16 nMask = 1; + m_xLevelLB->unselect_all(); + if (nActNumLvl == SAL_MAX_UINT16) + m_xLevelLB->select(pActNum->GetLevelCount()); + if(nActNumLvl != SAL_MAX_UINT16) { - nActNumLvl = nTmpNumLvl; - sal_uInt16 nMask = 1; - m_xLevelLB->unselect_all(); - if (nActNumLvl == SAL_MAX_UINT16) - m_xLevelLB->select(pActNum->GetLevelCount()); - if(nActNumLvl != SAL_MAX_UINT16) + for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) { - for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) - { - if(nActNumLvl & nMask) - m_xLevelLB->select(i); - nMask <<= 1 ; - } + if(nActNumLvl & nMask) + m_xLevelLB->select(i); + nMask <<= 1 ; } - *pActNum = *pSaveNum; - - InitControls(); } + *pActNum = *pSaveNum; + + InitControls(); } DeactivateRC SvxNumOptionsTabPage::DeactivatePage(SfxItemSet * _pSet) @@ -1835,93 +1832,93 @@ IMPL_LINK(SvxNumOptionsTabPage, GraphicHdl_Impl, const OString&, rIdent, void) } } } - if(bSucc) - { - aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit)); + if(!bSucc) + return; - sal_uInt16 nMask = 1; - for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit)); + + sal_uInt16 nMask = 1; + for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + { + if(nActNumLvl & nMask) { - if(nActNumLvl & nMask) - { - SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); - aNumFmt.SetCharFormatName(m_sNumCharFmtName); - aNumFmt.SetGraphic(aGrfName); + SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); + aNumFmt.SetCharFormatName(m_sNumCharFmtName); + aNumFmt.SetGraphic(aGrfName); - // set size for a later comparison - const SvxBrushItem* pBrushItem = aNumFmt.GetBrush(); - // initiate asynchronous loading - sal_Int16 eOrient = aNumFmt.GetVertOrient(); - aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient ); - aInitSize[i] = aNumFmt.GetGraphicSize(); + // set size for a later comparison + const SvxBrushItem* pBrushItem = aNumFmt.GetBrush(); + // initiate asynchronous loading + sal_Int16 eOrient = aNumFmt.GetVertOrient(); + aNumFmt.SetGraphicBrush( pBrushItem, &aSize, &eOrient ); + aInitSize[i] = aNumFmt.GetGraphicSize(); - pActNum->SetLevel(i, aNumFmt); - } - nMask <<= 1; + pActNum->SetLevel(i, aNumFmt); } - m_xRatioCB->set_sensitive(true); - m_xWidthFT->set_sensitive(true); - m_xHeightFT->set_sensitive(true); - m_xWidthMF->set_sensitive(true); - m_xHeightMF->set_sensitive(true); - SetMetricValue(*m_xWidthMF, aSize.Width(), eCoreUnit); - SetMetricValue(*m_xHeightMF, aSize.Height(), eCoreUnit); - m_xOrientFT->set_sensitive(true); - m_xOrientLB->set_sensitive(true); - SetModified(); - //needed due to asynchronous loading of graphics in the SvxBrushItem - aInvalidateTimer.Start(); + nMask <<= 1; } + m_xRatioCB->set_sensitive(true); + m_xWidthFT->set_sensitive(true); + m_xHeightFT->set_sensitive(true); + m_xWidthMF->set_sensitive(true); + m_xHeightMF->set_sensitive(true); + SetMetricValue(*m_xWidthMF, aSize.Width(), eCoreUnit); + SetMetricValue(*m_xHeightMF, aSize.Height(), eCoreUnit); + m_xOrientFT->set_sensitive(true); + m_xOrientLB->set_sensitive(true); + SetModified(); + //needed due to asynchronous loading of graphics in the SvxBrushItem + aInvalidateTimer.Start(); } IMPL_LINK_NOARG(SvxNumOptionsTabPage, PopupActivateHdl_Impl, weld::ToggleButton&, void) { - if (!m_xGalleryMenu) - { - m_xGalleryMenu = m_xBuilder->weld_menu("gallerysubmenu"); - weld::WaitObject aWait(GetFrameWeld()); + if (m_xGalleryMenu) + return; - if (GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames)) - { - GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS); + m_xGalleryMenu = m_xBuilder->weld_menu("gallerysubmenu"); + weld::WaitObject aWait(GetFrameWeld()); - Graphic aGraphic; - OUString sGrfName; - ScopedVclPtrInstance< VirtualDevice > pVD; - size_t i = 0; - for (const auto & grfName : aGrfNames) + if (!GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames)) + return; + + GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS); + + Graphic aGraphic; + OUString sGrfName; + ScopedVclPtrInstance< VirtualDevice > pVD; + size_t i = 0; + for (const auto & grfName : aGrfNames) + { + sGrfName = grfName; + OUString sItemId = "gallery" + OUString::number(i); + INetURLObject aObj(sGrfName); + if(aObj.GetProtocol() == INetProtocol::File) + sGrfName = aObj.PathToFileName(); + if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, i, &aGraphic)) + { + BitmapEx aBitmap(aGraphic.GetBitmapEx()); + Size aSize(aBitmap.GetSizePixel()); + if(aSize.Width() > MAX_BMP_WIDTH || + aSize.Height() > MAX_BMP_HEIGHT) { - sGrfName = grfName; - OUString sItemId = "gallery" + OUString::number(i); - INetURLObject aObj(sGrfName); - if(aObj.GetProtocol() == INetProtocol::File) - sGrfName = aObj.PathToFileName(); - if(GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, i, &aGraphic)) - { - BitmapEx aBitmap(aGraphic.GetBitmapEx()); - Size aSize(aBitmap.GetSizePixel()); - if(aSize.Width() > MAX_BMP_WIDTH || - aSize.Height() > MAX_BMP_HEIGHT) - { - bool bWidth = aSize.Width() > aSize.Height(); - double nScale = bWidth ? - double(MAX_BMP_WIDTH) / static_cast(aSize.Width()): - double(MAX_BMP_HEIGHT) / static_cast(aSize.Height()); - aBitmap.Scale(nScale, nScale); - } - pVD->SetOutputSizePixel(aBitmap.GetSizePixel(), false); - pVD->DrawBitmapEx(Point(), aBitmap); - m_xGalleryMenu->append(sItemId, sGrfName, *pVD); - } - else - { - m_xGalleryMenu->append(sItemId, sGrfName); - } - ++i; + bool bWidth = aSize.Width() > aSize.Height(); + double nScale = bWidth ? + double(MAX_BMP_WIDTH) / static_cast(aSize.Width()): + double(MAX_BMP_HEIGHT) / static_cast(aSize.Height()); + aBitmap.Scale(nScale, nScale); } - GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS); + pVD->SetOutputSizePixel(aBitmap.GetSizePixel(), false); + pVD->DrawBitmapEx(Point(), aBitmap); + m_xGalleryMenu->append(sItemId, sGrfName, *pVD); } + else + { + m_xGalleryMenu->append(sItemId, sGrfName); + } + ++i; } + GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS); } IMPL_LINK_NOARG(SvxNumOptionsTabPage, BulletHdl_Impl, weld::Button&, void) @@ -1961,26 +1958,26 @@ IMPL_LINK_NOARG(SvxNumOptionsTabPage, BulletHdl_Impl, weld::Button&, void) aMap.SetCharFont(aActBulletFont); if (bSameBullet) aMap.SetChar(cBullet); - if (aMap.run() == RET_OK) - { - // change Font Numrules - aActBulletFont = aMap.GetCharFont(); + if (aMap.run() != RET_OK) + return; - sal_uInt16 _nMask = 1; - for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + // change Font Numrules + aActBulletFont = aMap.GetCharFont(); + + sal_uInt16 _nMask = 1; + for(sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++) + { + if(nActNumLvl & _nMask) { - if(nActNumLvl & _nMask) - { - SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); - aNumFmt.SetBulletFont(&aActBulletFont); - aNumFmt.SetBulletChar( static_cast(aMap.GetChar()) ); - pActNum->SetLevel(i, aNumFmt); - } - _nMask <<= 1; + SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); + aNumFmt.SetBulletFont(&aActBulletFont); + aNumFmt.SetBulletChar( static_cast(aMap.GetChar()) ); + pActNum->SetLevel(i, aNumFmt); } - - SetModified(); + _nMask <<= 1; } + + SetModified(); } IMPL_LINK( SvxNumOptionsTabPage, SizeHdl_Impl, weld::MetricSpinButton&, rField, void) diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx index 2fd72a79596f..1b5fc2851ce9 100644 --- a/cui/source/tabpages/page.cxx +++ b/cui/source/tabpages/page.cxx @@ -828,48 +828,48 @@ IMPL_LINK_NOARG(SvxPageDescPage, PaperSizeSelect_Impl, weld::ComboBox&, void) { Paper ePaper = m_xPaperSizeBox->get_active_id(); - if ( ePaper != PAPER_USER ) - { - Size aSize( SvxPaperInfo::GetPaperSize( ePaper, MapUnit::Map100thMM ) ); + if ( ePaper == PAPER_USER ) + return; - if (m_xLandscapeBtn->get_active()) - Swap( aSize ); + Size aSize( SvxPaperInfo::GetPaperSize( ePaper, MapUnit::Map100thMM ) ); - if ( aSize.Height() < m_xPaperHeightEdit->get_min( FieldUnit::MM_100TH ) ) - m_xPaperHeightEdit->set_min( - m_xPaperHeightEdit->normalize( aSize.Height() ), FieldUnit::MM_100TH ); - if ( aSize.Width() < m_xPaperWidthEdit->get_min( FieldUnit::MM_100TH ) ) - m_xPaperWidthEdit->set_min( - m_xPaperWidthEdit->normalize( aSize.Width() ), FieldUnit::MM_100TH ); - SetMetricValue( *m_xPaperHeightEdit, aSize.Height(), MapUnit::Map100thMM ); - SetMetricValue( *m_xPaperWidthEdit, aSize.Width(), MapUnit::Map100thMM ); + if (m_xLandscapeBtn->get_active()) + Swap( aSize ); - CalcMargin_Impl(); + if ( aSize.Height() < m_xPaperHeightEdit->get_min( FieldUnit::MM_100TH ) ) + m_xPaperHeightEdit->set_min( + m_xPaperHeightEdit->normalize( aSize.Height() ), FieldUnit::MM_100TH ); + if ( aSize.Width() < m_xPaperWidthEdit->get_min( FieldUnit::MM_100TH ) ) + m_xPaperWidthEdit->set_min( + m_xPaperWidthEdit->normalize( aSize.Width() ), FieldUnit::MM_100TH ); + SetMetricValue( *m_xPaperHeightEdit, aSize.Height(), MapUnit::Map100thMM ); + SetMetricValue( *m_xPaperWidthEdit, aSize.Width(), MapUnit::Map100thMM ); - RangeHdl_Impl(); - UpdateExample_Impl( true ); + CalcMargin_Impl(); - if ( eMode == SVX_PAGE_MODE_PRESENTATION ) - { - // Draw: if paper format the margin shall be 1 cm - long nTmp = 0; - bool bScreen = (( PAPER_SCREEN_4_3 == ePaper )||( PAPER_SCREEN_16_9 == ePaper)||( PAPER_SCREEN_16_10 == ePaper)); - - if ( !bScreen ) - // no margin if screen - nTmp = 1; // accordingly 1 cm - - if ( bScreen || m_xRightMarginEdit->get_value(FieldUnit::NONE) == 0 ) - SetMetricValue( *m_xRightMarginEdit, nTmp, MapUnit::MapCM ); - if ( bScreen || m_xLeftMarginEdit->get_value(FieldUnit::NONE) == 0 ) - SetMetricValue( *m_xLeftMarginEdit, nTmp, MapUnit::MapCM ); - if ( bScreen || m_xBottomMarginEdit->get_value(FieldUnit::NONE) == 0 ) - SetMetricValue( *m_xBottomMarginEdit, nTmp, MapUnit::MapCM ); - if ( bScreen || m_xTopMarginEdit->get_value(FieldUnit::NONE) == 0 ) - SetMetricValue( *m_xTopMarginEdit, nTmp, MapUnit::MapCM ); - UpdateExample_Impl( true ); - } - } + RangeHdl_Impl(); + UpdateExample_Impl( true ); + + if ( eMode != SVX_PAGE_MODE_PRESENTATION ) + return; + + // Draw: if paper format the margin shall be 1 cm + long nTmp = 0; + bool bScreen = (( PAPER_SCREEN_4_3 == ePaper )||( PAPER_SCREEN_16_9 == ePaper)||( PAPER_SCREEN_16_10 == ePaper)); + + if ( !bScreen ) + // no margin if screen + nTmp = 1; // accordingly 1 cm + + if ( bScreen || m_xRightMarginEdit->get_value(FieldUnit::NONE) == 0 ) + SetMetricValue( *m_xRightMarginEdit, nTmp, MapUnit::MapCM ); + if ( bScreen || m_xLeftMarginEdit->get_value(FieldUnit::NONE) == 0 ) + SetMetricValue( *m_xLeftMarginEdit, nTmp, MapUnit::MapCM ); + if ( bScreen || m_xBottomMarginEdit->get_value(FieldUnit::NONE) == 0 ) + SetMetricValue( *m_xBottomMarginEdit, nTmp, MapUnit::MapCM ); + if ( bScreen || m_xTopMarginEdit->get_value(FieldUnit::NONE) == 0 ) + SetMetricValue( *m_xTopMarginEdit, nTmp, MapUnit::MapCM ); + UpdateExample_Impl( true ); } IMPL_LINK_NOARG(SvxPageDescPage, PaperSizeModify_Impl, weld::MetricSpinButton&, void) @@ -900,27 +900,27 @@ IMPL_LINK_NOARG(SvxPageDescPage, PaperSizeModify_Impl, weld::MetricSpinButton&, IMPL_LINK(SvxPageDescPage, SwapOrientation_Impl, weld::Button&, rBtn, void) { if ( - (!bLandscape && &rBtn == m_xLandscapeBtn.get()) || - (bLandscape && &rBtn == m_xPortraitBtn.get()) + !((!bLandscape && &rBtn == m_xLandscapeBtn.get()) || + (bLandscape && &rBtn == m_xPortraitBtn.get())) ) - { - bLandscape = m_xLandscapeBtn->get_active(); + return; + + bLandscape = m_xLandscapeBtn->get_active(); - const long lWidth = GetCoreValue( *m_xPaperWidthEdit, MapUnit::Map100thMM ); - const long lHeight = GetCoreValue( *m_xPaperHeightEdit, MapUnit::Map100thMM ); + const long lWidth = GetCoreValue( *m_xPaperWidthEdit, MapUnit::Map100thMM ); + const long lHeight = GetCoreValue( *m_xPaperHeightEdit, MapUnit::Map100thMM ); - // swap width and height - SetMetricValue(*m_xPaperWidthEdit, lHeight, MapUnit::Map100thMM); - SetMetricValue(*m_xPaperHeightEdit, lWidth, MapUnit::Map100thMM); + // swap width and height + SetMetricValue(*m_xPaperWidthEdit, lHeight, MapUnit::Map100thMM); + SetMetricValue(*m_xPaperHeightEdit, lWidth, MapUnit::Map100thMM); - // recalculate margins if necessary - CalcMargin_Impl(); + // recalculate margins if necessary + CalcMargin_Impl(); - PaperSizeSelect_Impl(m_xPaperSizeBox->get_widget()); - RangeHdl_Impl(); - SwapFirstValues_Impl(bBorderModified); - UpdateExample_Impl(true); - } + PaperSizeSelect_Impl(m_xPaperSizeBox->get_widget()); + RangeHdl_Impl(); + SwapFirstValues_Impl(bBorderModified); + UpdateExample_Impl(true); } void SvxPageDescPage::SwapFirstValues_Impl( bool bSet ) @@ -965,21 +965,21 @@ void SvxPageDescPage::SwapFirstValues_Impl( bool bSet ) nFirstTopMargin = m_xTopMarginEdit->convert_value_from(m_xTopMarginEdit->normalize(nNewT), FieldUnit::TWIP); nFirstBottomMargin = m_xBottomMarginEdit->convert_value_from(m_xBottomMarginEdit->normalize(nNewB), FieldUnit::TWIP); - if ( bSet ) - { - if ( nSetL < nNewL ) - m_xLeftMarginEdit->set_value( m_xLeftMarginEdit->normalize( nNewL ), - FieldUnit::TWIP ); - if ( nSetR < nNewR ) - m_xRightMarginEdit->set_value( m_xRightMarginEdit->normalize( nNewR ), - FieldUnit::TWIP ); - if ( nSetT < nNewT ) - m_xTopMarginEdit->set_value( m_xTopMarginEdit->normalize( nNewT ), - FieldUnit::TWIP ); - if ( nSetB < nNewB ) - m_xBottomMarginEdit->set_value( m_xBottomMarginEdit->normalize( nNewB ), - FieldUnit::TWIP ); - } + if ( !bSet ) + return; + + if ( nSetL < nNewL ) + m_xLeftMarginEdit->set_value( m_xLeftMarginEdit->normalize( nNewL ), + FieldUnit::TWIP ); + if ( nSetR < nNewR ) + m_xRightMarginEdit->set_value( m_xRightMarginEdit->normalize( nNewR ), + FieldUnit::TWIP ); + if ( nSetT < nNewT ) + m_xTopMarginEdit->set_value( m_xTopMarginEdit->normalize( nNewT ), + FieldUnit::TWIP ); + if ( nSetB < nNewB ) + m_xBottomMarginEdit->set_value( m_xBottomMarginEdit->normalize( nNewB ), + FieldUnit::TWIP ); } IMPL_LINK_NOARG(SvxPageDescPage, BorderModify_Impl, weld::MetricSpinButton&, void) @@ -1179,57 +1179,57 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet ) // evaluate footer attributes - if ( SfxItemState::SET == + if ( SfxItemState::SET != rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ), false, reinterpret_cast(&pSetItem) ) ) + return; + + const SfxItemSet& rFooterSet = pSetItem->GetItemSet(); + const SfxBoolItem& rFooterOn = + static_cast(rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) )); + + if ( rFooterOn.GetValue() ) { - const SfxItemSet& rFooterSet = pSetItem->GetItemSet(); - const SfxBoolItem& rFooterOn = - static_cast(rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) )); + const SvxSizeItem& rSize = static_cast( + rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) )); + const SvxULSpaceItem& rUL = static_cast( + rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) )); + long nDist = rUL.GetUpper(); + m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist ); + m_aBspWin.SetFtDist( nDist ); + const SvxLRSpaceItem& rLR = static_cast( + rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); + m_aBspWin.SetFtLeft( rLR.GetLeft() ); + m_aBspWin.SetFtRight( rLR.GetRight() ); + m_aBspWin.SetFooter( true ); + } + else + m_aBspWin.SetFooter( false ); - if ( rFooterOn.GetValue() ) - { - const SvxSizeItem& rSize = static_cast( - rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) )); - const SvxULSpaceItem& rUL = static_cast( - rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) )); - long nDist = rUL.GetUpper(); - m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist ); - m_aBspWin.SetFtDist( nDist ); - const SvxLRSpaceItem& rLR = static_cast( - rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); - m_aBspWin.SetFtLeft( rLR.GetLeft() ); - m_aBspWin.SetFtRight( rLR.GetRight() ); - m_aBspWin.SetFooter( true ); - } - else - m_aBspWin.SetFooter( false ); + // show background and border in the example + drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes; - // show background and border in the example - drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFooterFillAttributes; + if(mbEnableDrawingLayerFillStyles) + { + // create FillAttributes directly from DrawingLayer FillStyle entries + aFooterFillAttributes = std::make_shared(rFooterSet); + } + else + { + const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH)); - if(mbEnableDrawingLayerFillStyles) - { - // create FillAttributes directly from DrawingLayer FillStyle entries - aFooterFillAttributes = std::make_shared(rFooterSet); - } - else + if(rFooterSet.GetItemState(nWhich) >= SfxItemState::DEFAULT) { - const sal_uInt16 nWhich(GetWhich(SID_ATTR_BRUSH)); + // aBspWin.SetFtColor(rItem.GetColor()); + const SvxBrushItem& rItem = static_cast(rFooterSet.Get(nWhich)); + SfxItemSet aTempSet(*rFooterSet.GetPool(), svl::Items{}); - if(rFooterSet.GetItemState(nWhich) >= SfxItemState::DEFAULT) - { - // aBspWin.SetFtColor(rItem.GetColor()); - const SvxBrushItem& rItem = static_cast(rFooterSet.Get(nWhich)); - SfxItemSet aTempSet(*rFooterSet.GetPool(), svl::Items{}); - - setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); - aFooterFillAttributes = std::make_shared(aTempSet); - } + setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); + aFooterFillAttributes = std::make_shared(aTempSet); } - - m_aBspWin.setFooterFillAttributes(aFooterFillAttributes); } + + m_aBspWin.setFooterFillAttributes(aFooterFillAttributes); } void SvxPageDescPage::ActivatePage( const SfxItemSet& rSet ) @@ -1376,29 +1376,29 @@ void SvxPageDescPage::CalcMargin_Impl() long nWidth = nBL + nBR + MINBODY; long nHeight = nBT + nBB + MINBODY; - if ( nWidth > nW || nHeight > nH ) + if ( !(nWidth > nW || nHeight > nH) ) + return; + + if ( nWidth > nW ) { - if ( nWidth > nW ) - { - long nTmp = nBL <= nBR ? nBR : nBL; - nTmp -= nWidth - nW; + long nTmp = nBL <= nBR ? nBR : nBL; + nTmp -= nWidth - nW; - if ( nBL <= nBR ) - SetMetricValue( *m_xRightMarginEdit, nTmp, MapUnit::MapTwip ); - else - SetMetricValue( *m_xLeftMarginEdit, nTmp, MapUnit::MapTwip ); - } + if ( nBL <= nBR ) + SetMetricValue( *m_xRightMarginEdit, nTmp, MapUnit::MapTwip ); + else + SetMetricValue( *m_xLeftMarginEdit, nTmp, MapUnit::MapTwip ); + } - if ( nHeight > nH ) - { - long nTmp = nBT <= nBB ? nBB : nBT; - nTmp -= nHeight - nH; + if ( nHeight > nH ) + { + long nTmp = nBT <= nBB ? nBB : nBT; + nTmp -= nHeight - nH; - if ( nBT <= nBB ) - SetMetricValue( *m_xBottomMarginEdit, nTmp, MapUnit::MapTwip ); - else - SetMetricValue( *m_xTopMarginEdit, nTmp, MapUnit::MapTwip ); - } + if ( nBT <= nBB ) + SetMetricValue( *m_xBottomMarginEdit, nTmp, MapUnit::MapTwip ); + else + SetMetricValue( *m_xTopMarginEdit, nTmp, MapUnit::MapTwip ); } } diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index 54889cbf0bb5..27a34a33279e 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -632,36 +632,36 @@ void SvxStdParagraphTabPage::ActivatePage( const SfxItemSet& rSet ) sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_ADJUST ); SfxItemState eItemState = rSet.GetItemState( _nWhich ); - if ( eItemState >= SfxItemState::DEFAULT ) + if ( eItemState < SfxItemState::DEFAULT ) + return; + + const SvxAdjustItem& rAdj = static_cast( rSet.Get( _nWhich ) ); + SvxAdjust eAdjust = rAdj.GetAdjust(); + if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block ) { - const SvxAdjustItem& rAdj = static_cast( rSet.Get( _nWhich ) ); - SvxAdjust eAdjust = rAdj.GetAdjust(); - if ( eAdjust == SvxAdjust::Center || eAdjust == SvxAdjust::Block ) - { - _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION ); - eItemState = rSet.GetItemState( _nWhich ); + _nWhich = GetWhich( SID_ATTR_FRAMEDIRECTION ); + eItemState = rSet.GetItemState( _nWhich ); - if ( eItemState >= SfxItemState::DEFAULT ) - { - const SvxFrameDirectionItem& rFrameDirItem = static_cast( rSet.Get( _nWhich ) ); - SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue(); + if ( eItemState >= SfxItemState::DEFAULT ) + { + const SvxFrameDirectionItem& rFrameDirItem = static_cast( rSet.Get( _nWhich ) ); + SvxFrameDirection eFrameDirection = rFrameDirItem.GetValue(); - m_aExampleWin.EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection ); + m_aExampleWin.EnableRTL( SvxFrameDirection::Horizontal_RL_TB == eFrameDirection ); - if ( eAdjust == SvxAdjust::Block ) - m_aExampleWin.SetLastLine( rAdj.GetLastBlock() ); - } + if ( eAdjust == SvxAdjust::Block ) + m_aExampleWin.SetLastLine( rAdj.GetLastBlock() ); } - else - { - m_aExampleWin.EnableRTL( eAdjust == SvxAdjust::Right ); - eAdjust = SvxAdjust::Left; //required for correct preview display - m_aExampleWin.SetLastLine( eAdjust ); - } - m_aExampleWin.SetAdjust( eAdjust ); - - UpdateExample_Impl(); } + else + { + m_aExampleWin.EnableRTL( eAdjust == SvxAdjust::Right ); + eAdjust = SvxAdjust::Left; //required for correct preview display + m_aExampleWin.SetLastLine( eAdjust ); + } + m_aExampleWin.SetAdjust( eAdjust ); + + UpdateExample_Impl(); } DeactivateRC SvxStdParagraphTabPage::DeactivatePage( SfxItemSet* _pSet ) @@ -1977,22 +1977,22 @@ SvxExtParagraphTabPage::SvxExtParagraphTabPage(weld::Container* pPage, weld::Dia } sal_uInt16 nHtmlMode = GetHtmlMode_Impl( rAttr ); - if ( nHtmlMode & HTMLMODE_ON ) - { - bHtmlMode = true; - m_xHyphenBox->set_sensitive(false); - m_xHyphenNoCapsBox->set_sensitive(false); - m_xBeforeText->set_sensitive(false); - m_xExtHyphenBeforeBox->set_sensitive(false); - m_xAfterText->set_sensitive(false); - m_xExtHyphenAfterBox->set_sensitive(false); - m_xMaxHyphenLabel->set_sensitive(false); - m_xMaxHyphenEdit->set_sensitive(false); - m_xPageNumBox->set_sensitive(false); - m_xPagenumEdit->set_sensitive(false); - // no column break in HTML - m_xBreakTypeLB->remove(1); - } + if ( !(nHtmlMode & HTMLMODE_ON) ) + return; + + bHtmlMode = true; + m_xHyphenBox->set_sensitive(false); + m_xHyphenNoCapsBox->set_sensitive(false); + m_xBeforeText->set_sensitive(false); + m_xExtHyphenBeforeBox->set_sensitive(false); + m_xAfterText->set_sensitive(false); + m_xExtHyphenAfterBox->set_sensitive(false); + m_xMaxHyphenLabel->set_sensitive(false); + m_xMaxHyphenEdit->set_sensitive(false); + m_xPageNumBox->set_sensitive(false); + m_xPagenumEdit->set_sensitive(false); + // no column break in HTML + m_xBreakTypeLB->remove(1); } SvxExtParagraphTabPage::~SvxExtParagraphTabPage() diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index 9b144bf47919..f8d6beeb9649 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -1007,54 +1007,54 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) m_xHeightMF->save_value(); m_fWidthHeightRatio = double(nWidth) / double(nHeight); - if(!m_bPositioningDisabled) + if(m_bPositioningDisabled) + return; + + pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_ORIENT); + if(pItem) { - pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_ORIENT); - if(pItem) - { - short nHoriOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue(); - m_nOldH = nHoriOrientation; - } - pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_ORIENT); - if(pItem) - { - short nVertOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue(); - m_nOldV = nVertOrientation; - } - pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_RELATION); - if(pItem) - { - m_nOldHRel = static_cast< const SfxInt16Item*>(pItem)->GetValue(); - } + short nHoriOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue(); + m_nOldH = nHoriOrientation; + } + pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_ORIENT); + if(pItem) + { + short nVertOrientation = static_cast< const SfxInt16Item*>(pItem)->GetValue(); + m_nOldV = nVertOrientation; + } + pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_RELATION); + if(pItem) + { + m_nOldHRel = static_cast< const SfxInt16Item*>(pItem)->GetValue(); + } - pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_RELATION); - if(pItem) - { - m_nOldVRel = static_cast< const SfxInt16Item*>(pItem)->GetValue(); - } - pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_MIRROR); - if(pItem) - m_xHoriMirrorCB->set_active(static_cast(pItem)->GetValue()); - m_xHoriMirrorCB->save_state(); + pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_RELATION); + if(pItem) + { + m_nOldVRel = static_cast< const SfxInt16Item*>(pItem)->GetValue(); + } + pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_MIRROR); + if(pItem) + m_xHoriMirrorCB->set_active(static_cast(pItem)->GetValue()); + m_xHoriMirrorCB->save_state(); - sal_Int32 nHoriPos = 0; - sal_Int32 nVertPos = 0; - pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_POSITION); - if(pItem) - nHoriPos = static_cast(pItem)->GetValue(); - pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_POSITION); - if(pItem) - nVertPos = static_cast(pItem)->GetValue(); + sal_Int32 nHoriPos = 0; + sal_Int32 nVertPos = 0; + pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_HORI_POSITION); + if(pItem) + nHoriPos = static_cast(pItem)->GetValue(); + pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_VERT_POSITION); + if(pItem) + nVertPos = static_cast(pItem)->GetValue(); - InitPos(nAnchorType, m_nOldH, m_nOldHRel, m_nOldV, m_nOldVRel, nHoriPos, nVertPos); + InitPos(nAnchorType, m_nOldH, m_nOldHRel, m_nOldV, m_nOldVRel, nHoriPos, nVertPos); - m_xVertByMF->save_value(); - m_xHoriByMF->save_value(); - // #i18732# - m_xFollowCB->save_state(); + m_xVertByMF->save_value(); + m_xHoriByMF->save_value(); + // #i18732# + m_xFollowCB->save_state(); - RangeModifyHdl(m_xWidthMF->get_widget()); // initially set maximum values - } + RangeModifyHdl(m_xWidthMF->get_widget()); // initially set maximum values } DeactivateRC SvxSwPosSizeTabPage::DeactivatePage( SfxItemSet* _pSet ) @@ -1290,59 +1290,58 @@ IMPL_LINK(SvxSwPosSizeTabPage, PosHdl, weld::ComboBox&, rLB, void) UpdateExample(); // special treatment for HTML-Mode with horz-vert-dependencies - if (m_bHtmlMode && RndStdIds::FLY_AT_CHAR == GetAnchorType()) + if (!(m_bHtmlMode && RndStdIds::FLY_AT_CHAR == GetAnchorType())) + return; + + bool bSet = false; + if(bHori) { - bool bSet = false; - if(bHori) + // on the right only below is allowed - from the left only at the top + // from the left at the character -> below + if((HoriOrientation::LEFT == nAlign || HoriOrientation::RIGHT == nAlign) && + 0 == m_xVertLB->get_active()) { - // on the right only below is allowed - from the left only at the top - // from the left at the character -> below - if((HoriOrientation::LEFT == nAlign || HoriOrientation::RIGHT == nAlign) && - 0 == m_xVertLB->get_active()) - { - if(RelOrientation::FRAME == nRel) - m_xVertLB->set_active(1); - else - m_xVertLB->set_active(0); - bSet = true; - } - else if(HoriOrientation::LEFT == nAlign && 1 == m_xVertLB->get_active()) - { + if(RelOrientation::FRAME == nRel) + m_xVertLB->set_active(1); + else m_xVertLB->set_active(0); - bSet = true; - } - else if(HoriOrientation::NONE == nAlign && 1 == m_xVertLB->get_active()) + bSet = true; + } + else if(HoriOrientation::LEFT == nAlign && 1 == m_xVertLB->get_active()) + { + m_xVertLB->set_active(0); + bSet = true; + } + else if(HoriOrientation::NONE == nAlign && 1 == m_xVertLB->get_active()) + { + m_xVertLB->set_active(0); + bSet = true; + } + if(bSet) + PosHdl(*m_xVertLB); + } + else + { + if(VertOrientation::TOP == nAlign) + { + if(1 == m_xHoriLB->get_active()) { - m_xVertLB->set_active(0); + m_xHoriLB->set_active(0); bSet = true; } - if(bSet) - PosHdl(*m_xVertLB); + m_xHoriToLB->set_active(1); } - else + else if(VertOrientation::CHAR_BOTTOM == nAlign) { - if(VertOrientation::TOP == nAlign) - { - if(1 == m_xHoriLB->get_active()) - { - m_xHoriLB->set_active(0); - bSet = true; - } - m_xHoriToLB->set_active(1); - } - else if(VertOrientation::CHAR_BOTTOM == nAlign) + if(2 == m_xHoriLB->get_active()) { - if(2 == m_xHoriLB->get_active()) - { - m_xHoriLB->set_active(0); - bSet = true; - } - m_xHoriToLB->set_active(0) ; + m_xHoriLB->set_active(0); + bSet = true; } - if(bSet) - PosHdl(*m_xHoriLB); + m_xHoriToLB->set_active(0) ; } - + if(bSet) + PosHdl(*m_xHoriLB); } } diff --git a/cui/source/tabpages/textanim.cxx b/cui/source/tabpages/textanim.cxx index 6c1742b70b5c..ab5dc095bfff 100644 --- a/cui/source/tabpages/textanim.cxx +++ b/cui/source/tabpages/textanim.cxx @@ -57,25 +57,25 @@ SvxTextTabDialog::SvxTextTabDialog(weld::Window* pParent, const SfxItemSet* pAtt void SvxTextTabDialog::PageCreated(const OString& rId, SfxTabPage &rPage) { - if (rId == "RID_SVXPAGE_TEXTATTR") + if (rId != "RID_SVXPAGE_TEXTATTR") + return; + + SdrObjKind eKind = OBJ_NONE; + if (pView) { - SdrObjKind eKind = OBJ_NONE; - if (pView) + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + bool bHasMarked = rMarkList.GetMarkCount() > 0; + if (bHasMarked) { - const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); - bool bHasMarked = rMarkList.GetMarkCount() > 0; - if (bHasMarked) + if (rMarkList.GetMarkCount() == 1) { - if (rMarkList.GetMarkCount() == 1) - { - const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - eKind = static_cast(pObj->GetObjIdentifier()); - } + const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + eKind = static_cast(pObj->GetObjIdentifier()); } } - static_cast(rPage).SetObjKind(eKind); - static_cast(rPage).Construct(); } + static_cast(rPage).SetObjKind(eKind); + static_cast(rPage).Construct(); } /************************************************************************* @@ -385,75 +385,74 @@ std::unique_ptr SvxTextAnimationPage::Create(weld::Container* pPage, IMPL_LINK_NOARG(SvxTextAnimationPage, SelectEffectHdl_Impl, weld::ComboBox&, void) { int nPos = m_xLbEffect->get_active(); - if (nPos != -1) + if (nPos == -1) + return; + + eAniKind = static_cast(nPos); + switch( eAniKind ) { - eAniKind = static_cast(nPos); - switch( eAniKind ) + case SdrTextAniKind::NONE: + { + m_xBoxDirection->set_sensitive(false); + m_xFlProperties->set_sensitive(false); + } + break; + + case SdrTextAniKind::Blink: + case SdrTextAniKind::Scroll: + case SdrTextAniKind::Alternate: + case SdrTextAniKind::Slide: { - case SdrTextAniKind::NONE: + m_xFlProperties->set_sensitive(true); + if( eAniKind == SdrTextAniKind::Slide ) { - m_xBoxDirection->set_sensitive(false); - m_xFlProperties->set_sensitive(false); + m_xTsbStartInside->set_sensitive(false); + m_xTsbStopInside->set_sensitive(false); + m_xTsbEndless->set_sensitive(false); + m_xNumFldCount->set_sensitive(true); + m_xNumFldCount->set_value(m_xNumFldCount->get_value()); } - break; + else + { + m_xTsbStartInside->set_sensitive(true); + m_xTsbStopInside->set_sensitive(true); + m_xTsbEndless->set_sensitive(true); + ClickEndlessHdl_Impl(*m_xTsbEndless); + } + + m_xTsbAuto->set_sensitive(true); + ClickAutoHdl_Impl(*m_xTsbAuto); - case SdrTextAniKind::Blink: - case SdrTextAniKind::Scroll: - case SdrTextAniKind::Alternate: - case SdrTextAniKind::Slide: + if( eAniKind == SdrTextAniKind::Blink ) + { + m_xBoxDirection->set_sensitive(false); + m_xBoxCount->set_sensitive(false); + } + else { - m_xFlProperties->set_sensitive(true); - if( eAniKind == SdrTextAniKind::Slide ) - { - m_xTsbStartInside->set_sensitive(false); - m_xTsbStopInside->set_sensitive(false); - m_xTsbEndless->set_sensitive(false); - m_xNumFldCount->set_sensitive(true); - m_xNumFldCount->set_value(m_xNumFldCount->get_value()); - } - else - { - m_xTsbStartInside->set_sensitive(true); - m_xTsbStopInside->set_sensitive(true); - m_xTsbEndless->set_sensitive(true); - ClickEndlessHdl_Impl(*m_xTsbEndless); - } - - m_xTsbAuto->set_sensitive(true); - ClickAutoHdl_Impl(*m_xTsbAuto); - - if( eAniKind == SdrTextAniKind::Blink ) - { - m_xBoxDirection->set_sensitive(false); - m_xBoxCount->set_sensitive(false); - } - else - { - m_xBoxDirection->set_sensitive(true); - m_xBoxCount->set_sensitive(true); - } + m_xBoxDirection->set_sensitive(true); + m_xBoxCount->set_sensitive(true); } - break; } - + break; } } IMPL_LINK_NOARG(SvxTextAnimationPage, ClickEndlessHdl_Impl, weld::Button&, void) { - if( eAniKind != SdrTextAniKind::Slide ) + if( eAniKind == SdrTextAniKind::Slide ) + return; + + TriState eState = m_xTsbEndless->get_state(); + if( eState != TRISTATE_FALSE ) { - TriState eState = m_xTsbEndless->get_state(); - if( eState != TRISTATE_FALSE ) - { - m_xNumFldCount->set_sensitive(false); - m_xNumFldCount->set_text(""); - } - else - { - m_xNumFldCount->set_sensitive(true); - m_xNumFldCount->set_value(m_xNumFldCount->get_value()); - } + m_xNumFldCount->set_sensitive(false); + m_xNumFldCount->set_text(""); + } + else + { + m_xNumFldCount->set_sensitive(true); + m_xNumFldCount->set_value(m_xNumFldCount->get_value()); } } diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx index b82e57ba3233..c9eaf461c94d 100644 --- a/cui/source/tabpages/textattr.cxx +++ b/cui/source/tabpages/textattr.cxx @@ -483,37 +483,37 @@ std::unique_ptr SvxTextAttrPage::Create(weld::Container* pPage, weld */ void SvxTextAttrPage::PointChanged(weld::DrawingArea*, RectPoint eRP) { - if (m_xTsbFullWidth->get_state() == TRISTATE_TRUE) - { - // Depending on write direction and currently checked anchor we have - // to uncheck the "full width" button. - if (IsTextDirectionLeftToRight()) - switch( eRP ) - { - case RectPoint::LT: - case RectPoint::LM: - case RectPoint::LB: - case RectPoint::RT: - case RectPoint::RM: - case RectPoint::RB: - m_xTsbFullWidth->set_state( TRISTATE_FALSE ); - break; - default: ;//prevent warning - } - else - switch (eRP) - { - case RectPoint::LT: - case RectPoint::MT: - case RectPoint::RT: - case RectPoint::LB: - case RectPoint::MB: - case RectPoint::RB: - m_xTsbFullWidth->set_state( TRISTATE_FALSE ); - break; - default: ;//prevent warning - } - } + if (m_xTsbFullWidth->get_state() != TRISTATE_TRUE) + return; + + // Depending on write direction and currently checked anchor we have + // to uncheck the "full width" button. + if (IsTextDirectionLeftToRight()) + switch( eRP ) + { + case RectPoint::LT: + case RectPoint::LM: + case RectPoint::LB: + case RectPoint::RT: + case RectPoint::RM: + case RectPoint::RB: + m_xTsbFullWidth->set_state( TRISTATE_FALSE ); + break; + default: ;//prevent warning + } + else + switch (eRP) + { + case RectPoint::LT: + case RectPoint::MT: + case RectPoint::RT: + case RectPoint::LB: + case RectPoint::MB: + case RectPoint::RB: + m_xTsbFullWidth->set_state( TRISTATE_FALSE ); + break; + default: ;//prevent warning + } } @@ -529,51 +529,51 @@ void SvxTextAttrPage::PointChanged(weld::DrawingArea*, RectPoint eRP) */ IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Button&, void) { - if( m_xTsbFullWidth->get_state() == TRISTATE_TRUE ) + if( m_xTsbFullWidth->get_state() != TRISTATE_TRUE ) + return; + + if (IsTextDirectionLeftToRight()) { - if (IsTextDirectionLeftToRight()) + // Move text anchor to horizontal middle axis. + switch( m_aCtlPosition.GetActualRP() ) { - // Move text anchor to horizontal middle axis. - switch( m_aCtlPosition.GetActualRP() ) - { - case RectPoint::LT: - case RectPoint::RT: - m_aCtlPosition.SetActualRP( RectPoint::MT ); - break; - - case RectPoint::LM: - case RectPoint::RM: - m_aCtlPosition.SetActualRP( RectPoint::MM ); - break; - - case RectPoint::LB: - case RectPoint::RB: - m_aCtlPosition.SetActualRP( RectPoint::MB ); - break; - default: ;//prevent warning - } + case RectPoint::LT: + case RectPoint::RT: + m_aCtlPosition.SetActualRP( RectPoint::MT ); + break; + + case RectPoint::LM: + case RectPoint::RM: + m_aCtlPosition.SetActualRP( RectPoint::MM ); + break; + + case RectPoint::LB: + case RectPoint::RB: + m_aCtlPosition.SetActualRP( RectPoint::MB ); + break; + default: ;//prevent warning } - else + } + else + { + // Move text anchor to vertical middle axis. + switch( m_aCtlPosition.GetActualRP() ) { - // Move text anchor to vertical middle axis. - switch( m_aCtlPosition.GetActualRP() ) - { - case RectPoint::LT: - case RectPoint::LB: - m_aCtlPosition.SetActualRP( RectPoint::LM ); - break; - - case RectPoint::MT: - case RectPoint::MB: - m_aCtlPosition.SetActualRP( RectPoint::MM ); - break; - - case RectPoint::RT: - case RectPoint::RB: - m_aCtlPosition.SetActualRP( RectPoint::RM ); + case RectPoint::LT: + case RectPoint::LB: + m_aCtlPosition.SetActualRP( RectPoint::LM ); break; - default: ;//prevent warning - } + + case RectPoint::MT: + case RectPoint::MB: + m_aCtlPosition.SetActualRP( RectPoint::MM ); + break; + + case RectPoint::RT: + case RectPoint::RB: + m_aCtlPosition.SetActualRP( RectPoint::RM ); + break; + default: ;//prevent warning } } } diff --git a/cui/source/tabpages/tpbitmap.cxx b/cui/source/tabpages/tpbitmap.cxx index 1e25750eefc6..70073f7e4fd3 100644 --- a/cui/source/tabpages/tpbitmap.cxx +++ b/cui/source/tabpages/tpbitmap.cxx @@ -436,25 +436,25 @@ void SvxBitmapTabPage::ClickBitmapHdl_Impl() void SvxBitmapTabPage::CalculateBitmapPresetSize() { - if(!rBitmapSize.IsEmpty()) - { - long nObjectWidth = static_cast(m_fObjectWidth); - long nObjectHeight = static_cast(m_fObjectHeight); + if(rBitmapSize.IsEmpty()) + return; - if(std::abs(rBitmapSize.Width() - nObjectWidth) < std::abs(rBitmapSize.Height() - nObjectHeight)) - { - rFilledSize.setWidth( nObjectWidth ); - rFilledSize.setHeight( rBitmapSize.Height()*nObjectWidth/rBitmapSize.Width() ); - rZoomedSize.setWidth( rBitmapSize.Width()*nObjectHeight/rBitmapSize.Height() ); - rZoomedSize.setHeight( nObjectHeight ); - } - else - { - rFilledSize.setWidth( rBitmapSize.Width()*nObjectHeight/rBitmapSize.Height() ); - rFilledSize.setHeight( nObjectHeight ); - rZoomedSize.setWidth( nObjectWidth ); - rZoomedSize.setHeight( rBitmapSize.Height()*nObjectWidth/rBitmapSize.Width() ); - } + long nObjectWidth = static_cast(m_fObjectWidth); + long nObjectHeight = static_cast(m_fObjectHeight); + + if(std::abs(rBitmapSize.Width() - nObjectWidth) < std::abs(rBitmapSize.Height() - nObjectHeight)) + { + rFilledSize.setWidth( nObjectWidth ); + rFilledSize.setHeight( rBitmapSize.Height()*nObjectWidth/rBitmapSize.Width() ); + rZoomedSize.setWidth( rBitmapSize.Width()*nObjectHeight/rBitmapSize.Height() ); + rZoomedSize.setHeight( nObjectHeight ); + } + else + { + rFilledSize.setWidth( rBitmapSize.Width()*nObjectHeight/rBitmapSize.Height() ); + rFilledSize.setHeight( nObjectHeight ); + rZoomedSize.setWidth( nObjectWidth ); + rZoomedSize.setHeight( rBitmapSize.Height()*nObjectWidth/rBitmapSize.Width() ); } } @@ -524,37 +524,37 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickRenameHdl, SvxPresetListBox*, void) sal_uInt16 nId = m_xBitmapLB->GetSelectedItemId(); size_t nPos = m_xBitmapLB->GetSelectItemPos(); - if( nPos != VALUESET_ITEM_NOTFOUND ) - { - OUString aDesc( CuiResId( RID_SVXSTR_DESC_NEW_BITMAP ) ); - OUString aName( m_pBitmapList->GetBitmap( nPos )->GetName() ); + if( nPos == VALUESET_ITEM_NOTFOUND ) + return; - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); + OUString aDesc( CuiResId( RID_SVXSTR_DESC_NEW_BITMAP ) ); + OUString aName( m_pBitmapList->GetBitmap( nPos )->GetName() ); - bool bLoop = true; - while( bLoop && pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - sal_Int32 nBitmapPos = SearchBitmapList( aName ); - bool bValidBitmapName = (nBitmapPos == static_cast(nPos) ) || (nBitmapPos == -1); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); - if(bValidBitmapName) - { - bLoop = false; - m_pBitmapList->GetBitmap(nPos)->SetName(aName); + bool bLoop = true; + while( bLoop && pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aName ); + sal_Int32 nBitmapPos = SearchBitmapList( aName ); + bool bValidBitmapName = (nBitmapPos == static_cast(nPos) ) || (nBitmapPos == -1); - m_xBitmapLB->SetItemText(nId, aName); - m_xBitmapLB->SelectItem( nId ); + if(bValidBitmapName) + { + bLoop = false; + m_pBitmapList->GetBitmap(nPos)->SetName(aName); - *m_pnBitmapListState |= ChangeType::MODIFIED; - } - else - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); - std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); - xBox->run(); - } + m_xBitmapLB->SetItemText(nId, aName); + m_xBitmapLB->SelectItem( nId ); + + *m_pnBitmapListState |= ChangeType::MODIFIED; + } + else + { + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); + xBox->run(); } } } @@ -564,22 +564,22 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickDeleteHdl, SvxPresetListBox*, void) sal_uInt16 nId = m_xBitmapLB->GetSelectedItemId(); size_t nPos = m_xBitmapLB->GetSelectItemPos(); - if( nPos != VALUESET_ITEM_NOTFOUND ) - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletebitmapdialog.ui")); - std::unique_ptr xQueryBox(xBuilder->weld_message_dialog("AskDelBitmapDialog")); + if( nPos == VALUESET_ITEM_NOTFOUND ) + return; - if (xQueryBox->run() == RET_YES) - { - m_pBitmapList->Remove( static_cast(nPos) ); - m_xBitmapLB->RemoveItem( nId ); - nId = m_xBitmapLB->GetItemId(0); - m_xBitmapLB->SelectItem( nId ); + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletebitmapdialog.ui")); + std::unique_ptr xQueryBox(xBuilder->weld_message_dialog("AskDelBitmapDialog")); - m_aCtlBitmapPreview.Invalidate(); - ModifyBitmapHdl(m_xBitmapLB.get()); - *m_pnBitmapListState |= ChangeType::MODIFIED; - } + if (xQueryBox->run() == RET_YES) + { + m_pBitmapList->Remove( static_cast(nPos) ); + m_xBitmapLB->RemoveItem( nId ); + nId = m_xBitmapLB->GetItemId(0); + m_xBitmapLB->SelectItem( nId ); + + m_aCtlBitmapPreview.Invalidate(); + ModifyBitmapHdl(m_xBitmapLB.get()); + *m_pnBitmapListState |= ChangeType::MODIFIED; } } @@ -722,71 +722,71 @@ IMPL_LINK_NOARG(SvxBitmapTabPage, ClickImportHdl, weld::Button&, void) aDlg.EnableLink(false); long nCount = m_pBitmapList->Count(); - if( !aDlg.Execute() ) - { - Graphic aGraphic; + if( aDlg.Execute() ) + return; - std::unique_ptr xWait(new weld::WaitObject(pDialogFrameWeld)); - ErrCode nError = aDlg.GetGraphic( aGraphic ); - xWait.reset(); + Graphic aGraphic; - if( !nError ) - { - OUString aDesc(CuiResId(RID_SVXSTR_DESC_EXT_BITMAP)); + std::unique_ptr xWait(new weld::WaitObject(pDialogFrameWeld)); + ErrCode nError = aDlg.GetGraphic( aGraphic ); + xWait.reset(); - // convert file URL to UI name - OUString aName; - INetURLObject aURL( aDlg.GetPath() ); - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact->CreateSvxNameDialog( - pDialogFrameWeld, aURL.GetLastName().getToken(0, '.'), aDesc)); - nError = ErrCode(1); + if( !nError ) + { + OUString aDesc(CuiResId(RID_SVXSTR_DESC_EXT_BITMAP)); - while( pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); + // convert file URL to UI name + OUString aName; + INetURLObject aURL( aDlg.GetPath() ); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr pDlg(pFact->CreateSvxNameDialog( + pDialogFrameWeld, aURL.GetLastName().getToken(0, '.'), aDesc)); + nError = ErrCode(1); - bool bDifferent = true; + while( pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aName ); - for( long i = 0; i < nCount && bDifferent; i++ ) - if( aName == m_pBitmapList->GetBitmap( i )->GetName() ) - bDifferent = false; + bool bDifferent = true; - if( bDifferent ) { - nError = ERRCODE_NONE; - break; - } + for( long i = 0; i < nCount && bDifferent; i++ ) + if( aName == m_pBitmapList->GetBitmap( i )->GetName() ) + bDifferent = false; - std::unique_ptr xBuilder(Application::CreateBuilder(pDialogFrameWeld, "cui/ui/queryduplicatedialog.ui")); - std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); - if (xBox->run() != RET_OK) - break; + if( bDifferent ) { + nError = ERRCODE_NONE; + break; } - pDlg.disposeAndClear(); + std::unique_ptr xBuilder(Application::CreateBuilder(pDialogFrameWeld, "cui/ui/queryduplicatedialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); + if (xBox->run() != RET_OK) + break; + } - if( !nError ) - { - m_pBitmapList->Insert(std::make_unique(aGraphic, aName), nCount); + pDlg.disposeAndClear(); - sal_Int32 nId = m_xBitmapLB->GetItemId( nCount - 1 ); - BitmapEx aBitmap = m_pBitmapList->GetBitmapForPreview( nCount, m_xBitmapLB->GetIconSize() ); + if( !nError ) + { + m_pBitmapList->Insert(std::make_unique(aGraphic, aName), nCount); - m_xBitmapLB->InsertItem( nId + 1, Image(aBitmap), aName ); - m_xBitmapLB->SelectItem( nId + 1 ); - *m_pnBitmapListState |= ChangeType::MODIFIED; + sal_Int32 nId = m_xBitmapLB->GetItemId( nCount - 1 ); + BitmapEx aBitmap = m_pBitmapList->GetBitmapForPreview( nCount, m_xBitmapLB->GetIconSize() ); - ModifyBitmapHdl(m_xBitmapLB.get()); - } - } - else - { - // graphic couldn't be loaded - std::unique_ptr xBuilder(Application::CreateBuilder(pDialogFrameWeld, "cui/ui/querynoloadedfiledialog.ui")); - std::unique_ptr xBox(xBuilder->weld_message_dialog("NoLoadedFileDialog")); - xBox->run(); + m_xBitmapLB->InsertItem( nId + 1, Image(aBitmap), aName ); + m_xBitmapLB->SelectItem( nId + 1 ); + *m_pnBitmapListState |= ChangeType::MODIFIED; + + ModifyBitmapHdl(m_xBitmapLB.get()); } } + else + { + // graphic couldn't be loaded + std::unique_ptr xBuilder(Application::CreateBuilder(pDialogFrameWeld, "cui/ui/querynoloadedfiledialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("NoLoadedFileDialog")); + xBox->run(); + } } sal_Int32 SvxBitmapTabPage::SearchBitmapList(const GraphicObject& rGraphicObject) diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index 24a8199e12f4..456897ee28d6 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -185,29 +185,29 @@ void SvxColorTabPage::Construct() void SvxColorTabPage::ActivatePage( const SfxItemSet& ) { - if( pColorList.is() ) + if( !pColorList.is() ) + return; + + const SfxPoolItem* pPoolItem = nullptr; + if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) - { - SetColorModel( ColorModel::RGB ); - ChangeColorModel(); + SetColorModel( ColorModel::RGB ); + ChangeColorModel(); - const Color aColor = static_cast(pPoolItem)->GetColorValue(); - ChangeColor( aColor ); - sal_Int32 nPos = FindInPalette( aColor ); + const Color aColor = static_cast(pPoolItem)->GetColorValue(); + ChangeColor( aColor ); + sal_Int32 nPos = FindInPalette( aColor ); - if ( nPos != -1 ) - m_xValSetColorList->SelectItem(m_xValSetColorList->GetItemId(nPos)); - // else search in other palettes? + if ( nPos != -1 ) + m_xValSetColorList->SelectItem(m_xValSetColorList->GetItemId(nPos)); + // else search in other palettes? - } + } - m_aCtlPreviewOld.SetAttributes(aXFillAttr.GetItemSet()); - m_aCtlPreviewOld.Invalidate(); + m_aCtlPreviewOld.SetAttributes(aXFillAttr.GetItemSet()); + m_aCtlPreviewOld.Invalidate(); - SelectValSetHdl_Impl(m_xValSetColorList.get()); - } + SelectValSetHdl_Impl(m_xValSetColorList.get()); } DeactivateRC SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet ) @@ -396,32 +396,32 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickDeleteHdl_Impl, weld::Button&, void) { sal_uInt16 nId = m_xValSetColorList->GetSelectedItemId(); size_t nPos = m_xValSetColorList->GetSelectItemPos(); - if (m_xSelectPalette->get_active() == 0 && nPos != VALUESET_ITEM_NOTFOUND ) + if (!(m_xSelectPalette->get_active() == 0 && nPos != VALUESET_ITEM_NOTFOUND) ) + return; + + std::shared_ptr batch(comphelper::ConfigurationChanges::create(m_context)); + css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); + css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); + sal_Int32 nSize = aCustomColorList.getLength() - 1; + for(sal_Int32 nIndex = static_cast(nPos);nIndex < nSize;nIndex++) { - std::shared_ptr batch(comphelper::ConfigurationChanges::create(m_context)); - css::uno::Sequence< sal_Int32 > aCustomColorList(officecfg::Office::Common::UserColors::CustomColor::get()); - css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); - sal_Int32 nSize = aCustomColorList.getLength() - 1; - for(sal_Int32 nIndex = static_cast(nPos);nIndex < nSize;nIndex++) - { - aCustomColorList[nIndex] = aCustomColorList[nIndex+1]; - aCustomColorNameList[nIndex] = aCustomColorNameList[nIndex+1]; - } - aCustomColorList.realloc(nSize); - aCustomColorNameList.realloc(nSize); - officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); - officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); - batch->commit(); - m_xValSetColorList->RemoveItem(nId); - if (m_xValSetColorList->GetItemCount() != 0) - { - nId = m_xValSetColorList->GetItemId(0); - m_xValSetColorList->SelectItem(nId); - SelectValSetHdl_Impl(m_xValSetColorList.get()); - } - else - m_xBtnDelete->set_sensitive(false); + aCustomColorList[nIndex] = aCustomColorList[nIndex+1]; + aCustomColorNameList[nIndex] = aCustomColorNameList[nIndex+1]; } + aCustomColorList.realloc(nSize); + aCustomColorNameList.realloc(nSize); + officecfg::Office::Common::UserColors::CustomColor::set(aCustomColorList, batch); + officecfg::Office::Common::UserColors::CustomColorName::set(aCustomColorNameList, batch); + batch->commit(); + m_xValSetColorList->RemoveItem(nId); + if (m_xValSetColorList->GetItemCount() != 0) + { + nId = m_xValSetColorList->GetItemId(0); + m_xValSetColorList->SelectItem(nId); + SelectValSetHdl_Impl(m_xValSetColorList.get()); + } + else + m_xBtnDelete->set_sensitive(false); } IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, weld::ComboBox&, void) @@ -462,28 +462,28 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectPaletteLBHdl, weld::ComboBox&, void) IMPL_LINK(SvxColorTabPage, SelectValSetHdl_Impl, SvtValueSet*, pValSet, void) { sal_Int32 nPos = pValSet->GetSelectedItemId(); - if( nPos != 0 ) - { - Color aColor = pValSet->GetItemColor( nPos ); + if( nPos == 0 ) + return; - rXFSet.Put( XFillColorItem( OUString(), aColor ) ); - m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); - m_aCtlPreviewNew.Invalidate(); - ChangeColor(aColor, false); + Color aColor = pValSet->GetItemColor( nPos ); - if (pValSet == m_xValSetColorList.get()) - { - m_xValSetRecentList->SetNoSelection(); - if (m_xSelectPalette->get_active() == 0 && m_xValSetColorList->GetSelectedItemId() != 0) - m_xBtnDelete->set_sensitive(true); - else - m_xBtnDelete->set_sensitive(false); - } - if (pValSet == m_xValSetRecentList.get()) - { - m_xValSetColorList->SetNoSelection(); + rXFSet.Put( XFillColorItem( OUString(), aColor ) ); + m_aCtlPreviewNew.SetAttributes( aXFillAttr.GetItemSet() ); + m_aCtlPreviewNew.Invalidate(); + ChangeColor(aColor, false); + + if (pValSet == m_xValSetColorList.get()) + { + m_xValSetRecentList->SetNoSelection(); + if (m_xSelectPalette->get_active() == 0 && m_xValSetColorList->GetSelectedItemId() != 0) + m_xBtnDelete->set_sensitive(true); + else m_xBtnDelete->set_sensitive(false); - } + } + if (pValSet == m_xValSetRecentList.get()) + { + m_xValSetColorList->SetNoSelection(); + m_xBtnDelete->set_sensitive(false); } } diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx index 38bee1a8b1d7..777bc5d70bd9 100644 --- a/cui/source/tabpages/tpgradnt.cxx +++ b/cui/source/tabpages/tpgradnt.cxx @@ -128,44 +128,44 @@ void SvxGradientTabPage::Construct() void SvxGradientTabPage::ActivatePage( const SfxItemSet& rSet ) { - if( m_pColorList.is() ) + if( !m_pColorList.is() ) + return; + + // ColorList + if( *m_pnColorListState & ChangeType::CHANGED || + *m_pnColorListState & ChangeType::MODIFIED ) { - // ColorList - if( *m_pnColorListState & ChangeType::CHANGED || - *m_pnColorListState & ChangeType::MODIFIED ) - { - SvxAreaTabDialog* pArea = (*m_pnColorListState & ChangeType::CHANGED) ? - dynamic_cast(GetDialogController()) : nullptr; - if (pArea) - m_pColorList = pArea->GetNewColorList(); + SvxAreaTabDialog* pArea = (*m_pnColorListState & ChangeType::CHANGED) ? + dynamic_cast(GetDialogController()) : nullptr; + if (pArea) + m_pColorList = pArea->GetNewColorList(); - ModifiedHdl_Impl( this ); - } + ModifiedHdl_Impl( this ); + } - // determining (and possibly cutting) the name and - // displaying it in the GroupBox - OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; - INetURLObject aURL( m_pGradientList->GetPath() ); + // determining (and possibly cutting) the name and + // displaying it in the GroupBox + OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; + INetURLObject aURL( m_pGradientList->GetPath() ); - aURL.Append( m_pGradientList->GetName() ); - SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" ); + aURL.Append( m_pGradientList->GetName() ); + SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" ); - if ( aURL.getBase().getLength() > 18 ) - { - aString += aURL.getBase().copy( 0, 15 ) + "..."; - } - else - aString += aURL.getBase(); + if ( aURL.getBase().getLength() > 18 ) + { + aString += aURL.getBase().copy( 0, 15 ) + "..."; + } + else + aString += aURL.getBase(); - sal_Int32 nPos = SearchGradientList( rSet.Get(XATTR_FILLGRADIENT).GetName() ); - if ( nPos != -1) - { - sal_uInt16 nId = m_xGradientLB->GetItemId( static_cast( nPos ) ); - m_xGradientLB->SelectItem( nId ); - } - // colors could have been deleted - ChangeGradientHdl_Impl(); + sal_Int32 nPos = SearchGradientList( rSet.Get(XATTR_FILLGRADIENT).GetName() ); + if ( nPos != -1) + { + sal_uInt16 nId = m_xGradientLB->GetItemId( static_cast( nPos ) ); + m_xGradientLB->SelectItem( nId ); } + // colors could have been deleted + ChangeGradientHdl_Impl(); } @@ -391,30 +391,30 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl, weld::Button&, void) sal_uInt16 nId = m_xGradientLB->GetSelectedItemId(); size_t nPos = m_xGradientLB->GetSelectItemPos(); - if ( nPos != VALUESET_ITEM_NOTFOUND ) - { - OUString aName( m_pGradientList->GetGradient( static_cast(nPos) )->GetName() ); + if ( nPos == VALUESET_ITEM_NOTFOUND ) + return; - XGradient aXGradient( m_xLbColorFrom->GetSelectEntryColor(), - m_xLbColorTo->GetSelectEntryColor(), - static_cast(m_xLbGradientType->get_active()), - static_cast(m_xMtrAngle->get_value(FieldUnit::NONE) * 10), // should be changed in resource - static_cast(m_xMtrCenterX->get_value(FieldUnit::NONE)), - static_cast(m_xMtrCenterY->get_value(FieldUnit::NONE)), - static_cast(m_xMtrBorder->get_value(FieldUnit::NONE)), - static_cast(m_xMtrColorFrom->get_value(FieldUnit::NONE)), - static_cast(m_xMtrColorTo->get_value(FieldUnit::NONE)), - static_cast(m_xMtrIncrement->get_value()) ); + OUString aName( m_pGradientList->GetGradient( static_cast(nPos) )->GetName() ); - m_pGradientList->Replace(std::make_unique(aXGradient, aName), nPos); + XGradient aXGradient( m_xLbColorFrom->GetSelectEntryColor(), + m_xLbColorTo->GetSelectEntryColor(), + static_cast(m_xLbGradientType->get_active()), + static_cast(m_xMtrAngle->get_value(FieldUnit::NONE) * 10), // should be changed in resource + static_cast(m_xMtrCenterX->get_value(FieldUnit::NONE)), + static_cast(m_xMtrCenterY->get_value(FieldUnit::NONE)), + static_cast(m_xMtrBorder->get_value(FieldUnit::NONE)), + static_cast(m_xMtrColorFrom->get_value(FieldUnit::NONE)), + static_cast(m_xMtrColorTo->get_value(FieldUnit::NONE)), + static_cast(m_xMtrIncrement->get_value()) ); - BitmapEx aBitmap = m_pGradientList->GetBitmapForPreview( static_cast(nPos), m_xGradientLB->GetIconSize() ); - m_xGradientLB->RemoveItem( nId ); - m_xGradientLB->InsertItem( nId, Image(aBitmap), aName, static_cast(nPos) ); - m_xGradientLB->SelectItem( nId ); + m_pGradientList->Replace(std::make_unique(aXGradient, aName), nPos); - *m_pnGradientListState |= ChangeType::MODIFIED; - } + BitmapEx aBitmap = m_pGradientList->GetBitmapForPreview( static_cast(nPos), m_xGradientLB->GetIconSize() ); + m_xGradientLB->RemoveItem( nId ); + m_xGradientLB->InsertItem( nId, Image(aBitmap), aName, static_cast(nPos) ); + m_xGradientLB->SelectItem( nId ); + + *m_pnGradientListState |= ChangeType::MODIFIED; } IMPL_LINK_NOARG(SvxGradientTabPage, ClickDeleteHdl_Impl, SvxPresetListBox*, void) @@ -451,37 +451,37 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void sal_uInt16 nId = m_xGradientLB->GetSelectedItemId(); size_t nPos = m_xGradientLB->GetSelectItemPos(); - if ( nPos != VALUESET_ITEM_NOTFOUND ) - { - OUString aDesc( CuiResId( RID_SVXSTR_DESC_GRADIENT ) ); - OUString aName( m_pGradientList->GetGradient( nPos )->GetName() ); + if ( nPos == VALUESET_ITEM_NOTFOUND ) + return; - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); + OUString aDesc( CuiResId( RID_SVXSTR_DESC_GRADIENT ) ); + OUString aName( m_pGradientList->GetGradient( nPos )->GetName() ); - bool bLoop = true; - while( bLoop && pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - sal_Int32 nGradientPos = SearchGradientList(aName); - bool bValidGradientName = (nGradientPos == static_cast(nPos) ) || (nGradientPos == -1); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); - if( bValidGradientName ) - { - bLoop = false; - m_pGradientList->GetGradient(nPos)->SetName(aName); + bool bLoop = true; + while( bLoop && pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aName ); + sal_Int32 nGradientPos = SearchGradientList(aName); + bool bValidGradientName = (nGradientPos == static_cast(nPos) ) || (nGradientPos == -1); - m_xGradientLB->SetItemText( nId, aName ); - m_xGradientLB->SelectItem( nId ); + if( bValidGradientName ) + { + bLoop = false; + m_pGradientList->GetGradient(nPos)->SetName(aName); - *m_pnGradientListState |= ChangeType::MODIFIED; - } - else - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); - std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); - xBox->run(); - } + m_xGradientLB->SetItemText( nId, aName ); + m_xGradientLB->SelectItem( nId ); + + *m_pnGradientListState |= ChangeType::MODIFIED; + } + else + { + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); + xBox->run(); } } } @@ -518,50 +518,50 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl() } } - if( pGradient ) - { - css::awt::GradientStyle eXGS = pGradient->GetGradientStyle(); - sal_uInt16 nValue = pGradient->GetSteps(); - if( nValue == 0 ) - { - m_xCbIncrement->set_state(TRISTATE_TRUE); - m_xMtrIncrement->set_sensitive(false); - } - else - { - m_xCbIncrement->set_state(TRISTATE_FALSE); - m_xMtrIncrement->set_sensitive(true); - m_xMtrIncrement->set_value( nValue ); - } - m_xLbGradientType->set_active( - sal::static_int_cast< sal_Int32 >( eXGS ) ); - // if the entry is not in the listbox, - // colors are added temporarily - m_xLbColorFrom->SetNoSelection(); - m_xLbColorFrom->SelectEntry( pGradient->GetStartColor() ); - - m_xLbColorTo->SetNoSelection(); - m_xLbColorTo->SelectEntry( pGradient->GetEndColor() ); - - m_xMtrAngle->set_value(pGradient->GetAngle() / 10, FieldUnit::NONE); // should be changed in resource - m_xSliderAngle->set_value(pGradient->GetAngle() / 10); - m_xMtrBorder->set_value(pGradient->GetBorder(), FieldUnit::NONE); - m_xSliderBorder->set_value(pGradient->GetBorder()); - m_xMtrCenterX->set_value(pGradient->GetXOffset(), FieldUnit::NONE); - m_xMtrCenterY->set_value(pGradient->GetYOffset(), FieldUnit::NONE); - m_xMtrColorFrom->set_value(pGradient->GetStartIntens(), FieldUnit::NONE); - m_xMtrColorTo->set_value(pGradient->GetEndIntens(), FieldUnit::NONE); - - // disable/enable controls - SetControlState_Impl( eXGS ); - - // fill ItemSet and pass it on to aCtlPreview - m_rXFSet.Put( XFillGradientItem( OUString(), *pGradient ) ); - m_rXFSet.Put( XGradientStepCountItem( nValue ) ); - m_aCtlPreview.SetAttributes(m_aXFillAttr.GetItemSet()); + if( !pGradient ) + return; - m_aCtlPreview.Invalidate(); + css::awt::GradientStyle eXGS = pGradient->GetGradientStyle(); + sal_uInt16 nValue = pGradient->GetSteps(); + if( nValue == 0 ) + { + m_xCbIncrement->set_state(TRISTATE_TRUE); + m_xMtrIncrement->set_sensitive(false); + } + else + { + m_xCbIncrement->set_state(TRISTATE_FALSE); + m_xMtrIncrement->set_sensitive(true); + m_xMtrIncrement->set_value( nValue ); } + m_xLbGradientType->set_active( + sal::static_int_cast< sal_Int32 >( eXGS ) ); + // if the entry is not in the listbox, + // colors are added temporarily + m_xLbColorFrom->SetNoSelection(); + m_xLbColorFrom->SelectEntry( pGradient->GetStartColor() ); + + m_xLbColorTo->SetNoSelection(); + m_xLbColorTo->SelectEntry( pGradient->GetEndColor() ); + + m_xMtrAngle->set_value(pGradient->GetAngle() / 10, FieldUnit::NONE); // should be changed in resource + m_xSliderAngle->set_value(pGradient->GetAngle() / 10); + m_xMtrBorder->set_value(pGradient->GetBorder(), FieldUnit::NONE); + m_xSliderBorder->set_value(pGradient->GetBorder()); + m_xMtrCenterX->set_value(pGradient->GetXOffset(), FieldUnit::NONE); + m_xMtrCenterY->set_value(pGradient->GetYOffset(), FieldUnit::NONE); + m_xMtrColorFrom->set_value(pGradient->GetStartIntens(), FieldUnit::NONE); + m_xMtrColorTo->set_value(pGradient->GetEndIntens(), FieldUnit::NONE); + + // disable/enable controls + SetControlState_Impl( eXGS ); + + // fill ItemSet and pass it on to aCtlPreview + m_rXFSet.Put( XFillGradientItem( OUString(), *pGradient ) ); + m_rXFSet.Put( XGradientStepCountItem( nValue ) ); + m_aCtlPreview.SetAttributes(m_aXFillAttr.GetItemSet()); + + m_aCtlPreview.Invalidate(); } void SvxGradientTabPage::SetControlState_Impl( css::awt::GradientStyle eXGS ) diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx index 888f33e8d96a..d65c501f9d57 100644 --- a/cui/source/tabpages/tphatch.cxx +++ b/cui/source/tabpages/tphatch.cxx @@ -434,26 +434,26 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickAddHdl_Impl, weld::Button&, void) } pDlg.disposeAndClear(); - if( !nError ) - { - XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(), - static_cast(m_xLbLineType->get_active()), - GetCoreValue( *m_xMtrDistance, m_ePoolUnit ), - static_cast(m_xMtrAngle->get_value(FieldUnit::NONE) * 10) ); + if( nError ) + return; - m_pHatchingList->Insert(std::make_unique(aXHatch, aName), nCount); + XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(), + static_cast(m_xLbLineType->get_active()), + GetCoreValue( *m_xMtrDistance, m_ePoolUnit ), + static_cast(m_xMtrAngle->get_value(FieldUnit::NONE) * 10) ); - sal_Int32 nId = m_xHatchLB->GetItemId(nCount - 1); // calculate the last ID - BitmapEx aBitmap = m_pHatchingList->GetBitmapForPreview( nCount, m_xHatchLB->GetIconSize() ); - // Insert the new entry at the next ID - m_xHatchLB->InsertItem( nId + 1, Image(aBitmap), aName ); - m_xHatchLB->SelectItem( nId + 1 ); - m_xHatchLB->Resize(); + m_pHatchingList->Insert(std::make_unique(aXHatch, aName), nCount); - *m_pnHatchingListState |= ChangeType::MODIFIED; + sal_Int32 nId = m_xHatchLB->GetItemId(nCount - 1); // calculate the last ID + BitmapEx aBitmap = m_pHatchingList->GetBitmapForPreview( nCount, m_xHatchLB->GetIconSize() ); + // Insert the new entry at the next ID + m_xHatchLB->InsertItem( nId + 1, Image(aBitmap), aName ); + m_xHatchLB->SelectItem( nId + 1 ); + m_xHatchLB->Resize(); - ChangeHatchHdl_Impl(); - } + *m_pnHatchingListState |= ChangeType::MODIFIED; + + ChangeHatchHdl_Impl(); } IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl, weld::Button&, void) @@ -461,31 +461,31 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickModifyHdl_Impl, weld::Button&, void) sal_uInt16 nId = m_xHatchLB->GetSelectedItemId(); size_t nPos = m_xHatchLB->GetSelectItemPos(); - if( nPos != VALUESET_ITEM_NOTFOUND ) - { - OUString aName( m_pHatchingList->GetHatch( static_cast(nPos) )->GetName() ); + if( nPos == VALUESET_ITEM_NOTFOUND ) + return; + + OUString aName( m_pHatchingList->GetHatch( static_cast(nPos) )->GetName() ); - XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(), - static_cast(m_xLbLineType->get_active()), - GetCoreValue( *m_xMtrDistance, m_ePoolUnit ), - static_cast(m_xMtrAngle->get_value(FieldUnit::NONE) * 10) ); + XHatch aXHatch( m_xLbLineColor->GetSelectEntryColor(), + static_cast(m_xLbLineType->get_active()), + GetCoreValue( *m_xMtrDistance, m_ePoolUnit ), + static_cast(m_xMtrAngle->get_value(FieldUnit::NONE) * 10) ); - m_pHatchingList->Replace(std::make_unique(aXHatch, aName), nPos); + m_pHatchingList->Replace(std::make_unique(aXHatch, aName), nPos); - BitmapEx aBitmap = m_pHatchingList->GetBitmapForPreview( static_cast(nPos), m_xHatchLB->GetIconSize() ); - m_xHatchLB->RemoveItem( nId ); - m_xHatchLB->InsertItem( nId, Image(aBitmap), aName, static_cast(nPos) ); - m_xHatchLB->SelectItem( nId ); + BitmapEx aBitmap = m_pHatchingList->GetBitmapForPreview( static_cast(nPos), m_xHatchLB->GetIconSize() ); + m_xHatchLB->RemoveItem( nId ); + m_xHatchLB->InsertItem( nId, Image(aBitmap), aName, static_cast(nPos) ); + m_xHatchLB->SelectItem( nId ); - // save values for changes recognition (-> method) - m_xMtrDistance->save_value(); - m_xMtrAngle->save_value(); - m_xLbLineType->save_value(); - m_xLbLineColor->SaveValue(); - m_xLbBackgroundColor->SaveValue(); + // save values for changes recognition (-> method) + m_xMtrDistance->save_value(); + m_xMtrAngle->save_value(); + m_xLbLineType->save_value(); + m_xLbLineColor->SaveValue(); + m_xLbBackgroundColor->SaveValue(); - *m_pnHatchingListState |= ChangeType::MODIFIED; - } + *m_pnHatchingListState |= ChangeType::MODIFIED; } IMPL_LINK_NOARG(SvxHatchTabPage, ClickDeleteHdl_Impl, SvxPresetListBox*, void) @@ -493,25 +493,25 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickDeleteHdl_Impl, SvxPresetListBox*, void) sal_uInt16 nId = m_xHatchLB->GetSelectedItemId(); size_t nPos = m_xHatchLB->GetSelectItemPos(); - if( nPos != VALUESET_ITEM_NOTFOUND ) - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletehatchdialog.ui")); - std::unique_ptr xQueryBox(xBuilder->weld_message_dialog("AskDelHatchDialog")); - if (xQueryBox->run() == RET_YES) - { - m_pHatchingList->Remove(nPos); - m_xHatchLB->RemoveItem( nId ); - nId = m_xHatchLB->GetItemId(0); - m_xHatchLB->SelectItem( nId ); - m_xHatchLB->Resize(); + if( nPos == VALUESET_ITEM_NOTFOUND ) + return; - m_aCtlPreview.Invalidate(); + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querydeletehatchdialog.ui")); + std::unique_ptr xQueryBox(xBuilder->weld_message_dialog("AskDelHatchDialog")); + if (xQueryBox->run() != RET_YES) + return; - ChangeHatchHdl_Impl(); + m_pHatchingList->Remove(nPos); + m_xHatchLB->RemoveItem( nId ); + nId = m_xHatchLB->GetItemId(0); + m_xHatchLB->SelectItem( nId ); + m_xHatchLB->Resize(); - *m_pnHatchingListState |= ChangeType::MODIFIED; - } - } + m_aCtlPreview.Invalidate(); + + ChangeHatchHdl_Impl(); + + *m_pnHatchingListState |= ChangeType::MODIFIED; } IMPL_LINK_NOARG(SvxHatchTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void ) @@ -519,37 +519,37 @@ IMPL_LINK_NOARG(SvxHatchTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void ) sal_uInt16 nId = m_xHatchLB->GetSelectedItemId(); size_t nPos = m_xHatchLB->GetSelectItemPos(); - if( nPos != VALUESET_ITEM_NOTFOUND ) - { - OUString aDesc( CuiResId( RID_SVXSTR_DESC_HATCH ) ); - OUString aName( m_pHatchingList->GetHatch( nPos )->GetName() ); + if( nPos == VALUESET_ITEM_NOTFOUND ) + return; - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); + OUString aDesc( CuiResId( RID_SVXSTR_DESC_HATCH ) ); + OUString aName( m_pHatchingList->GetHatch( nPos )->GetName() ); - bool bLoop = true; - while( bLoop && pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - sal_Int32 nHatchPos = SearchHatchList( aName ); - bool bValidHatchName = (nHatchPos == static_cast(nPos) ) || (nHatchPos == -1); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); - if(bValidHatchName) - { - bLoop = false; - m_pHatchingList->GetHatch(nPos)->SetName(aName); + bool bLoop = true; + while( bLoop && pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aName ); + sal_Int32 nHatchPos = SearchHatchList( aName ); + bool bValidHatchName = (nHatchPos == static_cast(nPos) ) || (nHatchPos == -1); - m_xHatchLB->SetItemText(nId, aName); - m_xHatchLB->SelectItem( nId ); + if(bValidHatchName) + { + bLoop = false; + m_pHatchingList->GetHatch(nPos)->SetName(aName); - *m_pnHatchingListState |= ChangeType::MODIFIED; - } - else - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); - std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); - xBox->run(); - } + m_xHatchLB->SetItemText(nId, aName); + m_xHatchLB->SelectItem( nId ); + + *m_pnHatchingListState |= ChangeType::MODIFIED; + } + else + { + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); + xBox->run(); } } diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index 881d5108a1c1..6079adcd5790 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -1428,84 +1428,84 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, weld::ToggleButton&, void) m_xSymbolMB->set_item_sensitive("gallery", false); } - if (!m_xSymbolsMenu && m_pSymbolList) - { - m_xSymbolsMenu = m_xBuilder->weld_menu("symbolssubmenu"); - ScopedVclPtrInstance< VirtualDevice > pVDev; - pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); - std::unique_ptr pModel( - new SdrModel(nullptr, nullptr, true)); - pModel->GetItemPool().FreezeIdRanges(); - // Page - SdrPage* pPage = new SdrPage( *pModel, false ); - pPage->SetSize(Size(1000,1000)); - pModel->InsertPage( pPage, 0 ); - { - // 3D View - std::unique_ptr pView(new SdrView( *pModel, pVDev )); - pView->hideMarkHandles(); - pView->ShowSdrPage(pPage); + if (!(!m_xSymbolsMenu && m_pSymbolList)) + return; + + m_xSymbolsMenu = m_xBuilder->weld_menu("symbolssubmenu"); + ScopedVclPtrInstance< VirtualDevice > pVDev; + pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); + std::unique_ptr pModel( + new SdrModel(nullptr, nullptr, true)); + pModel->GetItemPool().FreezeIdRanges(); + // Page + SdrPage* pPage = new SdrPage( *pModel, false ); + pPage->SetSize(Size(1000,1000)); + pModel->InsertPage( pPage, 0 ); + { + // 3D View + std::unique_ptr pView(new SdrView( *pModel, pVDev )); + pView->hideMarkHandles(); + pView->ShowSdrPage(pPage); - // Generate invisible square to give all symbols a - // bitmap size, which is independent from specific glyph - SdrObject *pInvisibleSquare=m_pSymbolList->GetObj(0); + // Generate invisible square to give all symbols a + // bitmap size, which is independent from specific glyph + SdrObject *pInvisibleSquare=m_pSymbolList->GetObj(0); - // directly clone to target SdrModel - pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel); + // directly clone to target SdrModel + pInvisibleSquare = pInvisibleSquare->CloneSdrObject(*pModel); - pPage->NbcInsertObject(pInvisibleSquare); - pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); - pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); + pPage->NbcInsertObject(pInvisibleSquare); + pInvisibleSquare->SetMergedItem(XFillTransparenceItem(100)); + pInvisibleSquare->SetMergedItem(XLineTransparenceItem(100)); - for(size_t i=0; i < m_pSymbolList->GetObjCount(); ++i) - { - SdrObject *pObj=m_pSymbolList->GetObj(i); - assert(pObj); + for(size_t i=0; i < m_pSymbolList->GetObjCount(); ++i) + { + SdrObject *pObj=m_pSymbolList->GetObj(i); + assert(pObj); - // directly clone to target SdrModel - pObj = pObj->CloneSdrObject(*pModel); + // directly clone to target SdrModel + pObj = pObj->CloneSdrObject(*pModel); - m_aGrfNames.emplace_back(""); - pPage->NbcInsertObject(pObj); - if(m_pSymbolAttr) - { - pObj->SetMergedItemSet(*m_pSymbolAttr); - } - else - { - pObj->SetMergedItemSet(m_rOutAttrs); - } - pView->MarkAll(); - BitmapEx aBitmapEx(pView->GetMarkedObjBitmapEx()); - GDIMetaFile aMeta(pView->GetMarkedObjMetaFile()); - pView->UnmarkAll(); - pObj=pPage->RemoveObject(1); - SdrObject::Free(pObj); - - SvxBmpItemInfo* pInfo = new SvxBmpItemInfo; - pInfo->pBrushItem.reset(new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH)); - pInfo->sItemId = "symbol" + OUString::number(i); - m_aSymbolBrushItems.emplace_back(pInfo); - - Size aSize(aBitmapEx.GetSizePixel()); - if(aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT) - { - bool bWidth = aSize.Width() > aSize.Height(); - double nScale = bWidth ? - double(MAX_BMP_WIDTH) / static_cast(aSize.Width()): - double(MAX_BMP_HEIGHT) / static_cast(aSize.Height()); - aBitmapEx.Scale(nScale, nScale); - } - pVD->SetOutputSizePixel(aBitmapEx.GetSizePixel()); - pVD->DrawBitmapEx(Point(), aBitmapEx); - m_xSymbolsMenu->append(pInfo->sItemId, "", *pVD); + m_aGrfNames.emplace_back(""); + pPage->NbcInsertObject(pObj); + if(m_pSymbolAttr) + { + pObj->SetMergedItemSet(*m_pSymbolAttr); } - pInvisibleSquare=pPage->RemoveObject(0); - SdrObject::Free(pInvisibleSquare); + else + { + pObj->SetMergedItemSet(m_rOutAttrs); + } + pView->MarkAll(); + BitmapEx aBitmapEx(pView->GetMarkedObjBitmapEx()); + GDIMetaFile aMeta(pView->GetMarkedObjMetaFile()); + pView->UnmarkAll(); + pObj=pPage->RemoveObject(1); + SdrObject::Free(pObj); + + SvxBmpItemInfo* pInfo = new SvxBmpItemInfo; + pInfo->pBrushItem.reset(new SvxBrushItem(Graphic(aMeta), GPOS_AREA, SID_ATTR_BRUSH)); + pInfo->sItemId = "symbol" + OUString::number(i); + m_aSymbolBrushItems.emplace_back(pInfo); - if (m_aGrfNames.empty()) - m_xSymbolMB->set_item_sensitive("symbols", false); + Size aSize(aBitmapEx.GetSizePixel()); + if(aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT) + { + bool bWidth = aSize.Width() > aSize.Height(); + double nScale = bWidth ? + double(MAX_BMP_WIDTH) / static_cast(aSize.Width()): + double(MAX_BMP_HEIGHT) / static_cast(aSize.Height()); + aBitmapEx.Scale(nScale, nScale); + } + pVD->SetOutputSizePixel(aBitmapEx.GetSizePixel()); + pVD->DrawBitmapEx(Point(), aBitmapEx); + m_xSymbolsMenu->append(pInfo->sItemId, "", *pVD); } + pInvisibleSquare=pPage->RemoveObject(0); + SdrObject::Free(pInvisibleSquare); + + if (m_aGrfNames.empty()) + m_xSymbolMB->set_item_sensitive("symbols", false); } } diff --git a/cui/source/tabpages/tplnedef.cxx b/cui/source/tabpages/tplnedef.cxx index ba1ab3588fd0..2cef64e0e22e 100644 --- a/cui/source/tabpages/tplnedef.cxx +++ b/cui/source/tabpages/tplnedef.cxx @@ -148,32 +148,32 @@ void SvxLineDefTabPage::Construct() void SvxLineDefTabPage::ActivatePage( const SfxItemSet& ) { - if( nDlgType == 0 ) // area dialog + if( nDlgType != 0 ) // area dialog + return; + + // ActivatePage() is called before the dialog receives PageCreated() !!! + if( !pDashList.is() ) + return; + + if (*pPageType == PageType::Gradient && + *pPosDashLb != -1) { - // ActivatePage() is called before the dialog receives PageCreated() !!! - if( pDashList.is() ) - { - if (*pPageType == PageType::Gradient && - *pPosDashLb != -1) - { - m_xLbLineStyles->set_active(*pPosDashLb); - } - // so that a possibly existing line style is discarded - SelectLinestyleHdl_Impl( nullptr ); + m_xLbLineStyles->set_active(*pPosDashLb); + } + // so that a possibly existing line style is discarded + SelectLinestyleHdl_Impl( nullptr ); - // determining (and possibly cutting) the name - // and displaying it in the GroupBox + // determining (and possibly cutting) the name + // and displaying it in the GroupBox // OUString aString( CuiResId( RID_SVXSTR_TABLE ) ); // aString += ": "; - INetURLObject aURL( pDashList->GetPath() ); + INetURLObject aURL( pDashList->GetPath() ); - aURL.Append( pDashList->GetName() ); - DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); + aURL.Append( pDashList->GetName() ); + DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); - *pPageType = PageType::Area; // 2 - *pPosDashLb = -1; - } - } + *pPageType = PageType::Area; // 2 + *pPosDashLb = -1; } @@ -307,31 +307,31 @@ IMPL_LINK(SvxLineDefTabPage, SelectLinestyleListBoxHdl_Impl, weld::ComboBox&, rL void SvxLineDefTabPage::SelectLinestyleHdl_Impl(const weld::ComboBox* p) { - if(pDashList->Count()) + if(!pDashList->Count()) + return; + + int nTmp = m_xLbLineStyles->get_active(); + if (nTmp == -1) { - int nTmp = m_xLbLineStyles->get_active(); - if (nTmp == -1) - { - OSL_ENSURE(false, "OOps, non-existent LineDash selected (!)"); - nTmp = 1; - } + OSL_ENSURE(false, "OOps, non-existent LineDash selected (!)"); + nTmp = 1; + } - aDash = pDashList->GetDash( nTmp )->GetDash(); + aDash = pDashList->GetDash( nTmp )->GetDash(); - FillDialog_Impl(); + FillDialog_Impl(); - rXLSet.Put( XLineDashItem( OUString(), aDash ) ); + rXLSet.Put( XLineDashItem( OUString(), aDash ) ); - // #i34740# - m_aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); - m_aCtlPreview.Invalidate(); + // #i34740# + m_aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); + m_aCtlPreview.Invalidate(); - // Is not set before, in order to take the new style - // only if there was an entry selected in the ListBox. - // If it was called via Reset(), then p is == NULL - if( p ) - *pPageType = PageType::Hatch; - } + // Is not set before, in order to take the new style + // only if there was an entry selected in the ListBox. + // If it was called via Reset(), then p is == NULL + if( p ) + *pPageType = PageType::Hatch; } IMPL_LINK_NOARG(SvxLineDefTabPage, ChangePreviewHdl_Impl, weld::MetricSpinButton&, void) @@ -565,59 +565,59 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickAddHdl_Impl, weld::Button&, void) IMPL_LINK_NOARG(SvxLineDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) { int nPos = m_xLbLineStyles->get_active(); - if (nPos != -1) - { - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINESTYLE)); - OUString aName( pDashList->GetDash( nPos )->GetName() ); - OUString aOldName = aName; + if (nPos == -1) + return; - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); + OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINESTYLE)); + OUString aName( pDashList->GetDash( nPos )->GetName() ); + OUString aOldName = aName; - long nCount = pDashList->Count(); - bool bLoop = true; + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); - while ( bLoop && pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - bool bDifferent = true; + long nCount = pDashList->Count(); + bool bLoop = true; - for( long i = 0; i < nCount && bDifferent; i++ ) - { - if( aName == pDashList->GetDash( i )->GetName() && - aName != aOldName ) - bDifferent = false; - } + while ( bLoop && pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aName ); + bool bDifferent = true; - if ( bDifferent ) - { - bLoop = false; - FillDash_Impl(); + for( long i = 0; i < nCount && bDifferent; i++ ) + { + if( aName == pDashList->GetDash( i )->GetName() && + aName != aOldName ) + bDifferent = false; + } - pDashList->Replace(std::make_unique(aDash, aName), nPos); - m_xLbLineStyles->Modify(*pDashList->GetDash(nPos), nPos, pDashList->GetUiBitmap(nPos)); + if ( bDifferent ) + { + bLoop = false; + FillDash_Impl(); - m_xLbLineStyles->set_active(nPos); + pDashList->Replace(std::make_unique(aDash, aName), nPos); + m_xLbLineStyles->Modify(*pDashList->GetDash(nPos), nPos, pDashList->GetUiBitmap(nPos)); - *pnDashListState |= ChangeType::MODIFIED; + m_xLbLineStyles->set_active(nPos); - *pPageType = PageType::Hatch; + *pnDashListState |= ChangeType::MODIFIED; - // save values for changes recognition (-> method) - m_xNumFldNumber1->save_value(); - m_xMtrLength1->save_value(); - m_xLbType1->save_value(); - m_xNumFldNumber2->save_value(); - m_xMtrLength2->save_value(); - m_xLbType2->save_value(); - m_xMtrDistance->save_value(); - } - else - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); - std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); - xBox->run(); - } + *pPageType = PageType::Hatch; + + // save values for changes recognition (-> method) + m_xNumFldNumber1->save_value(); + m_xMtrLength1->save_value(); + m_xLbType1->save_value(); + m_xNumFldNumber2->save_value(); + m_xMtrLength2->save_value(); + m_xLbType2->save_value(); + m_xMtrDistance->save_value(); + } + else + { + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); + xBox->run(); } } } @@ -762,27 +762,27 @@ IMPL_LINK_NOARG(SvxLineDefTabPage, ClickSaveHdl_Impl, weld::Button&, void) } aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - if ( aDlg.Execute() == ERRCODE_NONE ) - { - INetURLObject aURL( aDlg.GetPath() ); - INetURLObject aPathURL( aURL ); + if ( aDlg.Execute() != ERRCODE_NONE ) + return; - aPathURL.removeSegment(); - aPathURL.removeFinalSlash(); + INetURLObject aURL( aDlg.GetPath() ); + INetURLObject aPathURL( aURL ); - pDashList->SetName( aURL.getName() ); - pDashList->SetPath( aPathURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + aPathURL.removeSegment(); + aPathURL.removeFinalSlash(); - if( pDashList->Save() ) - { - *pnDashListState &= ~ChangeType::MODIFIED; - } - else - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querynosavefiledialog.ui")); - std::unique_ptr xBox(xBuilder->weld_message_dialog("NoSaveFileDialog")); - xBox->run(); - } + pDashList->SetName( aURL.getName() ); + pDashList->SetPath( aPathURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + + if( pDashList->Save() ) + { + *pnDashListState &= ~ChangeType::MODIFIED; + } + else + { + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querynosavefiledialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("NoSaveFileDialog")); + xBox->run(); } } diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx index d537b7ea1ac9..a9db979bcda5 100644 --- a/cui/source/tabpages/tplneend.cxx +++ b/cui/source/tabpages/tplneend.cxx @@ -121,24 +121,24 @@ void SvxLineEndDefTabPage::Construct() void SvxLineEndDefTabPage::ActivatePage( const SfxItemSet& ) { - if( nDlgType == 0 ) // area dialog - { - // ActivatePage() is called before the dialog receives PageCreated() !!! - if( pLineEndList.is() ) - { - if( *pPosLineEndLb != -1) - { - m_xLbLineEnds->set_active(*pPosLineEndLb); - SelectLineEndHdl_Impl(); - } - INetURLObject aURL( pLineEndList->GetPath() ); + if( nDlgType != 0 ) // area dialog + return; - aURL.Append( pLineEndList->GetName() ); - DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); - *pPageType = PageType::Area; // 3 - *pPosLineEndLb = -1; - } + // ActivatePage() is called before the dialog receives PageCreated() !!! + if( !pLineEndList.is() ) + return; + + if( *pPosLineEndLb != -1) + { + m_xLbLineEnds->set_active(*pPosLineEndLb); + SelectLineEndHdl_Impl(); } + INetURLObject aURL( pLineEndList->GetPath() ); + + aURL.Append( pLineEndList->GetName() ); + DBG_ASSERT( aURL.GetProtocol() != INetProtocol::NotValid, "invalid URL" ); + *pPageType = PageType::Area; // 3 + *pPosLineEndLb = -1; } @@ -237,25 +237,25 @@ std::unique_ptr SvxLineEndDefTabPage::Create(weld::Container* pPage, void SvxLineEndDefTabPage::SelectLineEndHdl_Impl() { - if( pLineEndList->Count() > 0 ) - { - int nPos = m_xLbLineEnds->get_active(); + if( pLineEndList->Count() <= 0 ) + return; - const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos); + int nPos = m_xLbLineEnds->get_active(); - m_xEdtName->set_text(m_xLbLineEnds->get_active_text()); + const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nPos); - rXLSet.Put( XLineStartItem( OUString(), pEntry->GetLineEnd() ) ); - rXLSet.Put( XLineEndItem( OUString(), pEntry->GetLineEnd() ) ); + m_xEdtName->set_text(m_xLbLineEnds->get_active_text()); - // #i34740# - m_aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); - m_aCtlPreview.Invalidate(); + rXLSet.Put( XLineStartItem( OUString(), pEntry->GetLineEnd() ) ); + rXLSet.Put( XLineEndItem( OUString(), pEntry->GetLineEnd() ) ); - // Is not set before, in order to only take the new style, - // if there is an entry selected in the ListBox - *pPageType = PageType::Bitmap; - } + // #i34740# + m_aCtlPreview.SetLineAttributes(aXLineAttr.GetItemSet()); + m_aCtlPreview.Invalidate(); + + // Is not set before, in order to only take the new style, + // if there is an entry selected in the ListBox + *pPageType = PageType::Bitmap; } IMPL_LINK_NOARG(SvxLineEndDefTabPage, SelectLineEndHdl_Impl, weld::ComboBox&, void) @@ -266,72 +266,72 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, SelectLineEndHdl_Impl, weld::ComboBox&, vo IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickModifyHdl_Impl, weld::Button&, void) { int nPos = m_xLbLineEnds->get_active(); - if (nPos != -1) + if (nPos == -1) + return; + + OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND)); + OUString aName(m_xEdtName->get_text()); + long nCount = pLineEndList->Count(); + bool bDifferent = true; + + // check whether the name is existing already + for ( long i = 0; i < nCount && bDifferent; i++ ) + if ( aName == pLineEndList->GetLineEnd( i )->GetName() ) + bDifferent = false; + + // if yes, repeat and demand a new name + if ( !bDifferent ) { - OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND)); - OUString aName(m_xEdtName->get_text()); - long nCount = pLineEndList->Count(); - bool bDifferent = true; + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); + std::unique_ptr xWarningBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); + xWarningBox->run(); - // check whether the name is existing already - for ( long i = 0; i < nCount && bDifferent; i++ ) - if ( aName == pLineEndList->GetLineEnd( i )->GetName() ) - bDifferent = false; + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); + bool bLoop = true; - // if yes, repeat and demand a new name - if ( !bDifferent ) + while( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); - std::unique_ptr xWarningBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); - xWarningBox->run(); - - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); - bool bLoop = true; + pDlg->GetName( aName ); + bDifferent = true; - while( !bDifferent && bLoop && pDlg->Execute() == RET_OK ) + for( long i = 0; i < nCount && bDifferent; i++ ) { - pDlg->GetName( aName ); - bDifferent = true; - - for( long i = 0; i < nCount && bDifferent; i++ ) - { - if( aName == pLineEndList->GetLineEnd( i )->GetName() ) - bDifferent = false; - } - - if( bDifferent ) - bLoop = false; - else - xWarningBox->run(); + if( aName == pLineEndList->GetLineEnd( i )->GetName() ) + bDifferent = false; } + + if( bDifferent ) + bLoop = false; + else + xWarningBox->run(); } + } - // if not existing, enter the entry - if( bDifferent ) - { - const XLineEndEntry* pOldEntry = pLineEndList->GetLineEnd(nPos); + // if not existing, enter the entry + if( !bDifferent ) + return; - if(pOldEntry) - { - // #123497# Need to replace the existing entry with a new one - pLineEndList->Replace(std::make_unique(pOldEntry->GetLineEnd(), aName), nPos); + const XLineEndEntry* pOldEntry = pLineEndList->GetLineEnd(nPos); - m_xEdtName->set_text(aName); + if(pOldEntry) + { + // #123497# Need to replace the existing entry with a new one + pLineEndList->Replace(std::make_unique(pOldEntry->GetLineEnd(), aName), nPos); - m_xLbLineEnds->Modify(*pLineEndList->GetLineEnd(nPos), nPos, pLineEndList->GetUiBitmap(nPos)); - m_xLbLineEnds->set_active(nPos); + m_xEdtName->set_text(aName); - // set flag for modified - *pnLineEndListState |= ChangeType::MODIFIED; + m_xLbLineEnds->Modify(*pLineEndList->GetLineEnd(nPos), nPos, pLineEndList->GetUiBitmap(nPos)); + m_xLbLineEnds->set_active(nPos); - *pPageType = PageType::Bitmap; - } - else - { - OSL_ENSURE(false, "LineEnd to be modified not existing (!)"); - } - } + // set flag for modified + *pnLineEndListState |= ChangeType::MODIFIED; + + *pPageType = PageType::Bitmap; + } + else + { + OSL_ENSURE(false, "LineEnd to be modified not existing (!)"); } } @@ -582,27 +582,27 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickSaveHdl_Impl, weld::Button&, void) } aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); - if ( aDlg.Execute() == ERRCODE_NONE ) - { - INetURLObject aURL( aDlg.GetPath() ); - INetURLObject aPathURL( aURL ); + if ( aDlg.Execute() != ERRCODE_NONE ) + return; - aPathURL.removeSegment(); - aPathURL.removeFinalSlash(); + INetURLObject aURL( aDlg.GetPath() ); + INetURLObject aPathURL( aURL ); - pLineEndList->SetName( aURL.getName() ); - pLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + aPathURL.removeSegment(); + aPathURL.removeFinalSlash(); - if( pLineEndList->Save() ) - { - *pnLineEndListState &= ~ChangeType::MODIFIED; - } - else - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querynosavefiledialog.ui")); - std::unique_ptr xBox(xBuilder->weld_message_dialog("NoSaveFileDialog")); - xBox->run(); - } + pLineEndList->SetName( aURL.getName() ); + pLineEndList->SetPath( aPathURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + + if( pLineEndList->Save() ) + { + *pnLineEndListState &= ~ChangeType::MODIFIED; + } + else + { + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/querynosavefiledialog.ui")); + std::unique_ptr xBox(xBuilder->weld_message_dialog("NoSaveFileDialog")); + xBox->run(); } } diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx index cd223ed9284c..613508b64a79 100644 --- a/cui/source/tabpages/tppattern.cxx +++ b/cui/source/tabpages/tppattern.cxx @@ -128,47 +128,47 @@ void SvxPatternTabPage::Construct() void SvxPatternTabPage::ActivatePage( const SfxItemSet& rSet ) { - if( m_pColorList.is() ) + if( !m_pColorList.is() ) + return; + + // ColorList + if( *m_pnColorListState & ChangeType::CHANGED || + *m_pnColorListState & ChangeType::MODIFIED ) { - // ColorList - if( *m_pnColorListState & ChangeType::CHANGED || - *m_pnColorListState & ChangeType::MODIFIED ) - { - SvxAreaTabDialog* pArea = (*m_pnColorListState & ChangeType::CHANGED) ? - dynamic_cast(GetDialogController()) : nullptr; - if (pArea) - m_pColorList = pArea->GetNewColorList(); - } + SvxAreaTabDialog* pArea = (*m_pnColorListState & ChangeType::CHANGED) ? + dynamic_cast(GetDialogController()) : nullptr; + if (pArea) + m_pColorList = pArea->GetNewColorList(); + } - // determining (possibly cutting) the name and - // displaying it in the GroupBox - OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; - INetURLObject aURL( m_pPatternList->GetPath() ); + // determining (possibly cutting) the name and + // displaying it in the GroupBox + OUString aString = CuiResId( RID_SVXSTR_TABLE ) + ": "; + INetURLObject aURL( m_pPatternList->GetPath() ); - aURL.Append( m_pPatternList->GetName() ); - SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" ); + aURL.Append( m_pPatternList->GetName() ); + SAL_WARN_IF( aURL.GetProtocol() == INetProtocol::NotValid, "cui.tabpages", "invalid URL" ); - if( aURL.getBase().getLength() > 18 ) - { - aString += aURL.getBase().copy( 0, 15 ) + "..."; - } - else - aString += aURL.getBase(); + if( aURL.getBase().getLength() > 18 ) + { + aString += aURL.getBase().copy( 0, 15 ) + "..."; + } + else + aString += aURL.getBase(); - XFillBitmapItem aItem( rSet.Get( XATTR_FILLBITMAP ) ); + XFillBitmapItem aItem( rSet.Get( XATTR_FILLBITMAP ) ); - if ( aItem.isPattern() ) + if ( aItem.isPattern() ) + { + sal_Int32 nPos = SearchPatternList( aItem.GetName() ); + if ( nPos != -1) { - sal_Int32 nPos = SearchPatternList( aItem.GetName() ); - if ( nPos != -1) - { - sal_uInt16 nId = m_xPatternLB->GetItemId( static_cast( nPos ) ); - m_xPatternLB->SelectItem( nId ); - } + sal_uInt16 nId = m_xPatternLB->GetItemId( static_cast( nPos ) ); + m_xPatternLB->SelectItem( nId ); } - else - m_xPatternLB->SelectItem( m_xPatternLB->GetItemId( static_cast( 0 ) ) ); } + else + m_xPatternLB->SelectItem( m_xPatternLB->GetItemId( static_cast( 0 ) ) ); } @@ -272,47 +272,47 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, SvtValueSet*, void) } } - if(pGraphicObject) - { - Color aBackColor; - Color aPixelColor; - bool bIs8x8(vcl::bitmap::isHistorical8x8(pGraphicObject->GetGraphic().GetBitmapEx(), aBackColor, aPixelColor)); + if(!pGraphicObject) + return; - m_xLbColor->SetNoSelection(); - m_xLbBackgroundColor->SetNoSelection(); + Color aBackColor; + Color aPixelColor; + bool bIs8x8(vcl::bitmap::isHistorical8x8(pGraphicObject->GetGraphic().GetBitmapEx(), aBackColor, aPixelColor)); - if(bIs8x8) - { - m_xCtlPixel->SetPaintable( true ); - m_xBtnModify->set_sensitive(true); - m_xBtnAdd->set_sensitive(true); + m_xLbColor->SetNoSelection(); + m_xLbBackgroundColor->SetNoSelection(); - // setting the pixel control + if(bIs8x8) + { + m_xCtlPixel->SetPaintable( true ); + m_xBtnModify->set_sensitive(true); + m_xBtnAdd->set_sensitive(true); - m_xCtlPixel->SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx()); + // setting the pixel control - m_xLbColor->SelectEntry( aPixelColor ); - m_xLbBackgroundColor->SelectEntry( aBackColor ); + m_xCtlPixel->SetXBitmap(pGraphicObject->GetGraphic().GetBitmapEx()); - // update m_xBitmapCtl, rXFSet and m_aCtlPreview - m_xBitmapCtl->SetPixelColor( aPixelColor ); - m_xBitmapCtl->SetBackgroundColor( aBackColor ); - m_rXFSet.ClearItem(); - m_rXFSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP)); - m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_xBitmapCtl->GetBitmapEx()))); - m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() ); - m_aCtlPreview.Invalidate(); - } - else - { - m_xCtlPixel->Reset(); - m_xCtlPixel->SetPaintable( false ); - m_xBtnModify->set_sensitive(false); - m_xBtnAdd->set_sensitive(false); - } + m_xLbColor->SelectEntry( aPixelColor ); + m_xLbBackgroundColor->SelectEntry( aBackColor ); - m_xCtlPixel->Invalidate(); + // update m_xBitmapCtl, rXFSet and m_aCtlPreview + m_xBitmapCtl->SetPixelColor( aPixelColor ); + m_xBitmapCtl->SetBackgroundColor( aBackColor ); + m_rXFSet.ClearItem(); + m_rXFSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP)); + m_rXFSet.Put(XFillBitmapItem(OUString(), Graphic(m_xBitmapCtl->GetBitmapEx()))); + m_aCtlPreview.SetAttributes( m_aXFillAttr.GetItemSet() ); + m_aCtlPreview.Invalidate(); } + else + { + m_xCtlPixel->Reset(); + m_xCtlPixel->SetPaintable( false ); + m_xBtnModify->set_sensitive(false); + m_xBtnAdd->set_sensitive(false); + } + + m_xCtlPixel->Invalidate(); } IMPL_LINK_NOARG(SvxPatternTabPage, ClickAddHdl_Impl, weld::Button&, void) @@ -405,22 +405,22 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickModifyHdl_Impl, weld::Button&, void) sal_uInt16 nId = m_xPatternLB->GetSelectedItemId(); size_t nPos = m_xPatternLB->GetSelectItemPos(); - if ( nPos != VALUESET_ITEM_NOTFOUND ) - { - OUString aName( m_pPatternList->GetBitmap( static_cast(nPos) )->GetName() ); + if ( nPos == VALUESET_ITEM_NOTFOUND ) + return; - const BitmapEx aBitmapEx(m_xBitmapCtl->GetBitmapEx()); + OUString aName( m_pPatternList->GetBitmap( static_cast(nPos) )->GetName() ); - // #i123497# Need to replace the existing entry with a new one (old returned needs to be deleted) - m_pPatternList->Replace(std::make_unique(Graphic(aBitmapEx), aName), nPos); + const BitmapEx aBitmapEx(m_xBitmapCtl->GetBitmapEx()); - BitmapEx aBitmap = m_pPatternList->GetBitmapForPreview( static_cast( nPos ), m_xPatternLB->GetIconSize() ); - m_xPatternLB->RemoveItem(nId); - m_xPatternLB->InsertItem( nId, Image(aBitmap), aName, static_cast(nPos) ); - m_xPatternLB->SelectItem( nId ); + // #i123497# Need to replace the existing entry with a new one (old returned needs to be deleted) + m_pPatternList->Replace(std::make_unique(Graphic(aBitmapEx), aName), nPos); - *m_pnPatternListState |= ChangeType::MODIFIED; - } + BitmapEx aBitmap = m_pPatternList->GetBitmapForPreview( static_cast( nPos ), m_xPatternLB->GetIconSize() ); + m_xPatternLB->RemoveItem(nId); + m_xPatternLB->InsertItem( nId, Image(aBitmap), aName, static_cast(nPos) ); + m_xPatternLB->SelectItem( nId ); + + *m_pnPatternListState |= ChangeType::MODIFIED; } @@ -429,39 +429,39 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ClickRenameHdl_Impl, SvxPresetListBox*, void) size_t nPos = m_xPatternLB->GetSelectItemPos(); sal_Int32 nId = m_xPatternLB->GetSelectedItemId(); - if ( nPos != VALUESET_ITEM_NOTFOUND ) - { - OUString aDesc(CuiResId(RID_SVXSTR_DESC_NEW_PATTERN)); - OUString aName(m_pPatternList->GetBitmap(nPos)->GetName()); + if ( nPos == VALUESET_ITEM_NOTFOUND ) + return; - SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); + OUString aDesc(CuiResId(RID_SVXSTR_DESC_NEW_PATTERN)); + OUString aName(m_pPatternList->GetBitmap(nPos)->GetName()); - bool bLoop = true; + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ScopedVclPtr pDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aName, aDesc)); - while( bLoop && pDlg->Execute() == RET_OK ) - { - pDlg->GetName( aName ); - sal_Int32 nPatternPos = SearchPatternList(aName); - bool bValidPatternName = (nPatternPos == static_cast(nPos) ) || (nPatternPos == -1); + bool bLoop = true; - if( bValidPatternName ) - { - bLoop = false; + while( bLoop && pDlg->Execute() == RET_OK ) + { + pDlg->GetName( aName ); + sal_Int32 nPatternPos = SearchPatternList(aName); + bool bValidPatternName = (nPatternPos == static_cast(nPos) ) || (nPatternPos == -1); - m_pPatternList->GetBitmap(nPos)->SetName(aName); + if( bValidPatternName ) + { + bLoop = false; - m_xPatternLB->SetItemText( nId, aName ); - m_xPatternLB->SelectItem( nId ); + m_pPatternList->GetBitmap(nPos)->SetName(aName); - *m_pnPatternListState |= ChangeType::MODIFIED; - } - else - { - std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); - std::unique_ptr xWarnBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); - xWarnBox->run(); - } + m_xPatternLB->SetItemText( nId, aName ); + m_xPatternLB->SelectItem( nId ); + + *m_pnPatternListState |= ChangeType::MODIFIED; + } + else + { + std::unique_ptr xBuilder(Application::CreateBuilder(GetFrameWeld(), "cui/ui/queryduplicatedialog.ui")); + std::unique_ptr xWarnBox(xBuilder->weld_message_dialog("DuplicateNameDialog")); + xWarnBox->run(); } } } diff --git a/cui/source/tabpages/tpshadow.cxx b/cui/source/tabpages/tpshadow.cxx index 1c8c5051d0b9..de448b197fd4 100644 --- a/cui/source/tabpages/tpshadow.cxx +++ b/cui/source/tabpages/tpshadow.cxx @@ -168,42 +168,42 @@ void SvxShadowTabPage::ActivatePage( const SfxItemSet& rSet ) if (pPageTypeItem) SetPageType(static_cast(pPageTypeItem->GetValue())); - if( m_nDlgType == 0 ) + if( m_nDlgType != 0 ) + return; + + if( !m_pColorList.is() ) + return; + + // ColorList + if( *m_pnColorListState & ChangeType::CHANGED || + *m_pnColorListState & ChangeType::MODIFIED ) { - if( m_pColorList.is() ) + if( *m_pnColorListState & ChangeType::CHANGED ) { - // ColorList - if( *m_pnColorListState & ChangeType::CHANGED || - *m_pnColorListState & ChangeType::MODIFIED ) + SvxAreaTabDialog* pArea = dynamic_cast(GetDialogController()); + if( pArea ) { - if( *m_pnColorListState & ChangeType::CHANGED ) - { - SvxAreaTabDialog* pArea = dynamic_cast(GetDialogController()); - if( pArea ) - { - m_pColorList = pArea->GetNewColorList(); - } - else - { - SvxLineTabDialog* pLine = dynamic_cast(GetDialogController()); - if( pLine ) - m_pColorList = pLine->GetNewColorList(); - } - } - - SfxItemSet rAttribs( rSet ); - // rSet contains shadow attributes too, but we want - // to use it for updating rectangle attributes only, - // so set the shadow to none here - SdrOnOffItem aItem( makeSdrShadowItem( false )); - rAttribs.Put( aItem ); - - m_aCtlXRectPreview.SetRectangleAttributes( rAttribs ); - ModifyShadowHdl_Impl( *m_xMtrTransparent ); + m_pColorList = pArea->GetNewColorList(); + } + else + { + SvxLineTabDialog* pLine = dynamic_cast(GetDialogController()); + if( pLine ) + m_pColorList = pLine->GetNewColorList(); } - m_nPageType = PageType::Shadow; } + + SfxItemSet rAttribs( rSet ); + // rSet contains shadow attributes too, but we want + // to use it for updating rectangle attributes only, + // so set the shadow to none here + SdrOnOffItem aItem( makeSdrShadowItem( false )); + rAttribs.Put( aItem ); + + m_aCtlXRectPreview.SetRectangleAttributes( rAttribs ); + ModifyShadowHdl_Impl( *m_xMtrTransparent ); } + m_nPageType = PageType::Shadow; } diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index 612410ac94e6..77c3b7e7e8d2 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -328,64 +328,64 @@ DeactivateRC SvxAngleTabPage::DeactivatePage( SfxItemSet* _pSet ) void SvxAngleTabPage::PointChanged(weld::DrawingArea* pDrawingArea, RectPoint eRP) { - if (pDrawingArea == m_aCtlRect.GetDrawingArea()) + if (pDrawingArea != m_aCtlRect.GetDrawingArea()) + return; + + switch(eRP) { - switch(eRP) + case RectPoint::LT: { - case RectPoint::LT: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FieldUnit::NONE ); - break; - } - case RectPoint::MT: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FieldUnit::NONE ); - break; - } - case RectPoint::RT: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FieldUnit::NONE ); - break; - } - case RectPoint::LM: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FieldUnit::NONE ); - break; - } - case RectPoint::MM: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FieldUnit::NONE ); - break; - } - case RectPoint::RM: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FieldUnit::NONE ); - break; - } - case RectPoint::LB: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FieldUnit::NONE ); - break; - } - case RectPoint::MB: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FieldUnit::NONE ); - break; - } - case RectPoint::RB: - { - m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FieldUnit::NONE ); - m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FieldUnit::NONE ); - break; - } + m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FieldUnit::NONE ); + break; + } + case RectPoint::MT: + { + m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FieldUnit::NONE ); + break; + } + case RectPoint::RT: + { + m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getMinY()), FieldUnit::NONE ); + break; + } + case RectPoint::LM: + { + m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FieldUnit::NONE ); + break; + } + case RectPoint::MM: + { + m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FieldUnit::NONE ); + break; + } + case RectPoint::RM: + { + m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getCenter().getY()), FieldUnit::NONE ); + break; + } + case RectPoint::LB: + { + m_xMtrPosX->set_value( basegfx::fround64(maRange.getMinX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FieldUnit::NONE ); + break; + } + case RectPoint::MB: + { + m_xMtrPosX->set_value( basegfx::fround64(maRange.getCenter().getX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FieldUnit::NONE ); + break; + } + case RectPoint::RB: + { + m_xMtrPosX->set_value( basegfx::fround64(maRange.getMaxX()), FieldUnit::NONE ); + m_xMtrPosY->set_value( basegfx::fround64(maRange.getMaxY()), FieldUnit::NONE ); + break; } } } @@ -1516,47 +1516,47 @@ void SvxPositionSizeTabPage::DisableProtect() IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeWidthHdl, weld::MetricSpinButton&, void) { - if( m_xCbxScale->get_active() && m_xCbxScale->get_sensitive() ) - { - sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast(m_xMtrWidth->get_value(FieldUnit::NONE))) / mfOldWidth)); - int nMin, nMax; - m_xMtrHeight->get_range(nMin, nMax, FieldUnit::NONE); + if( !(m_xCbxScale->get_active() && m_xCbxScale->get_sensitive()) ) + return; - if (nHeight <= nMax) - { - m_xMtrHeight->set_value(nHeight, FieldUnit::NONE); - } - else - { - nHeight = nMax; - m_xMtrHeight->set_value(nHeight, FieldUnit::NONE); + sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast(m_xMtrWidth->get_value(FieldUnit::NONE))) / mfOldWidth)); + int nMin, nMax; + m_xMtrHeight->get_range(nMin, nMax, FieldUnit::NONE); - const sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast(nHeight)) / mfOldHeight)); - m_xMtrWidth->set_value(nWidth, FieldUnit::NONE); - } + if (nHeight <= nMax) + { + m_xMtrHeight->set_value(nHeight, FieldUnit::NONE); + } + else + { + nHeight = nMax; + m_xMtrHeight->set_value(nHeight, FieldUnit::NONE); + + const sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast(nHeight)) / mfOldHeight)); + m_xMtrWidth->set_value(nWidth, FieldUnit::NONE); } } IMPL_LINK_NOARG(SvxPositionSizeTabPage, ChangeHeightHdl, weld::MetricSpinButton&, void) { - if( m_xCbxScale->get_active() && m_xCbxScale->get_sensitive() ) - { - sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast(m_xMtrHeight->get_value(FieldUnit::NONE))) / mfOldHeight)); - int nMin, nMax; - m_xMtrWidth->get_range(nMin, nMax, FieldUnit::NONE); + if( !(m_xCbxScale->get_active() && m_xCbxScale->get_sensitive()) ) + return; - if (nWidth <= nMax) - { - m_xMtrWidth->set_value(nWidth, FieldUnit::NONE); - } - else - { - nWidth = nMax; - m_xMtrWidth->set_value(nWidth, FieldUnit::NONE); + sal_Int64 nWidth(basegfx::fround64((mfOldWidth * static_cast(m_xMtrHeight->get_value(FieldUnit::NONE))) / mfOldHeight)); + int nMin, nMax; + m_xMtrWidth->get_range(nMin, nMax, FieldUnit::NONE); - const sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast(nWidth)) / mfOldWidth)); - m_xMtrHeight->set_value(nHeight, FieldUnit::NONE); - } + if (nWidth <= nMax) + { + m_xMtrWidth->set_value(nWidth, FieldUnit::NONE); + } + else + { + nWidth = nMax; + m_xMtrWidth->set_value(nWidth, FieldUnit::NONE); + + const sal_Int64 nHeight(basegfx::fround64((mfOldHeight * static_cast(nWidth)) / mfOldWidth)); + m_xMtrHeight->set_value(nHeight, FieldUnit::NONE); } } -- cgit