diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-19 12:15:01 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-19 16:06:18 +0100 |
commit | 4565382ee6f8fec96f0df94c34a2567816291c2e (patch) | |
tree | 3f4f06f9f64c40a22de28300ef95f6a320cc221b /sw | |
parent | ab6176e88f78d0b3aa2490fbc7858304c2d4a437 (diff) |
sw: generalize ModelToViewHelper to handle all NonTextFieldmarks
Rename getDropDownsFor() to getNoTextFieldmarksIn().
Move some code so that sw::mark::ExpandFieldmark can expand all
fieldmarks that use CH_TXT_ATR_FORMELEMENT.
Change-Id: I8a1e28fc0ad77df3a749d9e55c306cb45187a082
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128606
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/IDocumentMarkAccess.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/inc/MarkManager.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/txtnode/modeltoviewhelper.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/unocore/unobkm.cxx | 11 |
6 files changed, 21 insertions, 17 deletions
diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx index 3a05a2053bbe..1d11734e46e9 100644 --- a/sw/inc/IDocumentMarkAccess.hxx +++ b/sw/inc/IDocumentMarkAccess.hxx @@ -328,7 +328,7 @@ class IDocumentMarkAccess virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0; virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition& pos) const=0; - virtual std::vector< ::sw::mark::IFieldmark* > getDropDownsFor(const SwPaM &rPaM) const=0; + virtual std::vector<::sw::mark::IFieldmark*> getNoTextFieldmarksIn(const SwPaM &rPaM) const=0; virtual void deleteFieldmarkAt(const SwPosition& rPos) = 0; virtual ::sw::mark::IFieldmark* changeFormFieldmarkType(::sw::mark::IFieldmark* pFieldmark, const OUString& rNewType) = 0; diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index e9c0ce701eba..5ed676719622 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1569,7 +1569,7 @@ namespace sw::mark return pMark; } - std::vector<IFieldmark*> MarkManager::getDropDownsFor(const SwPaM &rPaM) const + std::vector<IFieldmark*> MarkManager::getNoTextFieldmarksIn(const SwPaM &rPaM) const { std::vector<IFieldmark*> aRet; @@ -1582,8 +1582,11 @@ namespace sw::mark continue; IFieldmark *pMark = dynamic_cast<IFieldmark*>(pI); - if (!pMark || pMark->GetFieldname() != ODF_FORMDROPDOWN) + if (!pMark || (pMark->GetFieldname() != ODF_FORMDROPDOWN + && pMark->GetFieldname() != ODF_FORMCHECKBOX)) + { continue; + } aRet.push_back(pMark); } diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx index 0e2ffa97bf33..38c6870de628 100644 --- a/sw/source/core/inc/MarkManager.hxx +++ b/sw/source/core/inc/MarkManager.hxx @@ -94,7 +94,7 @@ namespace sw::mark { virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& rPos) const override; virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition &rPos) const override; - virtual std::vector< ::sw::mark::IFieldmark* > getDropDownsFor(const SwPaM &rPaM) const override; + virtual std::vector<::sw::mark::IFieldmark*> getNoTextFieldmarksIn(const SwPaM &rPaM) const override; virtual void deleteFieldmarkAt(const SwPosition& rPos) override; virtual ::sw::mark::IFieldmark* changeFormFieldmarkType(::sw::mark::IFieldmark* pFieldmark, const OUString& rNewType) override; diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 1c52ea7992d9..6a91d3c37dfc 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -875,6 +875,16 @@ void SwMetaPortion::Paint( const SwTextPaintInfo &rInf ) const namespace sw::mark { OUString ExpandFieldmark(IFieldmark* pBM) { + if (pBM->GetFieldname() == ODF_FORMCHECKBOX) + { + ::sw::mark::ICheckboxFieldmark const*const pCheckboxFm( + dynamic_cast<ICheckboxFieldmark const*>(pBM)); + assert(pCheckboxFm); + return pCheckboxFm->IsChecked() + ? OUString(u"\u2612") + : OUString(u"\u2610"); + } + assert(pBM->GetFieldname() == ODF_FORMDROPDOWN); const IFieldmark::parameter_map_t* const pParameters = pBM->GetParameters(); sal_Int32 nCurrentIdx = 0; const IFieldmark::parameter_map_t::const_iterator pResult = pParameters->find(OUString(ODF_FORMDROPDOWN_RESULT)); diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx b/sw/source/core/txtnode/modeltoviewhelper.cxx index a5ae25962862..846e4d1a51b1 100644 --- a/sw/source/core/txtnode/modeltoviewhelper.cxx +++ b/sw/source/core/txtnode/modeltoviewhelper.cxx @@ -281,10 +281,10 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode &rNode, //now get the dropdown formfields, get their position in the node and what the text they expand //to is SwPaM aPaM(rNode, 0, rNode, rNode.Len()); - std::vector<sw::mark::IFieldmark*> aDropDowns = - rNode.GetDoc().getIDocumentMarkAccess()->getDropDownsFor(aPaM); + std::vector<sw::mark::IFieldmark*> aNoTextFieldmarks = + rNode.GetDoc().getIDocumentMarkAccess()->getNoTextFieldmarksIn(aPaM); - for (sw::mark::IFieldmark *pMark : aDropDowns) + for (sw::mark::IFieldmark *const pMark : aNoTextFieldmarks) { const sal_Int32 nDummyCharPos = pMark->GetMarkPos().nContent.GetIndex()-1; if (aHiddenMulti.IsSelected(nDummyCharPos)) diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index b5577df6ecde..81a7cf0ac793 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -848,16 +848,7 @@ SwXFieldmark::getPresentation(sal_Bool const bShowCommand) else { OUString const type(getFieldType()); - if (type == ODF_FORMCHECKBOX) - { - ::sw::mark::ICheckboxFieldmark const*const pCheckboxFm( - dynamic_cast<ICheckboxFieldmark const*>(pMark)); - assert(pCheckboxFm); - return pCheckboxFm->IsChecked() - ? OUString(u"\u2612") - : OUString(u"\u2610"); - } - else if (type == ODF_FORMDROPDOWN) + if (type == ODF_FORMCHECKBOX || type == ODF_FORMDROPDOWN) { return sw::mark::ExpandFieldmark(const_cast<IFieldmark *>(pMark)); } |