diff options
-rw-r--r-- | sw/inc/ToxLinkProcessor.hxx | 3 | ||||
-rw-r--r-- | sw/inc/breakit.hxx | 7 | ||||
-rw-r--r-- | sw/qa/core/test_ToxLinkProcessor.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/bastyp/breakit.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/tox/ToxLinkProcessor.cxx | 13 | ||||
-rw-r--r-- | sw/source/core/unocore/unoidx.cxx | 30 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par3.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/index/cntex.cxx | 22 | ||||
-rw-r--r-- | sw/source/ui/index/cnttab.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/inc/conttree.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/swdtflvr.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/swuicnttab.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/TableEditPanel.cxx | 49 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/TableEditPanel.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/utlui/glbltree.cxx | 16 |
20 files changed, 95 insertions, 99 deletions
diff --git a/sw/inc/ToxLinkProcessor.hxx b/sw/inc/ToxLinkProcessor.hxx index d85b0665225e..b0c708fb6519 100644 --- a/sw/inc/ToxLinkProcessor.hxx +++ b/sw/inc/ToxLinkProcessor.hxx @@ -14,6 +14,7 @@ #include <rtl/ustring.hxx> #include <memory> +#include <optional> #include <utility> #include <vector> @@ -83,7 +84,7 @@ private: std::vector<std::unique_ptr<ClosedLink>> m_ClosedLinks; - std::unique_ptr<StartedLink> m_pStartedLink; + std::optional<StartedLink> m_oStartedLink; friend class ::ToxLinkProcessorTest; }; diff --git a/sw/inc/breakit.hxx b/sw/inc/breakit.hxx index a901a1f10a89..d21fb85bce45 100644 --- a/sw/inc/breakit.hxx +++ b/sw/inc/breakit.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SW_INC_BREAKIT_HXX #include <memory> +#include <optional> #include <com/sun/star/uno/Reference.h> #include <com/sun/star/i18n/ForbiddenCharacters.hpp> #include <i18nlangtag/languagetag.hxx> @@ -36,7 +37,7 @@ class SW_DLLPUBLIC SwBreakIt css::uno::Reference<css::i18n::XBreakIterator> m_xBreak; std::unique_ptr<LanguageTag> m_xLanguageTag; ///< language tag of the current locale - std::unique_ptr<css::i18n::ForbiddenCharacters> m_xForbidden; + std::optional<css::i18n::ForbiddenCharacters> m_oForbidden; LanguageType m_aForbiddenLang; ///< language of the current forbiddenChar struct @@ -102,9 +103,9 @@ public: const css::i18n::ForbiddenCharacters& GetForbidden( const LanguageType aLang ) { - if (!m_xForbidden || m_aForbiddenLang != aLang) + if (!m_oForbidden || m_aForbiddenLang != aLang) GetForbidden_( aLang ); - return *m_xForbidden; + return *m_oForbidden; } sal_uInt16 GetRealScriptOfText( const OUString& rText, sal_Int32 nPos ) const; diff --git a/sw/qa/core/test_ToxLinkProcessor.cxx b/sw/qa/core/test_ToxLinkProcessor.cxx index a4bb1eac60f0..e493320eae90 100644 --- a/sw/qa/core/test_ToxLinkProcessor.cxx +++ b/sw/qa/core/test_ToxLinkProcessor.cxx @@ -63,7 +63,7 @@ ToxLinkProcessorTest::NoExceptionIsThrownIfTooManyLinksAreClosed() sut.CloseLink(2, URL_1, /*bRelative=*/true); CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned>(sut.m_ClosedLinks.size())); CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned>(sut.m_ClosedLinks.at(0)->mEndTextPos)); - CPPUNIT_ASSERT_MESSAGE("no links are open", !sut.m_pStartedLink); + CPPUNIT_ASSERT_MESSAGE("no links are open", !sut.m_oStartedLink); } void @@ -77,7 +77,7 @@ ToxLinkProcessorTest::AddingAndClosingTwoOverlappingLinksResultsInOneClosedLink( // (for backward compatibility) sut.CloseLink(1, URL_2, /*bRelative=*/true); CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned>(sut.m_ClosedLinks.size())); - CPPUNIT_ASSERT_MESSAGE("no links are open", !sut.m_pStartedLink); + CPPUNIT_ASSERT_MESSAGE("no links are open", !sut.m_oStartedLink); // backward compatibility: the last start is closed by the first end CPPUNIT_ASSERT_EQUAL(OUString(STYLE_NAME_2), sut.m_ClosedLinks[0]->mINetFormat.GetINetFormat()); CPPUNIT_ASSERT_EQUAL(OUString(URL_1), sut.m_ClosedLinks[0]->mINetFormat.GetValue()); diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx index a8948ede9d97..33f55a1d548d 100644 --- a/sw/source/core/bastyp/breakit.cxx +++ b/sw/source/core/bastyp/breakit.cxx @@ -78,7 +78,7 @@ void SwBreakIt::GetForbidden_( const LanguageType aLang ) LocaleDataWrapper aWrap(m_xContext, GetLanguageTag(aLang)); m_aForbiddenLang = aLang; - m_xForbidden.reset(new i18n::ForbiddenCharacters(aWrap.getForbiddenCharacters())); + m_oForbidden.emplace(aWrap.getForbiddenCharacters()); } sal_uInt16 SwBreakIt::GetRealScriptOfText( const OUString& rText, sal_Int32 nPos ) const diff --git a/sw/source/core/tox/ToxLinkProcessor.cxx b/sw/source/core/tox/ToxLinkProcessor.cxx index 731a7c8a88c4..6d431e997651 100644 --- a/sw/source/core/tox/ToxLinkProcessor.cxx +++ b/sw/source/core/tox/ToxLinkProcessor.cxx @@ -20,14 +20,13 @@ namespace sw { void ToxLinkProcessor::StartNewLink(sal_Int32 startPosition, const OUString& characterStyle) { - SAL_INFO_IF(m_pStartedLink, "sw.core", "ToxLinkProcessor: LS without LE"); - m_pStartedLink = std::make_unique<StartedLink>( - startPosition, characterStyle); + SAL_INFO_IF(m_oStartedLink, "sw.core", "ToxLinkProcessor: LS without LE"); + m_oStartedLink.emplace(startPosition, characterStyle); } void ToxLinkProcessor::CloseLink(sal_Int32 endPosition, const OUString& url, bool bRelative) { - if (m_pStartedLink == nullptr) + if (!m_oStartedLink) { SAL_INFO("sw.core", "ToxLinkProcessor: LE without LS"); return; @@ -53,15 +52,15 @@ void ToxLinkProcessor::CloseLink(sal_Int32 endPosition, const OUString& url, boo } std::unique_ptr<ClosedLink> pClosedLink( - new ClosedLink(uri, m_pStartedLink->mStartPosition, endPosition)); + new ClosedLink(uri, m_oStartedLink->mStartPosition, endPosition)); - const OUString& characterStyle = m_pStartedLink->mCharacterStyle; + const OUString& characterStyle = m_oStartedLink->mCharacterStyle; sal_uInt16 poolId = ObtainPoolId(characterStyle); pClosedLink->mINetFormat.SetVisitedFormatAndId(characterStyle, poolId); pClosedLink->mINetFormat.SetINetFormatAndId(characterStyle, poolId); m_ClosedLinks.push_back(std::move(pClosedLink)); - m_pStartedLink.reset(); + m_oStartedLink.reset(); } sal_uInt16 diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index bb620b31a4c1..2b6afa848414 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -300,7 +300,7 @@ public: const TOXTypes m_eTOXType; bool m_bIsDescriptor; SwDoc* m_pDoc; - std::unique_ptr<SwDocIndexDescriptorProperties_Impl> m_pProps; + std::optional<SwDocIndexDescriptorProperties_Impl> m_oProps; uno::WeakReference<container::XIndexReplace> m_wStyleAccess; uno::WeakReference<container::XIndexReplace> m_wTokenAccess; @@ -310,9 +310,9 @@ public: , m_eTOXType(eType) , m_bIsDescriptor(nullptr == pBaseSection) , m_pDoc(&rDoc) - , m_pProps(m_bIsDescriptor - ? new SwDocIndexDescriptorProperties_Impl(rDoc.GetTOXType(eType, 0)) - : nullptr) + , m_oProps(m_bIsDescriptor + ? std::optional<SwDocIndexDescriptorProperties_Impl>(rDoc.GetTOXType(eType, 0)) + : std::nullopt) { if(m_pFormat) StartListening(m_pFormat->GetNotifier()); @@ -333,7 +333,7 @@ public: { SwSectionFormat *const pSectionFormat(GetSectionFormat()); SwTOXBase *const pTOXSection( m_bIsDescriptor - ? &m_pProps->GetTOXBase() + ? &const_cast<SwDocIndexDescriptorProperties_Impl&>(*m_oProps).GetTOXBase() : (pSectionFormat ? static_cast<SwTOXBaseSection*>(pSectionFormat->GetSection()) : nullptr)); @@ -584,7 +584,7 @@ SwXDocumentIndex::setPropertyValue( } else { - m_pImpl->m_pProps->SetTypeName(sNewName); + m_pImpl->m_oProps->SetTypeName(sNewName); } } break; @@ -889,7 +889,7 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) } else if (m_pImpl->m_bIsDescriptor) { - pTOXBase = &m_pImpl->m_pProps->GetTOXBase(); + pTOXBase = &m_pImpl->m_oProps->GetTOXBase(); } if(pTOXBase) { @@ -940,7 +940,7 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) { OUString sTmp((!m_pImpl->m_bIsDescriptor) ? pTOXBase->GetTOXType()->GetTypeName() - : m_pImpl->m_pProps->GetTypeName()); + : m_pImpl->m_oProps->GetTypeName()); //I18N lcl_ConvertTOUNameToProgrammaticName(sTmp); aRet <<= sTmp; @@ -1337,26 +1337,26 @@ SwXDocumentIndex::attach(const uno::Reference< text::XTextRange > & xTextRange) UnoActionContext aAction(pDoc); - SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase(); + SwTOXBase & rTOXBase = m_pImpl->m_oProps->GetTOXBase(); SwTOXType const*const pTOXType = rTOXBase.GetTOXType(); if ((TOX_USER == pTOXType->GetType()) && - m_pImpl->m_pProps->GetTypeName() != pTOXType->GetTypeName()) + m_pImpl->m_oProps->GetTypeName() != pTOXType->GetTypeName()) { - lcl_ReAssignTOXType(*pDoc, rTOXBase, m_pImpl->m_pProps->GetTypeName()); + lcl_ReAssignTOXType(*pDoc, rTOXBase, m_pImpl->m_oProps->GetTypeName()); } //TODO: apply Section attributes (columns and background) SwTOXBaseSection *const pTOX = pDoc->InsertTableOf( aPam, rTOXBase, nullptr, false, m_pImpl->m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); - pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_pProps->GetTOXBase().GetTOXName()); + pDoc->SetTOXBaseName(*pTOX, m_pImpl->m_oProps->GetTOXBase().GetTOXName()); // update page numbers m_pImpl->SetSectionFormat(*pTOX->GetFormat()); pTOX->GetFormat()->SetXObject(static_cast< ::cppu::OWeakObject*>(this)); pTOX->UpdatePageNum(); - m_pImpl->m_pProps.reset(); + m_pImpl->m_oProps.reset(); m_pImpl->m_pDoc = pDoc; m_pImpl->m_bIsDescriptor = false; } @@ -1425,7 +1425,7 @@ OUString SAL_CALL SwXDocumentIndex::getName() SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() ); if (m_pImpl->m_bIsDescriptor) { - return m_pImpl->m_pProps->GetTOXBase().GetTOXName(); + return m_pImpl->m_oProps->GetTOXBase().GetTOXName(); } if(!pSectionFormat) @@ -1449,7 +1449,7 @@ SwXDocumentIndex::setName(const OUString& rName) SwSectionFormat *const pSectionFormat( m_pImpl->GetSectionFormat() ); if (m_pImpl->m_bIsDescriptor) { - m_pImpl->m_pProps->GetTOXBase().SetTOXName(rName); + m_pImpl->m_oProps->GetTOXBase().SetTOXName(rName); } else if (pSectionFormat) { diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index d8ae5938d6dd..35621217ece1 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -636,7 +636,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp, if ( (68 == aRes.nSprmId) || (0x6A03 == aRes.nSprmId) ) { Read_PicLoc(aRes.nSprmId, aRes.pMemPos + - m_xSprmParser->DistanceToData(aRes.nSprmId), 4); + m_oSprmParser->DistanceToData(aRes.nSprmId), 4); // Ok, that's what we were looking for. Now let's get // out of here! break; @@ -1086,7 +1086,7 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj, WW8PLCFx_Cp_FKP* pChp = m_xPlcxMan->GetChpPLCF(); WW8PLCFxDesc aDesc; pChp->GetSprms( &aDesc ); - WW8SprmIter aSprmIter(aDesc.pMemPos, aDesc.nSprmsLen, *m_xSprmParser); + WW8SprmIter aSprmIter(aDesc.pMemPos, aDesc.nSprmsLen, *m_oSprmParser); for( int nLoop = 0; nLoop < 2; ++nLoop ) { diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index aac252d164a1..7c07fc0e94ec 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -5151,7 +5151,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss) RedlineFlags eMode = RedlineFlags::ShowInsert | RedlineFlags::ShowDelete; - m_xSprmParser.reset(new wwSprmParser(*m_xWwFib)); + m_oSprmParser.emplace(*m_xWwFib); // Set handy helper variables m_bVer6 = (6 == m_xWwFib->m_nVersion); @@ -5454,7 +5454,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss) m_xWDop.reset(); m_xFonts.reset(); m_xAtnNames.reset(); - m_xSprmParser.reset(); + m_oSprmParser.reset(); m_xProgress.reset(); m_pDataStream = nullptr; diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index a06d9ffce17a..ad5d59c9813a 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1208,7 +1208,7 @@ private: /* Knows how to split a series of bytes into sprms and their arguments */ - std::unique_ptr<wwSprmParser> m_xSprmParser; + std::optional<wwSprmParser> m_oSprmParser; /* Creates unique names to give to graphics diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index dee6138bc2b1..b19b2859048e 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -2088,7 +2088,7 @@ bool SwWW8ImplReader::ImportFormulaControl(WW8FormulaControl &aFormula, if ( (68 == aRes.nSprmId) || (0x6A03 == aRes.nSprmId) ) { Read_PicLoc( aRes.nSprmId, aRes.pMemPos + - m_xSprmParser->DistanceToData(aRes.nSprmId), 4); + m_oSprmParser->DistanceToData(aRes.nSprmId), 4); break; } } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index bdf8607f4d5b..78bd8b8a2dba 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -6202,14 +6202,14 @@ void SwWW8ImplReader::EndSprm( sal_uInt16 nId ) short SwWW8ImplReader::ImportSprm(const sal_uInt8* pPos, sal_Int32 nMemLen, sal_uInt16 nId) { if (!nId) - nId = m_xSprmParser->GetSprmId(pPos); + nId = m_oSprmParser->GetSprmId(pPos); OSL_ENSURE( nId != 0xff, "Sprm FF !!!!" ); const SprmReadInfo& rSprm = GetSprmReadInfo(nId); - sal_Int32 nFixedLen = m_xSprmParser->DistanceToData(nId); - sal_Int32 nL = m_xSprmParser->GetSprmSize(nId, pPos, nMemLen); + sal_Int32 nFixedLen = m_oSprmParser->DistanceToData(nId); + sal_Int32 nL = m_oSprmParser->GetSprmSize(nId, pPos, nMemLen); if (rSprm.pReadFnc) (this->*rSprm.pReadFnc)(nId, pPos + nFixedLen, nL - nFixedLen); diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index 4d8542eee6fb..d2e6b751cfef 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -103,7 +103,7 @@ IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, SwOneExampleFrame&, void { OUString sTmp = "IndexSection_" + OUString::number(i); uno::Any aSection = xSections->getByName( sTmp ); - aSection >>= m_vTypeData[i].m_pxIndexSections->xContainerSection; + aSection >>= m_vTypeData[i].m_oIndexSections->xContainerSection; } uno::Reference< text::XDocumentIndexesSupplier > xIdxSupp(xModel, uno::UNO_QUERY); uno::Reference< container::XIndexAccess > xIdxs = xIdxSupp->getDocumentIndexes(); @@ -143,17 +143,17 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( "com.sun.star.text.Bibliography" }; - OSL_ENSURE(m_vTypeData[nTOXIndex].m_pxIndexSections && - m_vTypeData[nTOXIndex].m_pxIndexSections->xContainerSection.is(), + OSL_ENSURE(m_vTypeData[nTOXIndex].m_oIndexSections && + m_vTypeData[nTOXIndex].m_oIndexSections->xContainerSection.is(), "Section not created"); uno::Reference< frame::XModel > & xModel = m_xExampleFrame->GetModel(); bool bInitialCreate = true; - if(!m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex.is()) + if(!m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.is()) { bInitialCreate = true; - if(!m_vTypeData[nTOXIndex].m_pxIndexSections->xContainerSection.is()) + if(!m_vTypeData[nTOXIndex].m_oIndexSections->xContainerSection.is()) throw uno::RuntimeException(); - uno::Reference< text::XTextRange > xAnchor = m_vTypeData[nTOXIndex].m_pxIndexSections->xContainerSection->getAnchor(); + uno::Reference< text::XTextRange > xAnchor = m_vTypeData[nTOXIndex].m_oIndexSections->xContainerSection->getAnchor(); xAnchor = xAnchor->getStart(); uno::Reference< text::XTextCursor > xCursor = xAnchor->getText()->createTextCursorByRange(xAnchor); @@ -161,20 +161,20 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( OUString sIndexTypeName(OUString::createFromAscii( IndexServiceNames[ nTOXIndex <= TOX_AUTHORITIES ? nTOXIndex : TOX_USER] )); - m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex.set(xFact->createInstance(sIndexTypeName), uno::UNO_QUERY); - uno::Reference< text::XTextContent > xContent = m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex; + m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.set(xFact->createInstance(sIndexTypeName), uno::UNO_QUERY); + uno::Reference< text::XTextContent > xContent = m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex; xCursor->getText()->insertTextContent(xCursor, xContent, false); } for(sal_uInt16 i = 0 ; i <= TOX_AUTHORITIES; i++) { - uno::Reference< beans::XPropertySet > xSectPr(m_vTypeData[i].m_pxIndexSections->xContainerSection, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xSectPr(m_vTypeData[i].m_oIndexSections->xContainerSection, uno::UNO_QUERY); if(xSectPr.is()) { xSectPr->setPropertyValue(UNO_NAME_IS_VISIBLE, Any(i == nTOXIndex)); } } // set properties - uno::Reference< beans::XPropertySet > xIdxProps(m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex, uno::UNO_QUERY); + uno::Reference< beans::XPropertySet > xIdxProps(m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex, uno::UNO_QUERY); uno::Reference< beans::XPropertySetInfo > xInfo = xIdxProps->getPropertySetInfo(); SwTOXDescription& rDesc = GetTOXDescription(m_eCurrentTOXType); SwTOIOptions nIdxOptions = rDesc.GetIndexOptions(); @@ -382,7 +382,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( pForm->GetTemplate(i + nOffset)); } } - m_vTypeData[nTOXIndex].m_pxIndexSections->xDocumentIndex->update(); + m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex->update(); } catch (const Exception&) diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 1b21652bcb0b..9955a85cd3d3 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -230,7 +230,7 @@ SwMultiTOXTabDialog::SwMultiTOXTabDialog(weld::Widget* pParent, const SfxItemSet } for(int i = m_vTypeData.size() - 1; i > -1; i--) { - m_vTypeData[i].m_pxIndexSections.reset(new SwIndexSections_Impl); + m_vTypeData[i].m_oIndexSections.emplace(); if(pCurTOX) { m_eCurrentTOXType.eType = pCurTOX->GetType(); diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 29e2a770b469..eb7d61ba44c5 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -506,7 +506,7 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo OUString sDesc; if( m_pWrtShell->GetURLFromButton( sURL, sDesc ) ) { - m_pBookmark.reset(new INetBookmark( sURL, sDesc )); + m_oBookmark.emplace( sURL, sDesc ); m_eBufferType = TransferBufferType::InetField; } } @@ -534,9 +534,9 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo !m_pWrtShell->GetView().GetDocShell()->IsReadOnly(); if( m_pWrtShell->GetContentAtPos( aPos, aContentAtPos, bSelect ) ) { - m_pBookmark.reset(new INetBookmark( + m_oBookmark.emplace( static_cast<const SwFormatINetFormat*>(aContentAtPos.aFnd.pAttr)->GetValue(), - aContentAtPos.sStr )); + aContentAtPos.sStr ); m_eBufferType = TransferBufferType::InetField; if( bSelect ) m_pWrtShell->SelectTextAttr( RES_TXTATR_INETFMT ); @@ -661,8 +661,8 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo case SotClipboardFormatId::FILECONTENT: case SotClipboardFormatId::UNIFORMRESOURCELOCATOR: case SotClipboardFormatId::SIMPLE_FILE: - if( (TransferBufferType::InetField & m_eBufferType) && m_pBookmark ) - bOK = SetINetBookmark( *m_pBookmark, rFlavor ); + if( (TransferBufferType::InetField & m_eBufferType) && m_oBookmark ) + bOK = SetINetBookmark( *m_oBookmark, rFlavor ); break; case SotClipboardFormatId::EMBED_SOURCE: @@ -3904,8 +3904,8 @@ bool SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, if( rSh.GetFormatFromObj( rDragPt ) ) { INetBookmark aTmp; - if( (TransferBufferType::InetField & m_eBufferType) && m_pBookmark ) - aTmp = *m_pBookmark; + if( (TransferBufferType::InetField & m_eBufferType) && m_oBookmark ) + aTmp = *m_oBookmark; // select target graphic if( rSh.SelectObj( rDragPt ) ) diff --git a/sw/source/uibase/inc/conttree.hxx b/sw/source/uibase/inc/conttree.hxx index c924241d0153..8aed949f732f 100644 --- a/sw/source/uibase/inc/conttree.hxx +++ b/sw/source/uibase/inc/conttree.hxx @@ -34,6 +34,7 @@ #include <svx/sdr/overlay/overlayobject.hxx> #include <editsh.hxx> +#include <edglbldc.hxx> class SwWrtShell; class SwContentType; @@ -42,7 +43,6 @@ class SwNavigationConfig; class Menu; class ToolBox; class SwGlblDocContents; -class SwGlblDocContent; class SfxObjectShell; class SdrObject; @@ -326,7 +326,7 @@ private: SwWrtShell* m_pActiveShell; std::unique_ptr<SwGlblDocContents> m_pSwGlblDocContents; // array with sorted content - std::unique_ptr<SwGlblDocContent> m_pDocContent; + std::optional<SwGlblDocContent> m_oDocContent; std::unique_ptr<sfx2::DocumentInserter> m_pDocInserter; static const SfxObjectShell* s_pShowShell; diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx index 375ca33a128d..86531267af9d 100644 --- a/sw/source/uibase/inc/swdtflvr.hxx +++ b/sw/source/uibase/inc/swdtflvr.hxx @@ -29,6 +29,7 @@ #include <o3tl/deleter.hxx> #include <o3tl/typed_flags_set.hxx> #include <svx/swframetypes.hxx> +#include <svl/urlbmk.hxx> #include <memory> #include <optional> @@ -36,7 +37,6 @@ class Graphic; class ImageMap; -class INetBookmark; class INetImage; class SfxAbstractPasteDialog; class SwDoc; @@ -88,7 +88,7 @@ class SW_DLLPUBLIC SwTransferable final : public TransferableHelper std::optional<Graphic> m_oClpGraphic; std::optional<Graphic> m_oClpBitmap; Graphic *m_pOrigGraphic; - std::unique_ptr<INetBookmark> m_pBookmark; // URL and description! + std::optional<INetBookmark> m_oBookmark; // URL and description! std::unique_ptr<ImageMap> m_pImageMap; std::unique_ptr<INetImage> m_pTargetURL; diff --git a/sw/source/uibase/inc/swuicnttab.hxx b/sw/source/uibase/inc/swuicnttab.hxx index 644810b8c96d..7a9d30fcd94b 100644 --- a/sw/source/uibase/inc/swuicnttab.hxx +++ b/sw/source/uibase/inc/swuicnttab.hxx @@ -61,7 +61,7 @@ class SwMultiTOXTabDialog final : public SfxTabDialogController { std::unique_ptr<SwForm> m_pForm; std::unique_ptr<SwTOXDescription> m_pDescription; - std::unique_ptr<SwIndexSections_Impl> m_pxIndexSections; + std::optional<SwIndexSections_Impl> m_oIndexSections; }; std::vector<TypeData> m_vTypeData; diff --git a/sw/source/uibase/sidebar/TableEditPanel.cxx b/sw/source/uibase/sidebar/TableEditPanel.cxx index 22b45f7419b4..61dcd2d4e52a 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.cxx +++ b/sw/source/uibase/sidebar/TableEditPanel.cxx @@ -47,7 +47,7 @@ void TableEditPanel::NotifyItemUpdate(const sal_uInt16 nSID, const SfxItemState case SID_ATTR_TABLE_ROW_HEIGHT: { bool bDisabled = eState == SfxItemState::DISABLED; - m_xRowHeightEdit->set_sensitive(!bDisabled); + m_aRowHeightEdit.set_sensitive(!bDisabled); if (pState && eState >= SfxItemState::DEFAULT) { @@ -55,19 +55,19 @@ void TableEditPanel::NotifyItemUpdate(const sal_uInt16 nSID, const SfxItemState if (pItem) { tools::Long nNewHeight = pItem->GetValue(); - nNewHeight = m_xRowHeightEdit->normalize(nNewHeight); - m_xRowHeightEdit->set_value(nNewHeight, FieldUnit::TWIP); + nNewHeight = m_aRowHeightEdit.normalize(nNewHeight); + m_aRowHeightEdit.set_value(nNewHeight, FieldUnit::TWIP); } } else if (eState != SfxItemState::DISABLED) - m_xRowHeightEdit->set_text(""); + m_aRowHeightEdit.set_text(""); break; } case SID_ATTR_TABLE_COLUMN_WIDTH: { bool bDisabled = eState == SfxItemState::DISABLED; - m_xColumnWidthEdit->set_sensitive(!bDisabled); + m_aColumnWidthEdit.set_sensitive(!bDisabled); if (pState && eState >= SfxItemState::DEFAULT) { @@ -75,12 +75,12 @@ void TableEditPanel::NotifyItemUpdate(const sal_uInt16 nSID, const SfxItemState if (pItem) { tools::Long nNewWidth = pItem->GetValue(); - nNewWidth = m_xColumnWidthEdit->normalize(nNewWidth); - m_xColumnWidthEdit->set_value(nNewWidth, FieldUnit::TWIP); + nNewWidth = m_aColumnWidthEdit.normalize(nNewWidth); + m_aColumnWidthEdit.set_value(nNewWidth, FieldUnit::TWIP); } } else if (eState != SfxItemState::DISABLED) - m_xColumnWidthEdit->set_text(""); + m_aColumnWidthEdit.set_text(""); break; } @@ -92,10 +92,8 @@ TableEditPanel::TableEditPanel(weld::Widget* pParent, SfxBindings* pBindings) : PanelLayout(pParent, "TableEditPanel", "modules/swriter/ui/sidebartableedit.ui") , m_pBindings(pBindings) - , m_xRowHeightEdit( - new SvxRelativeField(m_xBuilder->weld_metric_spin_button("rowheight", FieldUnit::CM))) - , m_xColumnWidthEdit( - new SvxRelativeField(m_xBuilder->weld_metric_spin_button("columnwidth", FieldUnit::CM))) + , m_aRowHeightEdit(m_xBuilder->weld_metric_spin_button("rowheight", FieldUnit::CM)) + , m_aColumnWidthEdit(m_xBuilder->weld_metric_spin_button("columnwidth", FieldUnit::CM)) , m_xInsert(m_xBuilder->weld_toolbar("insert")) , m_xInsertDispatch(new ToolbarUnoDispatcher(*m_xInsert, *m_xBuilder, rxFrame)) , m_xSelect(m_xBuilder->weld_toolbar("select")) @@ -143,36 +141,33 @@ TableEditPanel::TableEditPanel(weld::Widget* pParent, void TableEditPanel::InitRowHeightToolitem() { Link<weld::MetricSpinButton&, void> aLink = LINK(this, TableEditPanel, RowHeightMofiyHdl); - m_xRowHeightEdit->connect_value_changed(aLink); + m_aRowHeightEdit.connect_value_changed(aLink); FieldUnit eFieldUnit = SW_MOD()->GetUsrPref(false)->GetMetric(); - m_xRowHeightEdit->SetFieldUnit(eFieldUnit); + m_aRowHeightEdit.SetFieldUnit(eFieldUnit); - m_xRowHeightEdit->set_min(MINLAY, FieldUnit::TWIP); - m_xRowHeightEdit->set_max(SAL_MAX_INT32, FieldUnit::TWIP); + m_aRowHeightEdit.set_min(MINLAY, FieldUnit::TWIP); + m_aRowHeightEdit.set_max(SAL_MAX_INT32, FieldUnit::TWIP); - limitWidthForSidebar(*m_xRowHeightEdit); + limitWidthForSidebar(m_aRowHeightEdit); } void TableEditPanel::InitColumnWidthToolitem() { Link<weld::MetricSpinButton&, void> aLink = LINK(this, TableEditPanel, ColumnWidthMofiyHdl); - m_xColumnWidthEdit->connect_value_changed(aLink); + m_aColumnWidthEdit.connect_value_changed(aLink); FieldUnit eFieldUnit = SW_MOD()->GetUsrPref(false)->GetMetric(); - m_xColumnWidthEdit->SetFieldUnit(eFieldUnit); + m_aColumnWidthEdit.SetFieldUnit(eFieldUnit); - m_xColumnWidthEdit->set_min(MINLAY, FieldUnit::TWIP); - m_xColumnWidthEdit->set_max(SAL_MAX_INT32, FieldUnit::TWIP); + m_aColumnWidthEdit.set_min(MINLAY, FieldUnit::TWIP); + m_aColumnWidthEdit.set_max(SAL_MAX_INT32, FieldUnit::TWIP); - limitWidthForSidebar(*m_xColumnWidthEdit); + limitWidthForSidebar(m_aColumnWidthEdit); } TableEditPanel::~TableEditPanel() { - m_xRowHeightEdit.reset(); - m_xColumnWidthEdit.reset(); - m_xMiscDispatch.reset(); m_xMisc.reset(); @@ -215,7 +210,7 @@ TableEditPanel::~TableEditPanel() IMPL_LINK_NOARG(TableEditPanel, RowHeightMofiyHdl, weld::MetricSpinButton&, void) { SwTwips nNewHeight = static_cast<SwTwips>( - m_xRowHeightEdit->denormalize(m_xRowHeightEdit->get_value(FieldUnit::TWIP))); + m_aRowHeightEdit.denormalize(m_aRowHeightEdit.get_value(FieldUnit::TWIP))); SfxUInt32Item aRowHeight(SID_ATTR_TABLE_ROW_HEIGHT); aRowHeight.SetValue(nNewHeight); @@ -226,7 +221,7 @@ IMPL_LINK_NOARG(TableEditPanel, RowHeightMofiyHdl, weld::MetricSpinButton&, void IMPL_LINK_NOARG(TableEditPanel, ColumnWidthMofiyHdl, weld::MetricSpinButton&, void) { SwTwips nNewWidth = static_cast<SwTwips>( - m_xColumnWidthEdit->denormalize(m_xColumnWidthEdit->get_value(FieldUnit::TWIP))); + m_aColumnWidthEdit.denormalize(m_aColumnWidthEdit.get_value(FieldUnit::TWIP))); SfxUInt32Item aColumnWidth(SID_ATTR_TABLE_COLUMN_WIDTH); aColumnWidth.SetValue(nNewWidth); diff --git a/sw/source/uibase/sidebar/TableEditPanel.hxx b/sw/source/uibase/sidebar/TableEditPanel.hxx index 01098df5e60f..140de8653896 100644 --- a/sw/source/uibase/sidebar/TableEditPanel.hxx +++ b/sw/source/uibase/sidebar/TableEditPanel.hxx @@ -42,8 +42,8 @@ private: SfxBindings* m_pBindings; - std::unique_ptr<SvxRelativeField> m_xRowHeightEdit; - std::unique_ptr<SvxRelativeField> m_xColumnWidthEdit; + SvxRelativeField m_aRowHeightEdit; + SvxRelativeField m_aColumnWidthEdit; std::unique_ptr<weld::Toolbar> m_xInsert; std::unique_ptr<ToolbarUnoDispatcher> m_xInsertDispatch; std::unique_ptr<weld::Toolbar> m_xSelect; diff --git a/sw/source/uibase/utlui/glbltree.cxx b/sw/source/uibase/utlui/glbltree.cxx index 22559a3f709e..d59a0ccfdc4a 100644 --- a/sw/source/uibase/utlui/glbltree.cxx +++ b/sw/source/uibase/utlui/glbltree.cxx @@ -577,9 +577,9 @@ void SwGlobalTree::ExecuteContextMenuAction(std::string_view rSelectedPopupEntry // If a RequestHelp is called during the dialogue, // then the content gets lost. Because of that a copy // is created in which only the DocPos is set correctly. - std::unique_ptr<SwGlblDocContent> pContCopy; + std::optional<SwGlblDocContent> oContCopy; if(pCont) - pContCopy.reset(new SwGlblDocContent(pCont->GetDocPos())); + oContCopy.emplace(pCont->GetDocPos()); SfxDispatcher& rDispatch = *m_pActiveShell->GetView().GetViewFrame().GetDispatcher(); sal_uInt16 nSlot = 0; if (rSelectedPopupEntry == "updatesel") @@ -659,7 +659,7 @@ void SwGlobalTree::ExecuteContextMenuAction(std::string_view rSelectedPopupEntry } else if (rSelectedPopupEntry == "insertindex") { - if(pContCopy) + if(oContCopy) { SfxItemSetFixed< RES_FRM_SIZE, RES_FRM_SIZE, @@ -683,15 +683,15 @@ void SwGlobalTree::ExecuteContextMenuAction(std::string_view rSelectedPopupEntry SwTOXMgr aMgr(m_pActiveShell); SwTOXBase* pToInsert = nullptr; if(aMgr.UpdateOrInsertTOX(rDesc, &pToInsert, pDlg->GetOutputItemSet())) - m_pActiveShell->InsertGlobalDocContent( *pContCopy, *pToInsert ); + m_pActiveShell->InsertGlobalDocContent( *oContCopy, *pToInsert ); } pCont = nullptr; } } else if (rSelectedPopupEntry == "insertfile") { - m_pDocContent = std::move(pContCopy); - InsertRegion( m_pDocContent.get() ); + m_oDocContent = std::move(oContCopy); + InsertRegion( &*m_oDocContent ); pCont = nullptr; } else if (rSelectedPopupEntry == "insertnewfile") @@ -1116,8 +1116,8 @@ IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, vo + OUStringChar(sfx2::cTokenSeparator); pFileNames[nPos++] = sFileName; } - InsertRegion( m_pDocContent.get(), aFileNames ); - m_pDocContent.reset(); + InsertRegion( &*m_oDocContent, aFileNames ); + m_oDocContent.reset(); } void SwGlobalTree::Notify(SfxBroadcaster& rBC, SfxHint const& rHint) |