sw/qa/extras/mailmerge/data/bookmarkcondition.fodt | 91 +++++++++++++++++++++ sw/qa/extras/mailmerge/data/bookmarkcondition.ods |binary sw/qa/extras/mailmerge/mailmerge.cxx | 30 ++++++ sw/source/core/doc/DocumentFieldsManager.cxx | 11 ++ sw/source/core/doc/docfld.cxx | 58 +++++++++++-- sw/source/core/inc/docfld.hxx | 12 ++ sw/source/core/text/porlay.cxx | 22 ----- sw/source/ui/misc/bookmark.cxx | 4 8 files changed, 195 insertions(+), 33 deletions(-)
New commits: commit 51d82e3d9a44476bfb80cf48f165c602b4bc6708 Author: Michael Stahl <[email protected]> AuthorDate: Fri Aug 20 17:09:28 2021 +0200 Commit: Michael Stahl <[email protected]> CommitDate: Tue Aug 24 11:05:20 2021 +0200 sw: evaluate bookmark conditions differently Conditions may refer to database rows in mail merge, which requires a SwDBManager to evaluate. So do it in DocumentFieldsManager::UpdateExpFieldsImpl() where the similar conditions on sections and fields are evaluated. Change the meaning of the m_bHidden flag to store the result of evaluating the condition, instead of being always true when there is a condition. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120793 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 43fc5f3aee4c06fb5983b625175d6991433945d4) Change-Id: Ib8f5483e7f68fc37c650b790b70d10af3c1e6f28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120914 Tested-by: Michael Stahl <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/qa/extras/mailmerge/data/bookmarkcondition.fodt b/sw/qa/extras/mailmerge/data/bookmarkcondition.fodt new file mode 100644 index 000000000000..0f9d5a90b1dc --- /dev/null +++ b/sw/qa/extras/mailmerge/data/bookmarkcondition.fodt @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:officeooo="http://openoffice.org/2009/office" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns :config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="ur n:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:font-face-decls> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Lohit Devanagari" svg:font-family="'Lohit Devanagari'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Source Han Serif CN" svg:font-family="'Source Han Serif CN'" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:styles> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Serif CN" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN"/> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="1.251cm" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="de" fo:country="DE" style:letter-kerning="true" style:font-name-asian="Source Han Serif CN" style:font-size-asian="10.5pt" style:language-asian="zh" style:country-asian="CN" style:font-name-complex="Lohit Devanagari" style:font-size-complex="12pt" style:language-complex="hi" style:country-complex="IN" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <style:style style:name="Table_20_Contents" style:display-name="Table Contents" style:family="paragraph" style:parent-style-name="Standard" style:class="extra"> + <style:paragraph-properties fo:orphans="0" fo:widows="0" text:number-lines="false" text:line-number="0"/> + </style:style> + + <text:notes-configuration text:note-class="footnote" style:num-format="1" text:start-value="0" text:footnotes-position="page" text:start-numbering-at="document"/> + <text:notes-configuration text:note-class="endnote" style:num-format="i" text:start-value="0"/> + <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties officeooo:rsid="001fe5a9" officeooo:paragraph-rsid="001fe5a9"/> + </style:style> + <style:style style:name="T1" style:family="text"> + <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/> + </style:style> + <style:style style:name="Sect1" style:family="section"> + <style:section-properties style:editable="false"> + <style:columns fo:column-count="1" fo:column-gap="0cm"/> + </style:section-properties> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:p text:style-name="P1"/> + <text:section text:style-name="Sect1" text:name="a" text:condition="ooow:([WM:SE_S_Berge] != "true")" text:is-hidden="true" text:display="condition"> + <text:p text:style-name="P1">In den Bergen war es anstrengend.</text:p> + </text:section> + <text:p text:style-name="P1"/> + <text:section text:style-name="Sect1" text:name="b" text:condition="ooow:([WM:SE_S_Barcelona] != "true")" text:is-hidden="true" text:display="condition"> + <text:p text:style-name="P1">In Barcelona war es schön.</text:p> + </text:section> + <text:p text:style-name="P1"/> + <text:section text:style-name="Sect1" text:name="c" text:condition="ooow:([WM:SE_S_Paris] != "true")" text:is-hidden="true" text:display="condition"> + <text:p text:style-name="P1">In Paris war es erlebnisreich.</text:p> + </text:section> + <text:p text:style-name="P1"/> + <text:p text:style-name="P1"> + <text:span text:style-name="T1">Mein Urlaub war </text:span> + <text:bookmark-start text:name="S_Berge" loext:hidden="true" loext:condition="([WM:SE_S_Berge] != "true")"/> + <text:span text:style-name="T1">anstrengend</text:span> + <text:bookmark-start text:name="S_Barcelona" loext:hidden="true" loext:condition="([WM:SE_S_Barcelona] != "true")"/> + <text:bookmark-end text:name="S_Berge"/> + <text:span text:style-name="T1">schön</text:span> + <text:bookmark-start text:name="S_Paris" loext:hidden="true" loext:condition="([WM:SE_S_Paris] != "true")"/> + <text:bookmark-end text:name="S_Barcelona"/> + <text:span text:style-name="T1">erlebnisreich</text:span> + <text:bookmark-end text:name="S_Paris"/> + <text:span text:style-name="T1">.</text:span> + </text:p> + <text:p text:style-name="P1"/> + + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/mailmerge/data/bookmarkcondition.ods b/sw/qa/extras/mailmerge/data/bookmarkcondition.ods new file mode 100644 index 000000000000..463781ed5f6e Binary files /dev/null and b/sw/qa/extras/mailmerge/data/bookmarkcondition.ods differ diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index 9c84c312ef1e..2ac7cfcaaef0 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -595,6 +595,36 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf92623, "tdf92623.odt", "10-testing-addresses CPPUNIT_ASSERT_EQUAL(sal_Int32(10), countFieldMarks); } +DECLARE_SHELL_MAILMERGE_TEST(testBookmarkCondition, "bookmarkcondition.fodt", "bookmarkcondition.ods", "data") +{ + executeMailMerge(); + + //dumpMMLayout(); + mpXmlBuffer = xmlBufferPtr(); + dumpLayout(mxMMComponent); + + xmlDocPtr pLayout( + xmlParseMemory(reinterpret_cast<const char*>(xmlBufferContent(mpXmlBuffer)), + xmlBufferLength(mpXmlBuffer))); + + // check that conditions on sections and bookmarks are evaluated the same + assertXPath(pLayout, "/root/page", 7); + assertXPath(pLayout, "/root/page[1]/body/section", 1); + assertXPath(pLayout, "/root/page[1]/body/section[1]/txt[1]/LineBreak", "Line", u"In den Bergen war es anstrengend."); + assertXPath(pLayout, "/root/page[1]/body/txt[5]/LineBreak", "Line", u"Mein Urlaub war anstrengend . "); + assertXPath(pLayout, "/root/page[3]/body/section", 1); + assertXPath(pLayout, "/root/page[3]/body/section[1]/txt[1]/LineBreak", "Line", u"In Barcelona war es schön."); + assertXPath(pLayout, "/root/page[3]/body/txt[5]/LineBreak", "Line", u"Mein Urlaub war schön . "); + assertXPath(pLayout, "/root/page[5]/body/section", 1); + assertXPath(pLayout, "/root/page[5]/body/section[1]/txt[1]/LineBreak", "Line", "In Paris war es erlebnisreich."); + assertXPath(pLayout, "/root/page[5]/body/txt[5]/LineBreak", "Line", u"Mein Urlaub war erlebnisreich . "); + assertXPath(pLayout, "/root/page[7]/body/section", 3); + assertXPath(pLayout, "/root/page[7]/body/section[1]/txt[1]/LineBreak", "Line", u"In den Bergen war es anstrengend."); + assertXPath(pLayout, "/root/page[7]/body/section[2]/txt[1]/LineBreak", "Line", u"In Barcelona war es schön."); + assertXPath(pLayout, "/root/page[7]/body/section[3]/txt[1]/LineBreak", "Line", u"In Paris war es erlebnisreich."); + assertXPath(pLayout, "/root/page[7]/body/txt[5]/LineBreak", "Line", u"Mein Urlaub war anstrengend schön erlebnisreich . "); +} + DECLARE_SHELL_MAILMERGE_TEST_SELECTION(testTdf95292, "linked-labels.odt", "10-testing-addresses.ods", "testing-addresses", 5) { // A document with two labels merged with 5 datasets should result in three pages diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx index 264ac6352f64..7723a44809ad 100644 --- a/sw/source/core/doc/DocumentFieldsManager.cxx +++ b/sw/source/core/doc/DocumentFieldsManager.cxx @@ -1042,6 +1042,17 @@ void DocumentFieldsManager::UpdateExpFieldsImpl( } continue; } + ::sw::mark::IBookmark *const pBookmark( + const_cast<::sw::mark::IBookmark *>(it->GetBookmark())); + if (pBookmark) + { + SwSbxValue aValue(aCalc.Calculate(pBookmark->GetHideCondition())); + if (!aValue.IsVoidValue()) + { + pBookmark->Hide(aValue.GetBool()); + } + continue; + } SwTextField* pTextField = const_cast<SwTextField*>(it->GetTextField()); if( !pTextField ) diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index a5e7376f786f..f3bf0c6bd6a4 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -31,6 +31,7 @@ #include <doc.hxx> #include <IDocumentUndoRedo.hxx> #include <IDocumentFieldsAccess.hxx> +#include <IDocumentMarkAccess.hxx> #include <IDocumentState.hxx> #include <IDocumentLayoutAccess.hxx> #include <cntfrm.hxx> @@ -115,6 +116,24 @@ SetGetExpField::SetGetExpField( const SwSectionNode& rSectNd, } } +SetGetExpField::SetGetExpField(::sw::mark::IBookmark const& rBookmark, + SwPosition const*const pPos) +{ + eSetGetExpFieldType = BOOKMARK; + CNTNT.pBookmark = &rBookmark; + + if (pPos) + { + nNode = pPos->nNode.GetIndex(); + nContent = pPos->nContent.GetIndex(); + } + else + { + nNode = rBookmark.GetMarkStart().nNode.GetIndex(); + nContent = rBookmark.GetMarkStart().nContent.GetIndex();; + } +} + SetGetExpField::SetGetExpField( const SwTableBox& rTBox ) { eSetGetExpFieldType = TABLEBOX; @@ -276,6 +295,10 @@ const SwNode* SetGetExpField::GetNodeFromContent() const pRet = CNTNT.pSection->GetFormat()->GetSectionNode(); break; + case BOOKMARK: + pRet = &CNTNT.pBookmark->GetMarkStart().nNode.GetNode(); + break; + case CRSRPOS: pRet = &CNTNT.pPos->nNode.GetNode(); break; @@ -317,6 +340,9 @@ sal_Int32 SetGetExpField::GetCntPosFromContent() const case TEXTTOXMARK: nRet = CNTNT.pTextTOX->GetStart(); break; + case BOOKMARK: + nRet = CNTNT.pBookmark->GetMarkStart().nContent.GetIndex(); + break; case CRSRPOS: nRet = CNTNT.pPos->nContent.GetIndex(); break; @@ -877,7 +903,20 @@ void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode ) // add all to the list so that they are sorted for (const auto &nId : aTmpArr) { - GetBodyNode( *rDoc.GetNodes()[ nId ]->GetSectionNode() ); + SwSectionNode const& rSectionNode(*rDoc.GetNodes()[ nId ]->GetSectionNode()); + GetBodyNodeGeneric(rSectionNode, rSectionNode); + } + + // bookmarks with hide conditions, handle similar to sections + auto const& rIDMA(*rDoc.getIDocumentMarkAccess()); + for (auto it = rIDMA.getBookmarksBegin(); it != rIDMA.getBookmarksEnd(); ++it) + { + auto const pBookmark(dynamic_cast<::sw::mark::IBookmark const*>(it->get())); + assert(pBookmark); + if (!pBookmark->GetHideCondition().isEmpty()) + { + GetBodyNodeGeneric((*it)->GetMarkStart().nNode.GetNode(), *pBookmark); + } } } @@ -1060,19 +1099,22 @@ void SwDocUpdateField::GetBodyNode( const SwTextField& rTField, SwFieldIds nFiel delete pNew; } -void SwDocUpdateField::GetBodyNode( const SwSectionNode& rSectNd ) +template<typename T> +void SwDocUpdateField::GetBodyNodeGeneric(SwNode const& rNode, T const& rCond) { - const SwDoc& rDoc = *rSectNd.GetDoc(); + const SwDoc& rDoc = *rNode.GetDoc(); SetGetExpField* pNew = nullptr; - if( rSectNd.GetIndex() < rDoc.GetNodes().GetEndOfExtras().GetIndex() ) + if (rNode.GetIndex() < rDoc.GetNodes().GetEndOfExtras().GetIndex()) { do { // middle check loop // we need to get the anchor first // create index to determine the TextNode - SwPosition aPos( rSectNd ); - SwContentNode* pCNd = rDoc.GetNodes().GoNext( &aPos.nNode ); // to the next ContentNode + SwPosition aPos(rNode); + SwContentNode const*const pCNd = rNode.IsSectionNode() + ? rDoc.GetNodes().GoNext(&aPos.nNode) // to the next ContentNode + : rNode.GetContentNode(); if( !pCNd || !pCNd->IsTextNode() ) break; @@ -1088,13 +1130,13 @@ void SwDocUpdateField::GetBodyNode( const SwSectionNode& rSectNd ) bool const bResult = GetBodyTextNode( rDoc, aPos, *pFrame ); OSL_ENSURE(bResult, "where is the Field"); - pNew = new SetGetExpField( rSectNd, &aPos ); + pNew = new SetGetExpField( rCond, &aPos ); } while( false ); } if( !pNew ) - pNew = new SetGetExpField( rSectNd ); + pNew = new SetGetExpField( rCond ); if (!m_pFieldSortList->insert(pNew).second) delete pNew; diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx index 131bc0cc1d23..7c9314b8daf5 100644 --- a/sw/source/core/inc/docfld.hxx +++ b/sw/source/core/inc/docfld.hxx @@ -23,6 +23,7 @@ #include <calc.hxx> #include <doc.hxx> #include <IDocumentTimerAccess.hxx> +#include <IMark.hxx> #include <o3tl/sorted_vector.hxx> #include <memory> @@ -54,10 +55,11 @@ class SetGetExpField const SwTableBox* pTBox; const SwTextINetFormat* pTextINet; const SwFlyFrameFormat* pFlyFormat; + ::sw::mark::IBookmark const* pBookmark; } CNTNT; enum SetGetExpFieldType { - TEXTFIELD, TEXTTOXMARK, SECTIONNODE, CRSRPOS, TABLEBOX, + TEXTFIELD, TEXTTOXMARK, SECTIONNODE, BOOKMARK, CRSRPOS, TABLEBOX, TEXTINET, FLYFRAME } eSetGetExpFieldType; @@ -70,6 +72,9 @@ public: SetGetExpField( const SwSectionNode& rSectNode, const SwPosition* pPos = nullptr ); + SetGetExpField( ::sw::mark::IBookmark const& rBookmark, + SwPosition const* pPos = nullptr ); + SetGetExpField( const SwTableBox& rTableBox ); SetGetExpField( const SwNodeIndex& rNdIdx, const SwTextTOXMark& rTOX ); @@ -85,6 +90,8 @@ public: { return TEXTFIELD == eSetGetExpFieldType ? CNTNT.pTextField : nullptr; } const SwSection* GetSection() const { return SECTIONNODE == eSetGetExpFieldType ? CNTNT.pSection : nullptr; } + ::sw::mark::IBookmark const* GetBookmark() const + { return BOOKMARK == eSetGetExpFieldType ? CNTNT.pBookmark : nullptr; } const SwTextINetFormat* GetINetFormat() const { return TEXTINET == eSetGetExpFieldType ? CNTNT.pTextINet : nullptr; } const SwFlyFrameFormat* GetFlyFormat() const @@ -145,7 +152,8 @@ class SwDocUpdateField void MakeFieldList_( SwDoc& pDoc, int eGetMode ); void GetBodyNode( const SwTextField& , SwFieldIds nFieldWhich ); - void GetBodyNode( const SwSectionNode&); + template<typename T> + void GetBodyNodeGeneric(SwNode const& rNode, T const&); public: SwDocUpdateField(SwDoc& rDocument); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index 92184de27fd4..1138e28f7bce 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -2273,28 +2273,8 @@ void SwScriptInfo::selectHiddenTextProperty(const SwTextNode& rNode, MultiSelect const sw::mark::IMark* pMark = pIndex->GetMark(); const sw::mark::IBookmark* pBookmark = dynamic_cast<const sw::mark::IBookmark*>(pMark); - bool bHide = false; + // condition is evaluated in DocumentFieldsManager::UpdateExpFields() if (pBookmark && pBookmark->IsHidden()) - { - // bookmark is marked as hidden - bHide = true; - - // bookmark is marked as hidden with conditions - if (!pBookmark->GetHideCondition().isEmpty()) - { - SwDoc& rDoc = *const_cast<SwDoc*>(rNode.GetDoc()); - SwCalc aCalc(rDoc); - rDoc.getIDocumentFieldsAccess().FieldsToCalc(aCalc, rNode.GetIndex(), USHRT_MAX); - - SwSbxValue aValue = aCalc.Calculate(pBookmark->GetHideCondition()); - if(!aValue.IsVoidValue()) - { - bHide = aValue.GetBool(); - } - } - } - - if (bHide) { // intersect bookmark range with textnode range and add the intersection to rHiddenMulti diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 76f9eacae7eb..850f4a7e6393 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -415,10 +415,10 @@ void BookmarkTable::InsertBookmark(sw::mark::IMark* pMark) else if (bPulling && !bPulledAll) sBookmarkNodeText = "..." + sBookmarkNodeText; + const OUString& sHideCondition = pBookmark->GetHideCondition(); OUString sHidden = "No"; - if (pBookmark->IsHidden()) + if (pBookmark->IsHidden() || !sHideCondition.isEmpty()) sHidden = "Yes"; - OUString sHideCondition = pBookmark->GetHideCondition(); OUString sPageNum = OUString::number(SwPaM(pMark->GetMarkStart()).GetPageNum()); OUString sColumnData = sPageNum + "\t" + pBookmark->GetName() + "\t" + sBookmarkNodeText + "\t" + sHidden + "\t" + sHideCondition; InsertEntryToColumn(sColumnData, TREELIST_APPEND, 0xffff, pMark);
