diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 10:40:17 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-30 16:33:21 +0200 |
commit | 978f6bb752112cd5393c294aa751e9e567980399 (patch) | |
tree | ce6ecbdce221f9b990fa665418862f3c1411407a | |
parent | 069c534f1da3b206f4e418e0a628a3482cd4a04a (diff) |
loplugin:flatten in sw/uibase/dbui..sw/uibase/envelp
Change-Id: I20dc75b75e999ed82d221072d6ecaf2c02c834eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99793
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 244 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbtree.cxx | 52 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mmconfigitem.cxx | 36 | ||||
-rw-r--r-- | sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx | 80 | ||||
-rw-r--r-- | sw/source/uibase/dialog/watermarkdialog.cxx | 30 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 100 | ||||
-rw-r--r-- | sw/source/uibase/docvw/AnchorOverlayObject.cxx | 28 | ||||
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin2.cxx | 112 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 160 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarTxtControl.cxx | 36 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarWinAcc.cxx | 20 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtdd.cxx | 102 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 82 | ||||
-rw-r--r-- | sw/source/uibase/envelp/envimg.cxx | 90 |
15 files changed, 599 insertions, 599 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 86e31fc27501..b876dec35b5f 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -321,22 +321,22 @@ static void lcl_InitNumberFormatter(SwDSParam& rParam, uno::Reference<sdbc::XDat : SwDBManager::getDataSourceAsParent( rParam.xConnection, rParam.sDataSource)), uno::UNO_QUERY); - if(xSourceProps.is()) + if(!xSourceProps.is()) + return; + + uno::Any aFormats = xSourceProps->getPropertyValue("NumberFormatsSupplier"); + if(!aFormats.hasValue()) + return; + + uno::Reference<util::XNumberFormatsSupplier> xSuppl; + aFormats >>= xSuppl; + if(xSuppl.is()) { - uno::Any aFormats = xSourceProps->getPropertyValue("NumberFormatsSupplier"); - if(aFormats.hasValue()) - { - uno::Reference<util::XNumberFormatsSupplier> xSuppl; - aFormats >>= xSuppl; - if(xSuppl.is()) - { - uno::Reference< beans::XPropertySet > xSettings = xSuppl->getNumberFormatSettings(); - uno::Any aNull = xSettings->getPropertyValue("NullDate"); - aNull >>= rParam.aNullDate; - if(rParam.xFormatter.is()) - rParam.xFormatter->attachNumberFormatsSupplier(xSuppl); - } - } + uno::Reference< beans::XPropertySet > xSettings = xSuppl->getNumberFormatSettings(); + uno::Any aNull = xSettings->getPropertyValue("NullDate"); + aNull >>= rParam.aNullDate; + if(rParam.xFormatter.is()) + rParam.xFormatter->attachNumberFormatsSupplier(xSuppl); } } @@ -566,33 +566,33 @@ bool SwDBManager::Merge( const SwMergeDescriptor& rMergeDesc ) void SwDBManager::ImportFromConnection( SwWrtShell* pSh ) { - if(m_pImpl->pMergeData && !m_pImpl->pMergeData->bEndOfDB) - { - pSh->StartAllAction(); - pSh->StartUndo(); - bool bGroupUndo(pSh->DoesGroupUndo()); - pSh->DoGroupUndo(false); + if(!(m_pImpl->pMergeData && !m_pImpl->pMergeData->bEndOfDB)) + return; - if( pSh->HasSelection() ) - pSh->DelRight(); + pSh->StartAllAction(); + pSh->StartUndo(); + bool bGroupUndo(pSh->DoesGroupUndo()); + pSh->DoGroupUndo(false); - std::unique_ptr<SwWait> pWait; + if( pSh->HasSelection() ) + pSh->DelRight(); - { - sal_uLong i = 0; - do { + std::unique_ptr<SwWait> pWait; - ImportDBEntry(pSh); - if( 10 == ++i ) - pWait.reset(new SwWait( *pSh->GetView().GetDocShell(), true)); + { + sal_uLong i = 0; + do { - } while(ToNextMergeRecord()); - } + ImportDBEntry(pSh); + if( 10 == ++i ) + pWait.reset(new SwWait( *pSh->GetView().GetDocShell(), true)); - pSh->DoGroupUndo(bGroupUndo); - pSh->EndUndo(); - pSh->EndAllAction(); + } while(ToNextMergeRecord()); } + + pSh->DoGroupUndo(bGroupUndo); + pSh->EndUndo(); + pSh->EndAllAction(); } static OUString lcl_FindColumn(const OUString& sFormatStr,sal_uInt16 &nUsedPos, sal_uInt8 &nSeparator) @@ -628,69 +628,69 @@ static OUString lcl_FindColumn(const OUString& sFormatStr,sal_uInt16 &nUsedPos void SwDBManager::ImportDBEntry(SwWrtShell* pSh) { - if(m_pImpl->pMergeData && !m_pImpl->pMergeData->bEndOfDB) - { - uno::Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pImpl->pMergeData->xResultSet, uno::UNO_QUERY ); - uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns(); - OUString sFormatStr; - sal_uInt16 nFormatLen = sFormatStr.getLength(); - if( nFormatLen ) - { - const char cSpace = ' '; - const char cTab = '\t'; - sal_uInt16 nUsedPos = 0; - sal_uInt8 nSeparator; - OUString sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator); - while( !sColumn.isEmpty() ) + if(!(m_pImpl->pMergeData && !m_pImpl->pMergeData->bEndOfDB)) + return; + + uno::Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pImpl->pMergeData->xResultSet, uno::UNO_QUERY ); + uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns(); + OUString sFormatStr; + sal_uInt16 nFormatLen = sFormatStr.getLength(); + if( nFormatLen ) + { + const char cSpace = ' '; + const char cTab = '\t'; + sal_uInt16 nUsedPos = 0; + sal_uInt8 nSeparator; + OUString sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator); + while( !sColumn.isEmpty() ) + { + if(!xCols->hasByName(sColumn)) + return; + uno::Any aCol = xCols->getByName(sColumn); + uno::Reference< beans::XPropertySet > xColumnProp; + aCol >>= xColumnProp; + if(xColumnProp.is()) { - if(!xCols->hasByName(sColumn)) - return; - uno::Any aCol = xCols->getByName(sColumn); - uno::Reference< beans::XPropertySet > xColumnProp; - aCol >>= xColumnProp; - if(xColumnProp.is()) - { - SwDBFormatData aDBFormat; - OUString sInsert = GetDBField( xColumnProp, aDBFormat); - if( DB_SEP_SPACE == nSeparator ) - sInsert += OUStringChar(cSpace); - else if( DB_SEP_TAB == nSeparator) - sInsert += OUStringChar(cTab); - pSh->Insert(sInsert); - if( DB_SEP_RETURN == nSeparator) - pSh->SplitNode(); - else if(DB_SEP_NEWLINE == nSeparator) - pSh->InsertLineBreak(); - } - else - { - // column not found -> show error - OUString sInsert = "?" + sColumn + "?"; - pSh->Insert(sInsert); - } - sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator); + SwDBFormatData aDBFormat; + OUString sInsert = GetDBField( xColumnProp, aDBFormat); + if( DB_SEP_SPACE == nSeparator ) + sInsert += OUStringChar(cSpace); + else if( DB_SEP_TAB == nSeparator) + sInsert += OUStringChar(cTab); + pSh->Insert(sInsert); + if( DB_SEP_RETURN == nSeparator) + pSh->SplitNode(); + else if(DB_SEP_NEWLINE == nSeparator) + pSh->InsertLineBreak(); } - pSh->SplitNode(); - } - else - { - OUStringBuffer sStr; - uno::Sequence<OUString> aColNames = xCols->getElementNames(); - const OUString* pColNames = aColNames.getConstArray(); - long nLength = aColNames.getLength(); - for(long i = 0; i < nLength; i++) + else { - uno::Any aCol = xCols->getByName(pColNames[i]); - uno::Reference< beans::XPropertySet > xColumnProp; - aCol >>= xColumnProp; - SwDBFormatData aDBFormat; - sStr.append(GetDBField( xColumnProp, aDBFormat)); - if (i < nLength - 1) - sStr.append("\t"); + // column not found -> show error + OUString sInsert = "?" + sColumn + "?"; + pSh->Insert(sInsert); } - pSh->SwEditShell::Insert2(sStr.makeStringAndClear()); - pSh->SwFEShell::SplitNode(); // line feed + sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator); + } + pSh->SplitNode(); + } + else + { + OUStringBuffer sStr; + uno::Sequence<OUString> aColNames = xCols->getElementNames(); + const OUString* pColNames = aColNames.getConstArray(); + long nLength = aColNames.getLength(); + for(long i = 0; i < nLength; i++) + { + uno::Any aCol = xCols->getByName(pColNames[i]); + uno::Reference< beans::XPropertySet > xColumnProp; + aCol >>= xColumnProp; + SwDBFormatData aDBFormat; + sStr.append(GetDBField( xColumnProp, aDBFormat)); + if (i < nLength - 1) + sStr.append("\t"); } + pSh->SwEditShell::Insert2(sStr.makeStringAndClear()); + pSh->SwFEShell::SplitNode(); // line feed } } @@ -3143,19 +3143,19 @@ void SwDBManager::InsertText(SwWrtShell& rSh, xSource, xColSupp, aDBData )); - if( RET_OK == pDlg->Execute() ) + if( RET_OK != pDlg->Execute() ) + return; + + OUString sDummy; + if(!xConnection.is()) + xConnection = xSource->getConnection(sDummy, sDummy); + try { - OUString sDummy; - if(!xConnection.is()) - xConnection = xSource->getConnection(sDummy, sDummy); - try - { - pDlg->DataToDoc( aSelection , xSource, xConnection, xResSet); - } - catch (const uno::Exception&) - { - TOOLS_WARN_EXCEPTION("sw.mailmerge", ""); - } + pDlg->DataToDoc( aSelection , xSource, xConnection, xResSet); + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("sw.mailmerge", ""); } } @@ -3308,29 +3308,29 @@ std::shared_ptr<SwMailMergeConfigItem> SwDBManager::PerformMailMerge(SwView cons void SwDBManager::RevokeLastRegistrations() { - if (!m_aUncommittedRegistrations.empty()) + if (m_aUncommittedRegistrations.empty()) + return; + + SwView* pView = ( m_pDoc && m_pDoc->GetDocShell() ) ? m_pDoc->GetDocShell()->GetView() : nullptr; + if (pView) { - SwView* pView = ( m_pDoc && m_pDoc->GetDocShell() ) ? m_pDoc->GetDocShell()->GetView() : nullptr; - if (pView) + const std::shared_ptr<SwMailMergeConfigItem>& xConfigItem = pView->GetMailMergeConfigItem(); + if (xConfigItem) { - const std::shared_ptr<SwMailMergeConfigItem>& xConfigItem = pView->GetMailMergeConfigItem(); - if (xConfigItem) - { - xConfigItem->DisposeResultSet(); - xConfigItem->DocumentReloaded(); - } + xConfigItem->DisposeResultSet(); + xConfigItem->DocumentReloaded(); } + } - for (auto it = m_aUncommittedRegistrations.begin(); it != m_aUncommittedRegistrations.end();) + for (auto it = m_aUncommittedRegistrations.begin(); it != m_aUncommittedRegistrations.end();) + { + if ((m_pDoc && it->first == m_pDoc->GetDocShell()) || it->first == nullptr) { - if ((m_pDoc && it->first == m_pDoc->GetDocShell()) || it->first == nullptr) - { - RevokeDataSource(it->second); - it = m_aUncommittedRegistrations.erase(it); - } - else - ++it; + RevokeDataSource(it->second); + it = m_aUncommittedRegistrations.erase(it); } + else + ++it; } } diff --git a/sw/source/uibase/dbui/dbtree.cxx b/sw/source/uibase/dbui/dbtree.cxx index 4b57f8a107b5..4dee21a4ed0c 100644 --- a/sw/source/uibase/dbui/dbtree.cxx +++ b/sw/source/uibase/dbui/dbtree.cxx @@ -399,38 +399,38 @@ namespace void SwDBTreeList::ShowColumns(bool bShowCol) { - if (bShowCol != bShowColumns) - { - bShowColumns = bShowCol; - OUString sTableName; - OUString sColumnName; - const OUString sDBName(GetDBName(sTableName, sColumnName)); + if (bShowCol == bShowColumns) + return; - m_xTreeView->freeze(); + bShowColumns = bShowCol; + OUString sTableName; + OUString sColumnName; + const OUString sDBName(GetDBName(sTableName, sColumnName)); - std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator()); - std::unique_ptr<weld::TreeIter> xChild(m_xTreeView->make_iterator()); - if (m_xTreeView->get_iter_first(*xIter)) + m_xTreeView->freeze(); + + std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator()); + std::unique_ptr<weld::TreeIter> xChild(m_xTreeView->make_iterator()); + if (m_xTreeView->get_iter_first(*xIter)) + { + do { - do + GotoRootLevelParent(*m_xTreeView, *xIter); + m_xTreeView->collapse_row(*xIter); + while (m_xTreeView->iter_has_child(*xIter)) { - GotoRootLevelParent(*m_xTreeView, *xIter); - m_xTreeView->collapse_row(*xIter); - while (m_xTreeView->iter_has_child(*xIter)) - { - m_xTreeView->copy_iterator(*xIter, *xChild); - (void)m_xTreeView->iter_children(*xChild); - m_xTreeView->remove(*xChild); - } - } while (m_xTreeView->iter_next(*xIter)); - } + m_xTreeView->copy_iterator(*xIter, *xChild); + (void)m_xTreeView->iter_children(*xChild); + m_xTreeView->remove(*xChild); + } + } while (m_xTreeView->iter_next(*xIter)); + } - m_xTreeView->thaw(); + m_xTreeView->thaw(); - if (!sDBName.isEmpty()) - { - Select(sDBName, sTableName, sColumnName); // force RequestingChildren - } + if (!sDBName.isEmpty()) + { + Select(sDBName, sTableName, sColumnName); // force RequestingChildren } } diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx index 84cb6774253e..b40073d5ec56 100644 --- a/sw/source/uibase/dbui/mmconfigitem.cxx +++ b/sw/source/uibase/dbui/mmconfigitem.cxx @@ -901,25 +901,25 @@ OUString& SwMailMergeConfigItem::GetFilter() const void SwMailMergeConfigItem::SetFilter(OUString const & rFilter) { - if(m_pImpl->m_sFilter != rFilter) + if(m_pImpl->m_sFilter == rFilter) + return; + + m_pImpl->m_sFilter = rFilter; + m_pImpl->SetModified(); + Reference<XPropertySet> xRowProperties(m_pImpl->m_xResultSet, UNO_QUERY); + if(!xRowProperties.is()) + return; + + try { - m_pImpl->m_sFilter = rFilter; - m_pImpl->SetModified(); - Reference<XPropertySet> xRowProperties(m_pImpl->m_xResultSet, UNO_QUERY); - if(xRowProperties.is()) - { - try - { - xRowProperties->setPropertyValue("ApplyFilter", makeAny(!m_pImpl->m_sFilter.isEmpty())); - xRowProperties->setPropertyValue("Filter", makeAny(m_pImpl->m_sFilter)); - uno::Reference<XRowSet> xRowSet( m_pImpl->m_xResultSet, UNO_QUERY_THROW ); - xRowSet->execute(); - } - catch (const Exception&) - { - TOOLS_WARN_EXCEPTION("sw.ui", "SwMailMergeConfigItem::SetFilter()"); - } - } + xRowProperties->setPropertyValue("ApplyFilter", makeAny(!m_pImpl->m_sFilter.isEmpty())); + xRowProperties->setPropertyValue("Filter", makeAny(m_pImpl->m_sFilter)); + uno::Reference<XRowSet> xRowSet( m_pImpl->m_xResultSet, UNO_QUERY_THROW ); + xRowSet->execute(); + } + catch (const Exception&) + { + TOOLS_WARN_EXCEPTION("sw.ui", "SwMailMergeConfigItem::SetFilter()"); } } diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx index cd19c9a39492..217d04236ee7 100644 --- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx @@ -424,29 +424,29 @@ void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rC { SwWrtShell* pWrtShell = GetWrtShell_Impl(); OSL_ENSURE(!m_pSpellState->m_bInitialCall, "ApplyChangedSentence in initial call or after resume"); - if(pWrtShell && !m_pSpellState->m_bInitialCall) - { - ShellMode eSelMode = pWrtShell->GetView().GetShellMode(); - bool bDrawText = ShellMode::DrawText == eSelMode; - bool bNormalText = - ShellMode::TableText == eSelMode || - ShellMode::ListText == eSelMode || - ShellMode::TableListText == eSelMode || - ShellMode::Text == eSelMode; - - // evaluate if the same sentence should be rechecked or not. - // Sentences that got grammar checked should always be rechecked in order - // to detect possible errors that get introduced with the changes - bRecheck |= SwEditShell::HasLastSentenceGotGrammarChecked(); + if(!(pWrtShell && !m_pSpellState->m_bInitialCall)) + return; - if(bNormalText) - pWrtShell->ApplyChangedSentence(rChanged, bRecheck); - else if(bDrawText ) - { - SdrView* pDrView = pWrtShell->GetDrawView(); - SdrOutliner *pOutliner = pDrView->GetTextEditOutliner(); - pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, bRecheck); - } + ShellMode eSelMode = pWrtShell->GetView().GetShellMode(); + bool bDrawText = ShellMode::DrawText == eSelMode; + bool bNormalText = + ShellMode::TableText == eSelMode || + ShellMode::ListText == eSelMode || + ShellMode::TableListText == eSelMode || + ShellMode::Text == eSelMode; + + // evaluate if the same sentence should be rechecked or not. + // Sentences that got grammar checked should always be rechecked in order + // to detect possible errors that get introduced with the changes + bRecheck |= SwEditShell::HasLastSentenceGotGrammarChecked(); + + if(bNormalText) + pWrtShell->ApplyChangedSentence(rChanged, bRecheck); + else if(bDrawText ) + { + SdrView* pDrView = pWrtShell->GetDrawView(); + SdrOutliner *pOutliner = pDrView->GetTextEditOutliner(); + pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, bRecheck); } } @@ -481,26 +481,26 @@ void SwSpellDialogChildWindow::SetGrammarChecking(bool bOn) // set current spell position to the start of the current sentence to // continue with this sentence after grammar checking state has been changed SwWrtShell* pWrtShell = GetWrtShell_Impl(); - if(pWrtShell) + if(!pWrtShell) + return; + + ShellMode eSelMode = pWrtShell->GetView().GetShellMode(); + bool bDrawText = ShellMode::DrawText == eSelMode; + bool bNormalText = + ShellMode::TableText == eSelMode || + ShellMode::ListText == eSelMode || + ShellMode::TableListText == eSelMode || + ShellMode::Text == eSelMode; + if( bNormalText ) + SwEditShell::PutSpellingToSentenceStart(); + else if( bDrawText ) { - ShellMode eSelMode = pWrtShell->GetView().GetShellMode(); - bool bDrawText = ShellMode::DrawText == eSelMode; - bool bNormalText = - ShellMode::TableText == eSelMode || - ShellMode::ListText == eSelMode || - ShellMode::TableListText == eSelMode || - ShellMode::Text == eSelMode; - if( bNormalText ) - SwEditShell::PutSpellingToSentenceStart(); - else if( bDrawText ) + SdrView* pSdrView = pWrtShell->GetDrawView(); + SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : nullptr; + OSL_ENSURE(pOutliner, "No Outliner in SwSpellDialogChildWindow::SetGrammarChecking"); + if(pOutliner) { - SdrView* pSdrView = pWrtShell->GetDrawView(); - SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : nullptr; - OSL_ENSURE(pOutliner, "No Outliner in SwSpellDialogChildWindow::SetGrammarChecking"); - if(pOutliner) - { - pOutliner->PutSpellingToSentenceStart( pSdrView->GetTextEditOutlinerView()->GetEditView() ); - } + pOutliner->PutSpellingToSentenceStart( pSdrView->GetTextEditOutlinerView()->GetEditView() ); } } } diff --git a/sw/source/uibase/dialog/watermarkdialog.cxx b/sw/source/uibase/dialog/watermarkdialog.cxx index 46dc847c0746..88b187e24ab6 100644 --- a/sw/source/uibase/dialog/watermarkdialog.cxx +++ b/sw/source/uibase/dialog/watermarkdialog.cxx @@ -81,21 +81,21 @@ void SwWatermarkDialog::InitFields() const SfxPoolItem* pItem; SfxItemState eState = m_rBindings.GetDispatcher()->QueryState( SID_WATERMARK, pItem ); - if( eState >= SfxItemState::DEFAULT && pItem && pItem->Which() == SID_WATERMARK) - { - const SfxWatermarkItem* pWatermark = static_cast<const SfxWatermarkItem*>( pItem ); - const OUString& sText = pWatermark->GetText(); - m_xTextInput->set_text(sText); - OUString sFontName = pWatermark->GetFont(); - int nFontIndex = m_xFont->find_text(sFontName); - if (nFontIndex != -1) - m_xFont->set_active(nFontIndex); - else - m_xFont->set_entry_text(sFontName); - m_xAngle->set_value(pWatermark->GetAngle(), FieldUnit::DEGREE); - m_xColor->SelectEntry( pWatermark->GetColor() ); - m_xTransparency->set_value(pWatermark->GetTransparency(), FieldUnit::PERCENT); - } + if( !(eState >= SfxItemState::DEFAULT && pItem && pItem->Which() == SID_WATERMARK)) + return; + + const SfxWatermarkItem* pWatermark = static_cast<const SfxWatermarkItem*>( pItem ); + const OUString& sText = pWatermark->GetText(); + m_xTextInput->set_text(sText); + OUString sFontName = pWatermark->GetFont(); + int nFontIndex = m_xFont->find_text(sFontName); + if (nFontIndex != -1) + m_xFont->set_active(nFontIndex); + else + m_xFont->set_entry_text(sFontName); + m_xAngle->set_value(pWatermark->GetAngle(), FieldUnit::DEGREE); + m_xColor->SelectEntry( pWatermark->GetColor() ); + m_xTransparency->set_value(pWatermark->GetTransparency(), FieldUnit::PERCENT); } IMPL_LINK_NOARG(SwWatermarkDialog, OKButtonHdl, weld::Button&, void) diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index d33fc25d759e..f5497e800308 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -248,20 +248,20 @@ SwTransferable::SwTransferable( SwWrtShell& rSh ) { rSh.GetView().AddTransferable(*this); SwDocShell* pDShell = rSh.GetDoc()->GetDocShell(); - if( pDShell ) - { - pDShell->FillTransferableObjectDescriptor( m_aObjDesc ); - if( pDShell->GetMedium() ) - { - const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject(); - m_aObjDesc.maDisplayName = URIHelper::removePassword( - rURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), - INetURLObject::EncodeMechanism::WasEncoded, - INetURLObject::DecodeMechanism::Unambiguous ); - } + if( !pDShell ) + return; - PrepareOLE( m_aObjDesc ); + pDShell->FillTransferableObjectDescriptor( m_aObjDesc ); + if( pDShell->GetMedium() ) + { + const INetURLObject& rURLObj = pDShell->GetMedium()->GetURLObject(); + m_aObjDesc.maDisplayName = URIHelper::removePassword( + rURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), + INetURLObject::EncodeMechanism::WasEncoded, + INetURLObject::DecodeMechanism::Unambiguous ); } + + PrepareOLE( m_aObjDesc ); } SwTransferable::~SwTransferable() @@ -407,18 +407,18 @@ namespace void lclCheckAndPerformRotation(Graphic& aGraphic) { GraphicNativeMetadata aMetadata; - if ( aMetadata.read(aGraphic) ) + if ( !aMetadata.read(aGraphic) ) + return; + + sal_uInt16 aRotation = aMetadata.getRotation(); + if (aRotation != 0) { - sal_uInt16 aRotation = aMetadata.getRotation(); - if (aRotation != 0) + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/queryrotateintostandarddialog.ui")); + std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryRotateIntoStandardOrientationDialog")); + if (xQueryBox->run() == RET_YES) { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, "modules/swriter/ui/queryrotateintostandarddialog.ui")); - std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryRotateIntoStandardOrientationDialog")); - if (xQueryBox->run() == RET_YES) - { - GraphicNativeTransform aTransform( aGraphic ); - aTransform.rotate( aRotation ); - } + GraphicNativeTransform aTransform( aGraphic ); + aTransform.rotate( aRotation ); } } } @@ -3561,22 +3561,22 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos ) } } - if( m_pWrtShell->IsFrameSelected() ) + if( !m_pWrtShell->IsFrameSelected() ) + return; + + SfxItemSet aSet( m_pWrtShell->GetAttrPool(), svl::Items<RES_URL, RES_URL>{} ); + m_pWrtShell->GetFlyFrameAttr( aSet ); + const SwFormatURL& rURL = aSet.Get( RES_URL ); + if( rURL.GetMap() ) { - SfxItemSet aSet( m_pWrtShell->GetAttrPool(), svl::Items<RES_URL, RES_URL>{} ); - m_pWrtShell->GetFlyFrameAttr( aSet ); - const SwFormatURL& rURL = aSet.Get( RES_URL ); - if( rURL.GetMap() ) - { - m_pImageMap.reset( new ImageMap( *rURL.GetMap() ) ); - AddFormat( SotClipboardFormatId::SVIM ); - } - else if( !rURL.GetURL().isEmpty() ) - { - m_pTargetURL.reset(new INetImage( sGrfNm, rURL.GetURL(), - rURL.GetTargetFrameName() )); - AddFormat( SotClipboardFormatId::INET_IMAGE ); - } + m_pImageMap.reset( new ImageMap( *rURL.GetMap() ) ); + AddFormat( SotClipboardFormatId::SVIM ); + } + else if( !rURL.GetURL().isEmpty() ) + { + m_pTargetURL.reset(new INetImage( sGrfNm, rURL.GetURL(), + rURL.GetTargetFrameName() )); + AddFormat( SotClipboardFormatId::INET_IMAGE ); } } @@ -4169,20 +4169,20 @@ SwTransferDdeLink::SwTransferDdeLink( SwTransferable& rTrans, SwWrtShell& rSh ) rSh.DoUndo( bUndo ); } - if( !sName.isEmpty() && - nullptr != ( pDocShell = rSh.GetDoc()->GetDocShell() ) ) + if( sName.isEmpty() || + nullptr == ( pDocShell = rSh.GetDoc()->GetDocShell() )) + return; + + // then we create our "server" and connect to it + refObj = pDocShell->DdeCreateLinkSource( sName ); + if( refObj.is() ) { - // then we create our "server" and connect to it - refObj = pDocShell->DdeCreateLinkSource( sName ); - if( refObj.is() ) - { - refObj->AddConnectAdvise( this ); - refObj->AddDataAdvise( this, - OUString(), - ADVISEMODE_NODATA | ADVISEMODE_ONLYONCE ); - nOldTimeOut = refObj->GetUpdateTimeout(); - refObj->SetUpdateTimeout( 0 ); - } + refObj->AddConnectAdvise( this ); + refObj->AddDataAdvise( this, + OUString(), + ADVISEMODE_NODATA | ADVISEMODE_ONLYONCE ); + nOldTimeOut = refObj->GetUpdateTimeout(); + refObj->SetUpdateTimeout( 0 ); } } diff --git a/sw/source/uibase/docvw/AnchorOverlayObject.cxx b/sw/source/uibase/docvw/AnchorOverlayObject.cxx index af5a3de41214..74ed52b93441 100644 --- a/sw/source/uibase/docvw/AnchorOverlayObject.cxx +++ b/sw/source/uibase/docvw/AnchorOverlayObject.cxx @@ -298,25 +298,25 @@ void AnchorOverlayObject::SetAllPosition( const basegfx::B2DPoint& rPoint1, const basegfx::B2DPoint& rPoint6, const basegfx::B2DPoint& rPoint7) { - if ( rPoint1 != getBasePosition() || + if ( !(rPoint1 != getBasePosition() || rPoint2 != GetSecondPosition() || rPoint3 != GetThirdPosition() || rPoint4 != GetFourthPosition() || rPoint5 != GetFifthPosition() || rPoint6 != GetSixthPosition() || - rPoint7 != GetSeventhPosition() ) - { - maBasePosition = rPoint1; - maSecondPosition = rPoint2; - maThirdPosition = rPoint3; - maFourthPosition = rPoint4; - maFifthPosition = rPoint5; - maSixthPosition = rPoint6; - maSeventhPosition = rPoint7; - - implResetGeometry(); - objectChange(); - } + rPoint7 != GetSeventhPosition()) ) + return; + + maBasePosition = rPoint1; + maSecondPosition = rPoint2; + maThirdPosition = rPoint3; + maFourthPosition = rPoint4; + maFifthPosition = rPoint5; + maSixthPosition = rPoint6; + maSeventhPosition = rPoint7; + + implResetGeometry(); + objectChange(); } void AnchorOverlayObject::SetSixthPosition(const basegfx::B2DPoint& rNew) diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx b/sw/source/uibase/docvw/AnnotationWin.cxx index 99cc57173860..579323fd40ef 100644 --- a/sw/source/uibase/docvw/AnnotationWin.cxx +++ b/sw/source/uibase/docvw/AnnotationWin.cxx @@ -307,23 +307,23 @@ void SwAnnotationWin::UpdateData() void SwAnnotationWin::Delete() { - if (mrView.GetWrtShellPtr()->GotoField(*mpFormatField)) + if (!mrView.GetWrtShellPtr()->GotoField(*mpFormatField)) + return; + + if ( mrMgr.GetActiveSidebarWin() == this) { - if ( mrMgr.GetActiveSidebarWin() == this) + mrMgr.SetActiveSidebarWin(nullptr); + // if the note is empty, the previous line will send a delete event, but we are already there + if (mnEventId) { - mrMgr.SetActiveSidebarWin(nullptr); - // if the note is empty, the previous line will send a delete event, but we are already there - if (mnEventId) - { - Application::RemoveUserEvent( mnEventId ); - mnEventId = nullptr; - } + Application::RemoveUserEvent( mnEventId ); + mnEventId = nullptr; } - // we delete the field directly, the Mgr cleans up the PostIt by listening - GrabFocusToDocument(); - mrView.GetWrtShellPtr()->ClearMark(); - mrView.GetWrtShellPtr()->DelRight(); } + // we delete the field directly, the Mgr cleans up the PostIt by listening + GrabFocusToDocument(); + mrView.GetWrtShellPtr()->ClearMark(); + mrView.GetWrtShellPtr()->DelRight(); } void SwAnnotationWin::GotoPos() diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index 2801159850ad..633b8ebe00d8 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -151,32 +151,32 @@ void SwAnnotationWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rec { Window::Paint(rRenderContext, rRect); - if (mpMetadataAuthor->IsVisible()) + if (!mpMetadataAuthor->IsVisible()) + return; + + //draw left over space + if (Application::GetSettings().GetStyleSettings().GetHighContrastMode()) { - //draw left over space - if (Application::GetSettings().GetStyleSettings().GetHighContrastMode()) - { - rRenderContext.SetFillColor(COL_BLACK); - } - else - { - rRenderContext.SetFillColor(mColorDark); - } + rRenderContext.SetFillColor(COL_BLACK); + } + else + { + rRenderContext.SetFillColor(mColorDark); + } - sal_uInt32 boxHeight = mpMetadataAuthor->GetSizePixel().Height() + mpMetadataDate->GetSizePixel().Height(); - boxHeight += IsThreadResolved() ? mpMetadataResolved->GetSizePixel().Height() : 0; + sal_uInt32 boxHeight = mpMetadataAuthor->GetSizePixel().Height() + mpMetadataDate->GetSizePixel().Height(); + boxHeight += IsThreadResolved() ? mpMetadataResolved->GetSizePixel().Height() : 0; - rRenderContext.SetLineColor(); - tools::Rectangle aRectangle(Point(mpMetadataAuthor->GetPosPixel().X() + mpMetadataAuthor->GetSizePixel().Width(), - mpMetadataAuthor->GetPosPixel().Y()), - Size(GetMetaButtonAreaWidth(), boxHeight)); + rRenderContext.SetLineColor(); + tools::Rectangle aRectangle(Point(mpMetadataAuthor->GetPosPixel().X() + mpMetadataAuthor->GetSizePixel().Width(), + mpMetadataAuthor->GetPosPixel().Y()), + Size(GetMetaButtonAreaWidth(), boxHeight)); - if (comphelper::LibreOfficeKit::isActive()) - aRectangle = rRect; - else - aRectangle = PixelToLogic(aRectangle); - rRenderContext.DrawRect(aRectangle); - } + if (comphelper::LibreOfficeKit::isActive()) + aRectangle = rRect; + else + aRectangle = PixelToLogic(aRectangle); + rRenderContext.DrawRect(aRectangle); } void SwAnnotationWin::PaintTile(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) @@ -1021,44 +1021,44 @@ void SwAnnotationWin::SetColor(Color aColorDark,Color aColorLight, Color aColorA mColorLight = aColorLight; mColorAnchor = aColorAnchor; - if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) - { - { - mpMetadataAuthor->SetControlBackground(mColorDark); - AllSettings aSettings = mpMetadataAuthor->GetSettings(); - StyleSettings aStyleSettings = aSettings.GetStyleSettings(); - aStyleSettings.SetFieldTextColor(aColorAnchor); - aSettings.SetStyleSettings(aStyleSettings); - mpMetadataAuthor->SetSettings(aSettings); - } + if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + return; - { - mpMetadataDate->SetControlBackground(mColorDark); - AllSettings aSettings = mpMetadataDate->GetSettings(); - StyleSettings aStyleSettings = aSettings.GetStyleSettings(); - aStyleSettings.SetFieldTextColor(aColorAnchor); - aSettings.SetStyleSettings(aStyleSettings); - mpMetadataDate->SetSettings(aSettings); - } + { + mpMetadataAuthor->SetControlBackground(mColorDark); + AllSettings aSettings = mpMetadataAuthor->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + aStyleSettings.SetFieldTextColor(aColorAnchor); + aSettings.SetStyleSettings(aStyleSettings); + mpMetadataAuthor->SetSettings(aSettings); + } - { - mpMetadataResolved->SetControlBackground(mColorDark); - AllSettings aSettings = mpMetadataResolved->GetSettings(); - StyleSettings aStyleSettings = aSettings.GetStyleSettings(); - aStyleSettings.SetFieldTextColor(aColorAnchor); - aSettings.SetStyleSettings(aStyleSettings); - mpMetadataResolved->SetSettings(aSettings); - } + { + mpMetadataDate->SetControlBackground(mColorDark); + AllSettings aSettings = mpMetadataDate->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + aStyleSettings.SetFieldTextColor(aColorAnchor); + aSettings.SetStyleSettings(aStyleSettings); + mpMetadataDate->SetSettings(aSettings); + } - AllSettings aSettings2 = mpVScrollbar->GetSettings(); - StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings(); - aStyleSettings2.SetButtonTextColor(Color(0,0,0)); - aStyleSettings2.SetCheckedColor(mColorLight); // background - aStyleSettings2.SetShadowColor(mColorAnchor); - aStyleSettings2.SetFaceColor(mColorDark); - aSettings2.SetStyleSettings(aStyleSettings2); - mpVScrollbar->SetSettings(aSettings2); + { + mpMetadataResolved->SetControlBackground(mColorDark); + AllSettings aSettings = mpMetadataResolved->GetSettings(); + StyleSettings aStyleSettings = aSettings.GetStyleSettings(); + aStyleSettings.SetFieldTextColor(aColorAnchor); + aSettings.SetStyleSettings(aStyleSettings); + mpMetadataResolved->SetSettings(aSettings); } + + AllSettings aSettings2 = mpVScrollbar->GetSettings(); + StyleSettings aStyleSettings2 = aSettings2.GetStyleSettings(); + aStyleSettings2.SetButtonTextColor(Color(0,0,0)); + aStyleSettings2.SetCheckedColor(mColorLight); // background + aStyleSettings2.SetShadowColor(mColorAnchor); + aStyleSettings2.SetFaceColor(mColorDark); + aSettings2.SetStyleSettings(aStyleSettings2); + mpVScrollbar->SetSettings(aSettings2); } void SwAnnotationWin::SetSidebarPosition(sw::sidebarwindows::SidebarPosition eSidebarPosition) diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index b67252a139d8..a6e3c3956ab1 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -259,20 +259,20 @@ void SwPostItMgr::CheckForRemovedPostIts() ++it; } - if ( bRemoved ) + if ( !bRemoved ) + return; + + // make sure that no deleted items remain in page lists + // todo: only remove deleted ones?! + if ( mvPostItFields.empty() ) { - // make sure that no deleted items remain in page lists - // todo: only remove deleted ones?! - if ( mvPostItFields.empty() ) - { - PreparePageContainer(); - PrepareView(); - } - else - // if postits are their make sure that page lists are not empty - // otherwise sudden paints can cause pain (in BorderOverPageBorder) - CalcRects(); + PreparePageContainer(); + PrepareView(); } + else + // if postits are their make sure that page lists are not empty + // otherwise sudden paints can cause pain (in BorderOverPageBorder) + CalcRects(); } SwSidebarItem* SwPostItMgr::InsertItem(SfxBroadcaster* pItem, bool bCheckExistence, bool bFocus) @@ -1050,22 +1050,22 @@ void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) void SwPostItMgr::AutoScroll(const SwAnnotationWin* pPostIt,const unsigned long aPage ) { // otherwise all notes are visible - if (mPages[aPage-1]->bScrollbar) + if (!mPages[aPage-1]->bScrollbar) + return; + + const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height(); + const bool bBottom = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height())).Y() <= (mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight); + const bool bTop = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y())).Y() >= (mPages[aPage-1]->mPageRect.Top()+aSidebarheight); + if ( !(bBottom && bTop)) { - const long aSidebarheight = mpEditWin->PixelToLogic(Size(0,GetSidebarScrollerHeight())).Height(); - const bool bBottom = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height())).Y() <= (mPages[aPage-1]->mPageRect.Bottom()-aSidebarheight); - const bool bTop = mpEditWin->PixelToLogic(Point(0,pPostIt->GetPosPixel().Y())).Y() >= (mPages[aPage-1]->mPageRect.Top()+aSidebarheight); - if ( !(bBottom && bTop)) - { - const long aDiff = bBottom ? mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Top() + aSidebarheight)).Y() - pPostIt->GetPosPixel().Y() : - mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Bottom() - aSidebarheight)).Y() - (pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height()); - // this just adds the missing value to get the next a* GetScrollSize() after aDiff - // e.g aDiff= 61 POSTIT_SCROLL=50 --> lScroll = 100 - const auto nScrollSize = GetScrollSize(); - assert(nScrollSize); - const long lScroll = bBottom ? (aDiff + ( nScrollSize - (aDiff % nScrollSize))) : (aDiff - (nScrollSize + (aDiff % nScrollSize))); - Scroll(lScroll, aPage); - } + const long aDiff = bBottom ? mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Top() + aSidebarheight)).Y() - pPostIt->GetPosPixel().Y() : + mpEditWin->LogicToPixel(Point(0,mPages[aPage-1]->mPageRect.Bottom() - aSidebarheight)).Y() - (pPostIt->GetPosPixel().Y()+pPostIt->GetSizePixel().Height()); + // this just adds the missing value to get the next a* GetScrollSize() after aDiff + // e.g aDiff= 61 POSTIT_SCROLL=50 --> lScroll = 100 + const auto nScrollSize = GetScrollSize(); + assert(nScrollSize); + const long lScroll = bBottom ? (aDiff + ( nScrollSize - (aDiff % nScrollSize))) : (aDiff - (nScrollSize + (aDiff % nScrollSize))); + Scroll(lScroll, aPage); } } @@ -1414,35 +1414,35 @@ class FieldDocWatchingStack : public SfxListener virtual void Notify(SfxBroadcaster&, const SfxHint& rHint) override { const SwFormatFieldHint* pHint = dynamic_cast<const SwFormatFieldHint*>(&rHint); - if (pHint) + if (!pHint) + return; + + bool bAllInvalidated = false; + if (pHint->Which() == SwFormatFieldHintWhich::REMOVED) { - bool bAllInvalidated = false; - if (pHint->Which() == SwFormatFieldHintWhich::REMOVED) + const SwFormatField* pField = pHint->GetField(); + bAllInvalidated = pField == nullptr; + if (!bAllInvalidated && m_rFilter(pField)) { - const SwFormatField* pField = pHint->GetField(); - bAllInvalidated = pField == nullptr; - if (!bAllInvalidated && m_rFilter(pField)) - { - EndListening(const_cast<SwFormatField&>(*pField)); - v.erase(std::remove(v.begin(), v.end(), pField), v.end()); - } + EndListening(const_cast<SwFormatField&>(*pField)); + v.erase(std::remove(v.begin(), v.end(), pField), v.end()); } - else if (pHint->Which() == SwFormatFieldHintWhich::INSERTED) + } + else if (pHint->Which() == SwFormatFieldHintWhich::INSERTED) + { + const SwFormatField* pField = pHint->GetField(); + bAllInvalidated = pField == nullptr; + if (!bAllInvalidated && m_rFilter(pField)) { - const SwFormatField* pField = pHint->GetField(); - bAllInvalidated = pField == nullptr; - if (!bAllInvalidated && m_rFilter(pField)) - { - StartListening(const_cast<SwFormatField&>(*pField)); - v.push_back(pField); - } + StartListening(const_cast<SwFormatField&>(*pField)); + v.push_back(pField); } + } - if (bAllInvalidated) - FillVector(); + if (bAllInvalidated) + FillVector(); - return; - } + return; } public: @@ -2019,23 +2019,23 @@ void SwPostItMgr::CorrectPositions() const long aAnchorY = pFirstPostIt->Anchor() ? mpEditWin->LogicToPixel( Point(0,static_cast<long>(pFirstPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1 : 0; - if (Point(aAnchorX,aAnchorY) != pFirstPostIt->GetPosPixel()) + if (Point(aAnchorX,aAnchorY) == pFirstPostIt->GetPosPixel()) + return; + + long aAnchorPosX = 0; + long aAnchorPosY = 0; + for (const std::unique_ptr<SwPostItPageItem>& pPage : mPages) { - long aAnchorPosX = 0; - long aAnchorPosY = 0; - for (const std::unique_ptr<SwPostItPageItem>& pPage : mPages) + for (auto const& item : pPage->mvSidebarItems) { - for (auto const& item : pPage->mvSidebarItems) + // check, if anchor overlay object exists. + if ( item->bShow && item->pPostIt && item->pPostIt->Anchor() ) { - // check, if anchor overlay object exists. - if ( item->bShow && item->pPostIt && item->pPostIt->Anchor() ) - { - aAnchorPosX = pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT - ? mpEditWin->LogicToPixel( Point(static_cast<long>(item->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X() - : mpEditWin->LogicToPixel( Point(static_cast<long>(item->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); - aAnchorPosY = mpEditWin->LogicToPixel( Point(0,static_cast<long>(item->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; - item->pPostIt->SetPosPixel(Point(aAnchorPosX,aAnchorPosY)); - } + aAnchorPosX = pPage->eSidebarPosition == sw::sidebarwindows::SidebarPosition::LEFT + ? mpEditWin->LogicToPixel( Point(static_cast<long>(item->pPostIt->Anchor()->GetSeventhPosition().getX()),0)).X() + : mpEditWin->LogicToPixel( Point(static_cast<long>(item->pPostIt->Anchor()->GetSixthPosition().getX()),0)).X(); + aAnchorPosY = mpEditWin->LogicToPixel( Point(0,static_cast<long>(item->pPostIt->Anchor()->GetSixthPosition().getY()))).Y() + 1; + item->pPostIt->SetPosPixel(Point(aAnchorPosX,aAnchorPosY)); } } } @@ -2133,24 +2133,24 @@ Color SwPostItMgr::GetColorAnchor(std::size_t aAuthorIndex) void SwPostItMgr::SetActiveSidebarWin( SwAnnotationWin* p) { - if ( p != mpActivePostIt ) + if ( p == mpActivePostIt ) + return; + + // we need the temp variable so we can set mpActivePostIt before we call DeactivatePostIt + // therefore we get a new layout in DOCCHANGED when switching from postit to document, + // otherwise, GetActivePostIt() would still hold our old postit + SwAnnotationWin* pActive = mpActivePostIt; + mpActivePostIt = p; + if (pActive) { - // we need the temp variable so we can set mpActivePostIt before we call DeactivatePostIt - // therefore we get a new layout in DOCCHANGED when switching from postit to document, - // otherwise, GetActivePostIt() would still hold our old postit - SwAnnotationWin* pActive = mpActivePostIt; - mpActivePostIt = p; - if (pActive) - { - pActive->DeactivatePostIt(); - mShadowState.mpShadowField = nullptr; - } - if (mpActivePostIt) - { - mpActivePostIt->GotoPos(); - mpView->AttrChangedNotify(nullptr); - mpActivePostIt->ActivatePostIt(); - } + pActive->DeactivatePostIt(); + mShadowState.mpShadowField = nullptr; + } + if (mpActivePostIt) + { + mpActivePostIt->GotoPos(); + mpView->AttrChangedNotify(nullptr); + mpActivePostIt->ActivatePostIt(); } } diff --git a/sw/source/uibase/docvw/SidebarTxtControl.cxx b/sw/source/uibase/docvw/SidebarTxtControl.cxx index 65c67d0983a5..b1f4f8879f23 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.cxx @@ -288,26 +288,26 @@ void SidebarTextControl::KeyInput( const KeyEvent& rKeyEvt ) void SidebarTextControl::MouseMove( const MouseEvent& rMEvt ) { - if ( GetTextView() ) + if ( !GetTextView() ) + return; + + OutlinerView* pOutlinerView( GetTextView() ); + pOutlinerView->MouseMove( rMEvt ); + // mba: why does OutlinerView not handle the modifier setting?! + // this forces the postit to handle *all* pointer types + SetPointer( pOutlinerView->GetPointer( rMEvt.GetPosPixel() ) ); + + const EditView& aEV = pOutlinerView->GetEditView(); + const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer(); + if ( pItem ) { - OutlinerView* pOutlinerView( GetTextView() ); - pOutlinerView->MouseMove( rMEvt ); - // mba: why does OutlinerView not handle the modifier setting?! - // this forces the postit to handle *all* pointer types - SetPointer( pOutlinerView->GetPointer( rMEvt.GetPosPixel() ) ); - - const EditView& aEV = pOutlinerView->GetEditView(); - const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer(); - if ( pItem ) + const SvxFieldData* pField = pItem->GetField(); + const SvxURLField* pURL = dynamic_cast<const SvxURLField*>( pField ); + if ( pURL ) { - const SvxFieldData* pField = pItem->GetField(); - const SvxURLField* pURL = dynamic_cast<const SvxURLField*>( pField ); - if ( pURL ) - { - OUString sText(SfxHelp::GetURLHelpText(pURL->GetURL())); - Help::ShowQuickHelp( - this, PixelToLogic(tools::Rectangle(GetPosPixel(), Size(50, 10))), sText); - } + OUString sText(SfxHelp::GetURLHelpText(pURL->GetURL())); + Help::ShowQuickHelp( + this, PixelToLogic(tools::Rectangle(GetPosPixel(), Size(50, 10))), sText); } } } diff --git a/sw/source/uibase/docvw/SidebarWinAcc.cxx b/sw/source/uibase/docvw/SidebarWinAcc.cxx index 010394dad277..9ca77ffdc1ba 100644 --- a/sw/source/uibase/docvw/SidebarWinAcc.cxx +++ b/sw/source/uibase/docvw/SidebarWinAcc.cxx @@ -112,18 +112,18 @@ SidebarWinAccessible::~SidebarWinAccessible() void SidebarWinAccessible::ChangeSidebarItem( const SwSidebarItem& rSidebarItem ) { - if ( bAccContextCreated ) + if ( !bAccContextCreated ) + return; + + css::uno::Reference< css::accessibility::XAccessibleContext > xAcc + = getAccessibleContext(); + if ( xAcc.is() ) { - css::uno::Reference< css::accessibility::XAccessibleContext > xAcc - = getAccessibleContext(); - if ( xAcc.is() ) + SidebarWinAccessibleContext* pAccContext = + dynamic_cast<SidebarWinAccessibleContext*>(xAcc.get()); + if ( pAccContext ) { - SidebarWinAccessibleContext* pAccContext = - dynamic_cast<SidebarWinAccessibleContext*>(xAcc.get()); - if ( pAccContext ) - { - pAccContext->ChangeAnchor( rSidebarItem.maLayoutInfo.mpAnchorFrame ); - } + pAccContext->ChangeAnchor( rSidebarItem.maLayoutInfo.mpAnchorFrame ); } } } diff --git a/sw/source/uibase/docvw/edtdd.cxx b/sw/source/uibase/docvw/edtdd.cxx index 44728b9ba129..8530a015cfe7 100644 --- a/sw/source/uibase/docvw/edtdd.cxx +++ b/sw/source/uibase/docvw/edtdd.cxx @@ -77,60 +77,60 @@ void SwEditWin::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel ) } } - if ( !m_pApplyTempl && !rSh.IsDrawCreate() && !IsDrawAction()) + if ( !(!m_pApplyTempl && !rSh.IsDrawCreate() && !IsDrawAction())) + return; + + bool bStart = false, bDelSelect = false; + SdrObject *pObj = nullptr; + Point aDocPos( PixelToLogic( rPosPixel ) ); + if ( !rSh.IsInSelect() && rSh.TestCurrPam( aDocPos, true)) + //We are not selecting and aren't at a selection + bStart = true; + else if ( !g_bFrameDrag && rSh.IsSelFrameMode() && + rSh.IsInsideSelectedObj( aDocPos ) && + nullptr == m_pAnchorMarker) { - bool bStart = false, bDelSelect = false; - SdrObject *pObj = nullptr; - Point aDocPos( PixelToLogic( rPosPixel ) ); - if ( !rSh.IsInSelect() && rSh.TestCurrPam( aDocPos, true)) - //We are not selecting and aren't at a selection - bStart = true; - else if ( !g_bFrameDrag && rSh.IsSelFrameMode() && - rSh.IsInsideSelectedObj( aDocPos ) && - nullptr == m_pAnchorMarker) - { - //We are not dragging internally and are not at an - //object (frame, draw object) - - // #i106131# *and* AnchorDrag is *not* active: When active, - // entering global drag mode will destroy the AnchorHdl but - // keep the now invalid ptr in place, next access will crash. - // It is indeed wrong to enter drag mode when AnchorDrag is - // already active - bStart = true; - } - else if( !g_bFrameDrag && m_rView.GetDocShell()->IsReadOnly() && - OBJCNT_NONE != rSh.GetObjCntType( aDocPos, pObj )) - { - rSh.LockPaint(); - if( rSh.SelectObj( aDocPos, 0, pObj )) - bStart = bDelSelect = true; - else - rSh.UnlockPaint(); - } + //We are not dragging internally and are not at an + //object (frame, draw object) + + // #i106131# *and* AnchorDrag is *not* active: When active, + // entering global drag mode will destroy the AnchorHdl but + // keep the now invalid ptr in place, next access will crash. + // It is indeed wrong to enter drag mode when AnchorDrag is + // already active + bStart = true; + } + else if( !g_bFrameDrag && m_rView.GetDocShell()->IsReadOnly() && + OBJCNT_NONE != rSh.GetObjCntType( aDocPos, pObj )) + { + rSh.LockPaint(); + if( rSh.SelectObj( aDocPos, 0, pObj )) + bStart = bDelSelect = true; else - { - SwContentAtPos aSwContentAtPos( IsAttrAtPos::InetAttr ); - bStart = rSh.GetContentAtPos( aDocPos, - aSwContentAtPos ); - } + rSh.UnlockPaint(); + } + else + { + SwContentAtPos aSwContentAtPos( IsAttrAtPos::InetAttr ); + bStart = rSh.GetContentAtPos( aDocPos, + aSwContentAtPos ); + } - if ( bStart && !m_bIsInDrag ) - { - m_bMBPressed = false; - ReleaseMouse(); - g_bFrameDrag = false; - g_bExecuteDrag = true; - SwEditWin::m_nDDStartPosY = aDocPos.Y(); - SwEditWin::m_nDDStartPosX = aDocPos.X(); - m_aMovePos = aDocPos; - StartExecuteDrag(); - if( bDelSelect ) - { - rSh.UnSelectFrame(); - rSh.UnlockPaint(); - } - } + if ( !(bStart && !m_bIsInDrag) ) + return; + + m_bMBPressed = false; + ReleaseMouse(); + g_bFrameDrag = false; + g_bExecuteDrag = true; + SwEditWin::m_nDDStartPosY = aDocPos.Y(); + SwEditWin::m_nDDStartPosX = aDocPos.X(); + m_aMovePos = aDocPos; + StartExecuteDrag(); + if( bDelSelect ) + { + rSh.UnSelectFrame(); + rSh.UnlockPaint(); } } diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index b2d43874a13d..49d759d89aaa 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -5068,20 +5068,20 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) if (bCallBase) Window::MouseButtonUp(rMEvt); - if (pSdrView && rMEvt.GetClicks() == 1 && comphelper::LibreOfficeKit::isActive()) + if (!(pSdrView && rMEvt.GetClicks() == 1 && comphelper::LibreOfficeKit::isActive())) + return; + + // When tiled rendering, single click on a shape text starts editing already. + SdrViewEvent aViewEvent; + SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONUP, aViewEvent); + const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); + if (eHit == SdrHitKind::TextEditObj && rMarkList.GetMarkCount() == 1) { - // When tiled rendering, single click on a shape text starts editing already. - SdrViewEvent aViewEvent; - SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONUP, aViewEvent); - const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); - if (eHit == SdrHitKind::TextEditObj && rMarkList.GetMarkCount() == 1) + if (SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj()) { - if (SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj()) - { - EnterDrawTextMode(pObj->GetLogicRect().Center()); - if ( dynamic_cast< const SwDrawTextShell *>( m_rView.GetCurShell() ) != nullptr ) - static_cast<SwDrawTextShell*>(m_rView.GetCurShell())->Init(); - } + EnterDrawTextMode(pObj->GetLogicRect().Center()); + if ( dynamic_cast< const SwDrawTextShell *>( m_rView.GetCurShell() ) != nullptr ) + static_cast<SwDrawTextShell*>(m_rView.GetCurShell())->Init(); } } } @@ -6177,36 +6177,36 @@ void QuickHelpData::FillStrArr( SwWrtShell const & rSh, const OUString& rWord ) const SwAutoCompleteWord& rACList = SwEditShell::GetAutoCompleteWords(); std::vector<OUString> strings; - if ( rACList.GetWordsMatching( rWord, strings ) ) + if ( !rACList.GetWordsMatching( rWord, strings ) ) + return; + + for (const OUString & aCompletedString : strings) { - for (const OUString & aCompletedString : strings) - { - // when we have a matching current date, avoid to suggest - // other words with the same matching starting characters, - // for example 2016-01-3 instead of 2016-01-30 - if (!rStrToday.isEmpty() && aCompletedString.startsWith(rWord)) - continue; - - OUString sStr; - - //fdo#61251 if it's an exact match, ensure unchanged replacement - //exists as a candidate - if (aCompletedString.startsWith(rWord)) - m_aHelpStrings.emplace_back(aCompletedString, rWord.getLength()); - else - sStr = aCompletedString; // to be added if no case conversion is performed below - - if (aWordCase == CASE_LOWER) - sStr = rCC.lowercase(aCompletedString); - else if (aWordCase == CASE_SENTENCE) - sStr = rCC.lowercase(aCompletedString) - .replaceAt(0, 1, OUString(aCompletedString[0])); - else if (aWordCase == CASE_UPPER) - sStr = rCC.uppercase(aCompletedString); - - if (!sStr.isEmpty()) - m_aHelpStrings.emplace_back(aCompletedString, rWord.getLength()); - } + // when we have a matching current date, avoid to suggest + // other words with the same matching starting characters, + // for example 2016-01-3 instead of 2016-01-30 + if (!rStrToday.isEmpty() && aCompletedString.startsWith(rWord)) + continue; + + OUString sStr; + + //fdo#61251 if it's an exact match, ensure unchanged replacement + //exists as a candidate + if (aCompletedString.startsWith(rWord)) + m_aHelpStrings.emplace_back(aCompletedString, rWord.getLength()); + else + sStr = aCompletedString; // to be added if no case conversion is performed below + + if (aWordCase == CASE_LOWER) + sStr = rCC.lowercase(aCompletedString); + else if (aWordCase == CASE_SENTENCE) + sStr = rCC.lowercase(aCompletedString) + .replaceAt(0, 1, OUString(aCompletedString[0])); + else if (aWordCase == CASE_UPPER) + sStr = rCC.uppercase(aCompletedString); + + if (!sStr.isEmpty()) + m_aHelpStrings.emplace_back(aCompletedString, rWord.getLength()); } } diff --git a/sw/source/uibase/envelp/envimg.cxx b/sw/source/uibase/envelp/envimg.cxx index 6f849460175c..50cf3e9d92e8 100644 --- a/sw/source/uibase/envelp/envimg.cxx +++ b/sw/source/uibase/envelp/envimg.cxx @@ -158,56 +158,56 @@ SwEnvCfgItem::SwEnvCfgItem() : EnableNotification(aNames); const Any* pValues = aValues.getConstArray(); OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); - if(aValues.getLength() == aNames.getLength()) + if(aValues.getLength() != aNames.getLength()) + return; + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) { - for(int nProp = 0; nProp < aNames.getLength(); nProp++) + if(pValues[nProp].hasValue()) { - if(pValues[nProp].hasValue()) + switch(nProp) { - switch(nProp) + case 0: pValues[nProp] >>= m_aEnvItem.m_aAddrText; break;// "Inscription/Addressee", + case 1: pValues[nProp] >>= m_aEnvItem.m_aSendText; break;// "Inscription/Sender", + case 2: m_aEnvItem.m_bSend = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Inscription/UseSender", + case 3: + pValues[nProp] >>= m_aEnvItem.m_nAddrFromLeft;// "Format/AddresseeFromLeft", + m_aEnvItem.m_nAddrFromLeft = convertMm100ToTwip(m_aEnvItem.m_nAddrFromLeft); + break; + case 4: + pValues[nProp] >>= m_aEnvItem.m_nAddrFromTop; // "Format/AddresseeFromTop", + m_aEnvItem.m_nAddrFromTop = convertMm100ToTwip(m_aEnvItem.m_nAddrFromTop); + break; + case 5: + pValues[nProp] >>= m_aEnvItem.m_nSendFromLeft; // "Format/SenderFromLeft", + m_aEnvItem.m_nSendFromLeft = convertMm100ToTwip(m_aEnvItem.m_nSendFromLeft); + break; + case 6: + pValues[nProp] >>= m_aEnvItem.m_nSendFromTop;// "Format/SenderFromTop", + m_aEnvItem.m_nSendFromTop = convertMm100ToTwip(m_aEnvItem.m_nSendFromTop); + break; + case 7: + pValues[nProp] >>= m_aEnvItem.m_nWidth; // "Format/Width", + m_aEnvItem.m_nWidth = convertMm100ToTwip(m_aEnvItem.m_nWidth); + break; + case 8: + pValues[nProp] >>= m_aEnvItem.m_nHeight; // "Format/Height", + m_aEnvItem.m_nHeight = convertMm100ToTwip(m_aEnvItem.m_nHeight); + break; + case 9: { - case 0: pValues[nProp] >>= m_aEnvItem.m_aAddrText; break;// "Inscription/Addressee", - case 1: pValues[nProp] >>= m_aEnvItem.m_aSendText; break;// "Inscription/Sender", - case 2: m_aEnvItem.m_bSend = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Inscription/UseSender", - case 3: - pValues[nProp] >>= m_aEnvItem.m_nAddrFromLeft;// "Format/AddresseeFromLeft", - m_aEnvItem.m_nAddrFromLeft = convertMm100ToTwip(m_aEnvItem.m_nAddrFromLeft); - break; - case 4: - pValues[nProp] >>= m_aEnvItem.m_nAddrFromTop; // "Format/AddresseeFromTop", - m_aEnvItem.m_nAddrFromTop = convertMm100ToTwip(m_aEnvItem.m_nAddrFromTop); - break; - case 5: - pValues[nProp] >>= m_aEnvItem.m_nSendFromLeft; // "Format/SenderFromLeft", - m_aEnvItem.m_nSendFromLeft = convertMm100ToTwip(m_aEnvItem.m_nSendFromLeft); - break; - case 6: - pValues[nProp] >>= m_aEnvItem.m_nSendFromTop;// "Format/SenderFromTop", - m_aEnvItem.m_nSendFromTop = convertMm100ToTwip(m_aEnvItem.m_nSendFromTop); - break; - case 7: - pValues[nProp] >>= m_aEnvItem.m_nWidth; // "Format/Width", - m_aEnvItem.m_nWidth = convertMm100ToTwip(m_aEnvItem.m_nWidth); - break; - case 8: - pValues[nProp] >>= m_aEnvItem.m_nHeight; // "Format/Height", - m_aEnvItem.m_nHeight = convertMm100ToTwip(m_aEnvItem.m_nHeight); - break; - case 9: - { - sal_Int32 nTemp = 0; - pValues[nProp] >>= nTemp; m_aEnvItem.m_eAlign = static_cast<SwEnvAlign>(nTemp); break;// "Print/Alignment", - } - case 10: m_aEnvItem.m_bPrintFromAbove = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Print/FromAbove", - case 11: - pValues[nProp] >>= m_aEnvItem.m_nShiftRight; - m_aEnvItem.m_nShiftRight = convertMm100ToTwip(m_aEnvItem.m_nShiftRight);// "Print/Right", - break; - case 12: - pValues[nProp] >>= m_aEnvItem.m_nShiftDown; - m_aEnvItem.m_nShiftDown = convertMm100ToTwip(m_aEnvItem.m_nShiftDown); - break;// "Print/Down" + sal_Int32 nTemp = 0; + pValues[nProp] >>= nTemp; m_aEnvItem.m_eAlign = static_cast<SwEnvAlign>(nTemp); break;// "Print/Alignment", } + case 10: m_aEnvItem.m_bPrintFromAbove = *o3tl::doAccess<bool>(pValues[nProp]); break;// "Print/FromAbove", + case 11: + pValues[nProp] >>= m_aEnvItem.m_nShiftRight; + m_aEnvItem.m_nShiftRight = convertMm100ToTwip(m_aEnvItem.m_nShiftRight);// "Print/Right", + break; + case 12: + pValues[nProp] >>= m_aEnvItem.m_nShiftDown; + m_aEnvItem.m_nShiftDown = convertMm100ToTwip(m_aEnvItem.m_nShiftDown); + break;// "Print/Down" } } } |