diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2023-06-15 11:36:43 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2023-06-16 00:48:56 +0200 |
commit | 6c4edf7f86912084371e15be7321e9c4764a9ca6 (patch) | |
tree | e0e8dbb1d31b22de364b63837f9ce624144516b7 /editeng/source/uno | |
parent | d934aeace6e7049db3959421538ae382cb97b1d1 (diff) |
tdf#103064 sw,editeng: enable UNO API and ODF import/export
Change-Id: Icf30e1f30fe6bf6a7d96d14b975954613cd68b70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153157
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'editeng/source/uno')
-rw-r--r-- | editeng/source/uno/unoedprx.cxx | 14 | ||||
-rw-r--r-- | editeng/source/uno/unofored.cxx | 14 | ||||
-rw-r--r-- | editeng/source/uno/unoforou.cxx | 14 | ||||
-rw-r--r-- | editeng/source/uno/unotext.cxx | 54 |
4 files changed, 93 insertions, 3 deletions
diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx index 5bddd24fca7a..20d5df281bce 100644 --- a/editeng/source/uno/unoedprx.cxx +++ b/editeng/source/uno/unoedprx.cxx @@ -530,6 +530,20 @@ void SvxAccessibleTextAdapter::GetPortions( sal_Int32 nPara, std::vector<sal_Int mpTextForwarder->GetPortions( nPara, rList ); } +OUString SvxAccessibleTextAdapter::GetStyleSheet(sal_Int32 nPara) const +{ + assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder"); + + return mpTextForwarder->GetStyleSheet(nPara); +} + +void SvxAccessibleTextAdapter::SetStyleSheet(sal_Int32 nPara, const OUString& rStyleName) +{ + assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder"); + + mpTextForwarder->SetStyleSheet(nPara, rStyleName); +} + SfxItemState SvxAccessibleTextAdapter::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const { assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder"); diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx index 5e1824ff5dca..66f4fde2bf78 100644 --- a/editeng/source/uno/unofored.cxx +++ b/editeng/source/uno/unofored.cxx @@ -124,6 +124,20 @@ void SvxEditEngineForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_Int32 rEditEngine.GetPortions( nPara, rList ); } +OUString SvxEditEngineForwarder::GetStyleSheet(sal_Int32 nPara) const +{ + if (auto pStyle = rEditEngine.GetStyleSheet(nPara)) + return pStyle->GetName(); + return OUString(); +} + +void SvxEditEngineForwarder::SetStyleSheet(sal_Int32 nPara, const OUString& rStyleName) +{ + auto pStyleSheetPool = rEditEngine.GetStyleSheetPool(); + if (auto pStyle = pStyleSheetPool ? pStyleSheetPool->Find(rStyleName, SfxStyleFamily::Para) : nullptr) + rEditEngine.SetStyleSheet(nPara, static_cast<SfxStyleSheet*>(pStyle)); +} + void SvxEditEngineForwarder::QuickInsertText( const OUString& rText, const ESelection& rSel ) { rEditEngine.QuickInsertText( rText, rSel ); diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx index f6d0fbb8eaea..8772ff9a77fa 100644 --- a/editeng/source/uno/unoforou.cxx +++ b/editeng/source/uno/unoforou.cxx @@ -186,6 +186,20 @@ void SvxOutlinerForwarder::GetPortions( sal_Int32 nPara, std::vector<sal_Int32>& const_cast<EditEngine&>(rOutliner.GetEditEngine()).GetPortions( nPara, rList ); } +OUString SvxOutlinerForwarder::GetStyleSheet(sal_Int32 nPara) const +{ + if (auto pStyle = rOutliner.GetStyleSheet(nPara)) + return pStyle->GetName(); + return OUString(); +} + +void SvxOutlinerForwarder::SetStyleSheet(sal_Int32 nPara, const OUString& rStyleName) +{ + auto pStyleSheetPool = rOutliner.GetStyleSheetPool(); + if (auto pStyle = pStyleSheetPool ? pStyleSheetPool->Find(rStyleName, SfxStyleFamily::Para) : nullptr) + rOutliner.SetStyleSheet(nPara, static_cast<SfxStyleSheet*>(pStyle)); +} + void SvxOutlinerForwarder::QuickInsertText( const OUString& rText, const ESelection& rSel ) { flushCache(); diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 6f78a4a66878..eb18d69903c4 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -431,7 +431,30 @@ void SvxUnoTextRangeBase::_setPropertyValue( const OUString& PropertyName, const ESelection aSel( GetSelection() ); bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END ); - if( nPara == -1 && !bParaAttrib ) + if (pMap->nWID == WID_PARASTYLENAME) + { + OUString aStyle = aValue.get<OUString>(); + + sal_Int32 nEndPara; + + if( nPara == -1 ) + { + nPara = aSel.nStartPara; + nEndPara = aSel.nEndPara; + } + else + { + // only one paragraph + nEndPara = nPara; + } + + while( nPara <= nEndPara ) + { + pForwarder->SetStyleSheet(nPara, aStyle); + nPara++; + } + } + else if ( nPara == -1 && !bParaAttrib ) { SfxItemSet aOldSet( pForwarder->GetAttribs( aSel ) ); // we have a selection and no para attribute @@ -653,6 +676,12 @@ void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertyMapEntry* pMap, } break; + case WID_PARASTYLENAME: + { + rAny <<= GetEditSource()->GetTextForwarder()->GetStyleSheet(maSelection.nStartPara); + } + break; + default: if(!GetPropertyValueHelper( *const_cast<SfxItemSet*>(&rSet), pMap, rAny, &maSelection, GetEditSource() )) rAny = SvxItemPropertySet::getPropertyValue(pMap, rSet, true, false ); @@ -780,6 +809,8 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a std::optional<SfxItemSet> pOldParaSet; std::optional<SfxItemSet> pNewParaSet; + std::optional<OUString> aStyleName; + for( ; nCount; nCount--, pPropertyNames++, pValues++ ) { const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames ); @@ -788,7 +819,11 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a { bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END ); - if( (nPara == -1) && !bParaAttrib ) + if (pMap->nWID == WID_PARASTYLENAME) + { + aStyleName.emplace((*pValues).get<OUString>()); + } + else if( (nPara == -1) && !bParaAttrib ) { if( !pNewAttrSet ) { @@ -833,7 +868,7 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a bool bNeedsUpdate = false; - if( pNewParaSet ) + if( pNewParaSet || aStyleName ) { if( pNewParaSet->Count() ) { @@ -842,6 +877,8 @@ void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& a SfxItemSet aSet( pForwarder->GetParaAttribs( nTempPara ) ); aSet.Put( *pNewParaSet ); pForwarder->SetParaAttribs( nTempPara, aSet ); + if (aStyleName) + pForwarder->SetStyleSheet(nTempPara, *aStyleName); nTempPara++; } bNeedsUpdate = true; @@ -984,6 +1021,7 @@ beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropert case WID_NUMBERINGSTARTVALUE: case WID_PARAISNUMBERINGRESTART: + case WID_PARASTYLENAME: eItemState = SfxItemState::SET; bItemStateSet = true; break; @@ -1117,6 +1155,7 @@ bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const Sf case WID_NUMBERINGSTARTVALUE: case WID_PARAISNUMBERINGRESTART: + case WID_PARASTYLENAME: eItemState = SfxItemState::SET; bItemStateSet = true; break; @@ -2310,6 +2349,15 @@ void SvxDummyTextSource::GetPortions( sal_Int32, std::vector<sal_Int32>& ) const { } +OUString SvxDummyTextSource::GetStyleSheet(sal_Int32) const +{ + return OUString(); +} + +void SvxDummyTextSource::SetStyleSheet(sal_Int32, const OUString&) +{ +} + SfxItemState SvxDummyTextSource::GetItemState( const ESelection&, sal_uInt16 ) const { return SfxItemState::UNKNOWN; |