sfx2/source/doc/objserv.cxx                                      |   20 
 sw/inc/dbmgr.hxx                                                 |    2 
 sw/qa/extras/uiwriter/data/database-display-hidden-section.fodt  |   60 ++
 sw/qa/extras/uiwriter/data/database-display-hidden-section2.fodt |   60 ++
 sw/qa/extras/uiwriter/data/set-variable-hidden-text.fodt         |  121 +++++
 sw/qa/extras/uiwriter/uiwriter9.cxx                              |  224 
++++++++++
 sw/source/uibase/dbui/dbmgr.cxx                                  |   69 +--
 7 files changed, 498 insertions(+), 58 deletions(-)

New commits:
commit 5f45e5d11388f8ecdf921b8e870f6671cf4ae16c
Author:     Michael Stahl <[email protected]>
AuthorDate: Wed Sep 17 21:01:28 2025 +0200
Commit:     Miklos Vajna <[email protected]>
CommitDate: Thu Oct 2 08:29:14 2025 +0200

    sw: fix "Export Directly as PDF" with set-variable fields in hidden text
    
    ... results in wrong conditional text fields.
    
    First, add a testHiddenSectionPDFExport2 for the bug that was fixed with
    commit 1e007e8f1703851b01c68884e87c906f6bae5a5e - and
    testHiddenSectionPDFExport for a slightly different scenario that also
    failed.
    
    Investigating this, it turns out that the conditions are only evaluated
    properly inside SwDBManager::Merge(), because this sets up its
    m_pImpl->pMergeData, and without that SwCalc::VarLook() will not know
    which record is currently selected and return SbxVoid (if there is no
    xConnection) or a wrong record (if there is a xConnection).
    
    There is even code in SwDBManager::Merge() that tries to store the new
    state in m_DataSourceParams so that later SwCalc are able to use it, but
    this broke in 2007 with commit d06a6d2c192076870d67f19653701fdc25d9841c
    which changed SwNewDBMgr::FindDSData() to return the m_pImpl->pMergeData
    instead of a m_DataSourceParams entry, and thus the *pTemp assignment
    became self-assignment.
    
    Also, FindDSData(bCreate=true) already does everything that this code
    was doing anyway, so if we just call that *before* creating
    m_pImpl->pMergeData we can delete all that code.
    
    Now another problem becomes apparent: an obvious mismatch between how
    SwDBManager::GetColumnCnt() and lcl_MoveAbsolute() treat
    SwDSParam::aSelection - in the caller the nAbsRecordId is an index that
    is *contained* in aSelection (see explicit search with std::any_of), in
    the callee it is an index *into* aSelection.
    
    Apparently this is a regression from commit
    f5ccfd60c2c5dab392d58870fbd079a6286bc239 and testing reveals that for
    tdf#73025 the lcl_MoveAbsolute() is never called from GetColumnCnt(),
    but only from SwDBManager::ToRecordId(), so let's have 2 different
    functions for callers expecting different behaviour.
    
    Then revert 1e007e8f1703851b01c68884e87c906f6bae5a5e as this scenario
    works with the above described fixes.
    
    Add a testHiddenTextFieldPDFExport for the new bug.
    
    Change-Id: Ibca38edec8782c06a61d4eb5c9065098de8562fe
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191104
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <[email protected]>
    (cherry picked from commit 7978401cfcdd68536b47f2dfcf4799a5dcbdd22f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191738
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 6a97e49fb6ff..1ce86a925767 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1133,20 +1133,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                     SfxViewShell::Current()->SetStoringHelper(xHelper);
 
                 QueryHiddenInformation(bIsPDFExport ? 
HiddenWarningFact::WhenCreatingPDF : HiddenWarningFact::WhenSaving);
-                SfxPoolItemHolder aItem;
-                if (SID_DIRECTEXPORTDOCASPDF == nId)
-                    aItem = GetSlotState(SID_MAIL_PREPAREEXPORT);
-                const SfxBoolItem* pItem(dynamic_cast<const 
SfxBoolItem*>(aItem.getItem()));
-
-                // Fetch value from the pool item early, because 
GUIStoreModel() can free the pool
-                // item as part of spinning the main loop if a dialog is 
opened.
-                const bool bMailPrepareExport(nullptr != pItem && 
pItem->GetValue());
-                if (bMailPrepareExport)
-                {
-                    SfxRequest aRequest(SID_MAIL_PREPAREEXPORT, 
SfxCallMode::SYNCHRON, GetPool());
-                    aRequest.AppendItem(SfxBoolItem(FN_NOUPDATE, true));
-                    ExecuteSlot(aRequest);
-                }
 
                 xHelper->GUIStoreModel( GetModel(),
                                        pSlot->GetUnoName(),
@@ -1155,12 +1141,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                                        GetDocumentSignatureState(),
                                        bIsAsync );
 
-                if (bMailPrepareExport)
-                {
-                    SfxRequest aRequest(SID_MAIL_EXPORT_FINISHED, 
SfxCallMode::SYNCHRON, GetPool());
-                    ExecuteSlot(aRequest);
-                }
-
                 // merge aDispatchArgs to the request
                 SfxAllItemSet aResultParams( GetPool() );
                 TransformParameters( nId,
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index b48749696d74..0fb132b2a972 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -359,7 +359,7 @@ public:
                             OUString& rResult, double* pNumber);
     /** create and store or find an already stored connection to a data source 
for use
     in SwFieldMgr and SwDBTreeList */
-    css::uno::Reference< css::sdbc::XConnection> const &
+    SW_DLLPUBLIC css::uno::Reference<css::sdbc::XConnection> const&
                     RegisterConnection(OUString const& rSource);
 
     void            CreateDSData(const SwDBData& rData)
diff --git a/sw/qa/extras/uiwriter/data/database-display-hidden-section.fodt 
b/sw/qa/extras/uiwriter/data/database-display-hidden-section.fodt
new file mode 100644
index 000000000000..09fac66f6f11
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/database-display-hidden-section.fodt
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:d
 r3d="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:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Liberation Serif" 
svg:font-family="&apos;Liberation Serif&apos;" 
style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Lohit Devanagari" svg:font-family="&apos;Lohit 
Devanagari&apos;" style:font-family-generic="system" 
style:font-pitch="variable"/>
+  <style:font-face style:name="Source Han Serif CN" 
svg:font-family="&apos;Source Han Serif CN&apos;" 
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:font-independent-line-spacing="false">
+    <style:tab-stops/>
+   </style:paragraph-properties>
+   <style:text-properties style:use-window-font-color="true" 
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" 
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"/>
+  </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"/>
+ </office:styles>
+ <office:automatic-styles>
+  <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:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" 
style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" 
style:layout-grid-mode="none" style:layout-grid-ruby-below="false" 
style:layout-grid-print="false" style:layout-grid-display="false" 
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>
+    <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>
+ </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="Standard">
+        <text:database-display text:table-name="biblio" 
text:table-type="table" text:column-name="Custom1" 
text:database-name="Bibliography">&lt;Custom1&gt;</text:database-display>
+      </text:p>
+      <text:p text:style-name="Standard"/>
+      <text:section text:style-name="Sect1" text:name="Section1" 
text:condition="ooow:Bibliography.biblio.Custom1==&quot;English&quot;" 
text:is-hidden="true" text:display="condition">
+        <text:p text:style-name="Standard"/>
+        <text:p text:style-name="Standard">Section cachée si "Custom1" = 
"English"</text:p>
+      </text:section>
+
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/uiwriter/data/database-display-hidden-section2.fodt 
b/sw/qa/extras/uiwriter/data/database-display-hidden-section2.fodt
new file mode 100644
index 000000000000..d7860b9420e4
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/database-display-hidden-section2.fodt
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
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:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:d
 r3d="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:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:font-face-decls>
+  <style:font-face style:name="Liberation Serif" 
svg:font-family="&apos;Liberation Serif&apos;" 
style:font-family-generic="roman" style:font-pitch="variable"/>
+  <style:font-face style:name="Lohit Devanagari" svg:font-family="&apos;Lohit 
Devanagari&apos;" style:font-family-generic="system" 
style:font-pitch="variable"/>
+  <style:font-face style:name="Source Han Serif CN" 
svg:font-family="&apos;Source Han Serif CN&apos;" 
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:font-independent-line-spacing="false">
+    <style:tab-stops/>
+   </style:paragraph-properties>
+   <style:text-properties style:use-window-font-color="true" 
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" 
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"/>
+  </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"/>
+ </office:styles>
+ <office:automatic-styles>
+  <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:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" 
style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" 
style:layout-grid-mode="none" style:layout-grid-ruby-below="false" 
style:layout-grid-print="false" style:layout-grid-display="false" 
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>
+    <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>
+ </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="Standard">
+        <text:database-display text:table-name="biblio" 
text:table-type="table" text:column-name="Custom1" 
text:database-name="Bibliography2">&lt;Custom1&gt;</text:database-display>
+      </text:p>
+      <text:p text:style-name="Standard"/>
+      <text:section text:style-name="Sect1" text:name="Section1" 
text:condition="ooow:Bibliography2.biblio.Custom1==&quot;English&quot;" 
text:is-hidden="true" text:display="condition">
+        <text:p text:style-name="Standard"/>
+        <text:p text:style-name="Standard">Section cachée si "Custom1" = 
"English"</text:p>
+      </text:section>
+
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/uiwriter/data/set-variable-hidden-text.fodt 
b/sw/qa/extras/uiwriter/data/set-variable-hidden-text.fodt
new file mode 100644
index 000000000000..576604298b33
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/set-variable-hidden-text.fodt
@@ -0,0 +1,121 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<office:document 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:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
<office:meta><meta:initial-creator>gcc</meta:initial-creator><meta:creation-date>2025-09-18T14:40:00.300148362</meta:creation-date><dc:date>2025-09-18T14:40:40.278151245</dc:date><dc:creator>gcc</dc:creator><meta:editing-duration>PT41S</meta:editing-duration><meta:editing-cycles>1</meta:editing-cycles><meta:document-statistic
 meta:table-count="0" meta:image-count="0" meta:object-count="0" 
meta:page-count="1" meta:paragraph-count="1" meta:word-count="1" 
meta:character-count="8" 
meta:non-whitespace-character-count="8"/><meta:generator>LibreOfficeDev/26.2.0.0.alpha0$Linux_X86_64
 
LibreOffice_project/7954f6cb07c7219cff788ad9e6c4809ceef8f690</meta:generator></office:meta>
+ <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="Lucida Sans1" svg:font-family="'Lucida Sans'" 
style:font-family-generic="system" style:font-pitch="variable"/>
+  <style:font-face style:name="Noto Serif CJK SC" svg:font-family="'Noto Serif 
CJK SC'" 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" loext:tab-stop-distance="0cm" 
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="Noto Serif CJK SC" style:font-size-asian="10.5pt" 
style:language-asian="zh" style:country-asian="CN" 
style:font-name-complex="Lucida Sans1" 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" fo:hyphenation-keep="auto" 
loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="false" 
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="Noto Serif CJK SC" style:font-size-asian="10.5pt" 
style:language-asian="zh" style:country-asian="CN" 
style:font-name-complex="Lucida Sans1" 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" loext:hyphenation-no-last-word="false" 
loext:hyphenation-word-char-count="5" loext:hyphenation-zone="no-limit"/>
+  </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"/>
+  <text:outline-style style:name="Outline">
+   <text:outline-level-style text:level="1" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="2" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="3" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="4" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="5" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="6" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="7" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="8" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="9" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+   <text:outline-level-style text:level="10" style:num-format="">
+    <style:list-level-properties 
text:list-level-position-and-space-mode="label-alignment">
+     <style:list-level-label-alignment text:label-followed-by="listtab"/>
+    </style:list-level-properties>
+   </text:outline-level-style>
+  </text:outline-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 text:display="none"/>
+  </style:style>
+  <style:style style:name="P2" style:family="paragraph" 
style:parent-style-name="Standard">
+   <style:text-properties/>
+  </style:style>
+  <style:page-layout style:name="pm1">
+   <style:page-layout-properties fo:page-width="10.5cm" 
fo:page-height="14.801cm" 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" loext:margin-gutter="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>
+  <number:number-style style:name="N0">
+   <number:number number:min-integer-digits="1"/>
+  </number:number-style>
+ </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:variable-decls>
+    <text:variable-decl office:value-type="float" text:name="foo"/>
+   </text:variable-decls>
+   <text:sequence-decls>
+    <text:sequence-decl text:display-outline-level="0" 
text:name="Illustration"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
+    <text:sequence-decl text:display-outline-level="0" text:name="Figure"/>
+   </text:sequence-decls>
+   <text:p text:style-name="P1"><text:variable-set text:name="foo" 
office:value-type="float" office:value="2" 
style:data-style-name="N0">2</text:variable-set></text:p>
+   <text:p text:style-name="P2"><text:conditional-text 
text:condition="ooow:foo==2" text:string-value-if-true="Expected" 
text:string-value-if-false="Fail">Expected</text:conditional-text></text:p>
+  </office:text>
+ </office:body>
+</office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter9.cxx 
b/sw/qa/extras/uiwriter/uiwriter9.cxx
index 2f6fa8f1d9ec..e7dabb391b37 100644
--- a/sw/qa/extras/uiwriter/uiwriter9.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter9.cxx
@@ -59,6 +59,8 @@
 #include <IDocumentLinksAdministration.hxx>
 #include <fmtinfmt.hxx>
 #include <rootfrm.hxx>
+#include <dbmgr.hxx>
+#include <mmconfigitem.hxx>
 #include <svx/svxids.hrc>
 #include <pagefrm.hxx>
 #include <svx/svdview.hxx>
@@ -351,6 +353,228 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, 
testPasteTableInMiddleOfParagraph)
                          
pWrtShell->GetCursor()->GetPointNode().GetTextNode()->GetText());
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testHiddenSectionPDFExport)
+{
+    // this uses biblio.odb
+    createSwDoc("database-display-hidden-section.fodt");
+
+    uno::Reference<text::XTextSectionsSupplier> 
xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xSections(xTextSectionsSupplier->getTextSections(),
+                                                      uno::UNO_QUERY);
+    uno::Reference<text::XTextSection> xSection(xSections->getByIndex(0), 
uno::UNO_QUERY);
+
+    // apparently without a record it evaluates to hidden?
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsVisible"));
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    // somehow a timer that constructs toolbars isn't run in unit tests -
+    // it would query state of .uno:MailMergeEmailDocuments which as a side
+    // effect (!) calls this:
+    getSwDocShell()->GetView()->EnsureMailMergeConfigItem();
+
+    dispatchCommand(mxComponent, u".uno:MailMergeNextEntry"_ustr, {});
+    getParagraph(1, "English ");
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    dispatchCommand(mxComponent, u".uno:MailMergeNextEntry"_ustr, {});
+    getParagraph(1, "English ");
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    uno::Sequence<css::beans::PropertyValue> args{
+        comphelper::makePropertyValue(u"SynchronMode"_ustr, true),
+        comphelper::makePropertyValue(u"URL"_ustr, maTempFile.GetURL())
+    };
+    dispatchCommand(mxComponent, u".uno:ExportDirectToPDF"_ustr, args);
+
+    // fetch again in case it was deleted and undo
+    xSection.set(xSections->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+
+    int nObjectsHidden;
+    if (pPDFium)
+    {
+        SvFileStream aPDFFile(maTempFile.GetURL(), StreamMode::READ);
+        SvMemoryStream aMemory;
+        aMemory.WriteStream(aPDFFile);
+
+        std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
+            = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), 
OString());
+        CPPUNIT_ASSERT(pPdfDocument);
+        CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+        std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = 
pPdfDocument->openPage(0);
+        CPPUNIT_ASSERT(pPdfPage);
+        nObjectsHidden = pPdfPage->getObjectCount();
+    }
+
+    dispatchCommand(mxComponent, u".uno:MailMergeNextEntry"_ustr, {});
+    getParagraph(1, "Deutsch ");
+    CPPUNIT_ASSERT(getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    dispatchCommand(mxComponent, u".uno:ExportDirectToPDF"_ustr, args);
+
+    // fetch again in case it was deleted and undo
+    xSection.set(xSections->getByIndex(0), uno::UNO_QUERY);
+    // the problem was that PDF export hid the section
+    CPPUNIT_ASSERT(getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    if (pPDFium)
+    {
+        SvFileStream aPDFFile(maTempFile.GetURL(), StreamMode::READ);
+        SvMemoryStream aMemory;
+        aMemory.WriteStream(aPDFFile);
+
+        std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
+            = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), 
OString());
+        CPPUNIT_ASSERT(pPdfDocument);
+        CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+        std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = 
pPdfDocument->openPage(0);
+        CPPUNIT_ASSERT(pPdfPage);
+        // there must be more objects on the page now (currently goes 2->3)
+        CPPUNIT_ASSERT_LESS(pPdfPage->getObjectCount(), nObjectsHidden);
+    }
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testHiddenSectionPDFExport2)
+{
+    // this uses biblio.odb
+    createSwDoc("database-display-hidden-section2.fodt");
+
+    uno::Reference<text::XTextSectionsSupplier> 
xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> 
xSections(xTextSectionsSupplier->getTextSections(),
+                                                      uno::UNO_QUERY);
+    uno::Reference<text::XTextSection> xSection(xSections->getByIndex(0), 
uno::UNO_QUERY);
+
+    // apparently without a record it evaluates to hidden?
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsVisible"));
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    // somehow a timer that constructs toolbars isn't run in unit tests -
+    // it would query state of .uno:MailMergeEmailDocuments which as a side
+    // effect (!) calls this:
+    auto pMMConfig = getSwDocShell()->GetView()->EnsureMailMergeConfigItem();
+
+    // ... but the file has wrong DB name so we first have to fix it
+    // in the same way as SwChangeDBDlg
+    SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+    pWrtShell->GetDBManager()->RegisterConnection("Bibliography");
+    SwDBData data;
+    data.sDataSource = "Bibliography";
+    data.sCommand = "biblio";
+    pWrtShell->ChgDBData(data);
+    // this would be called via a SwXTextView listener
+    pMMConfig->updateCurrentDBDataFromDocument();
+    pWrtShell->ChangeDBFields({ u"Bibliography2ÿbiblioÿ0"_ustr }, 
u"Bibliographyÿbiblioÿ0"_ustr);
+
+    dispatchCommand(mxComponent, u".uno:MailMergeNextEntry"_ustr, {});
+    getParagraph(1, "English ");
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    dispatchCommand(mxComponent, u".uno:MailMergeNextEntry"_ustr, {});
+    getParagraph(1, "English ");
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    uno::Sequence<css::beans::PropertyValue> args{
+        comphelper::makePropertyValue(u"SynchronMode"_ustr, true),
+        comphelper::makePropertyValue(u"URL"_ustr, maTempFile.GetURL())
+    };
+    dispatchCommand(mxComponent, u".uno:ExportDirectToPDF"_ustr, args);
+
+    // fetch again in case it was deleted and undo
+    xSection.set(xSections->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(!getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+
+    int nObjectsHidden;
+    if (pPDFium)
+    {
+        SvFileStream aPDFFile(maTempFile.GetURL(), StreamMode::READ);
+        SvMemoryStream aMemory;
+        aMemory.WriteStream(aPDFFile);
+
+        std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
+            = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), 
OString());
+        CPPUNIT_ASSERT(pPdfDocument);
+        CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+        std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = 
pPdfDocument->openPage(0);
+        CPPUNIT_ASSERT(pPdfPage);
+        nObjectsHidden = pPdfPage->getObjectCount();
+    }
+
+    dispatchCommand(mxComponent, u".uno:MailMergeNextEntry"_ustr, {});
+    getParagraph(1, "Deutsch ");
+    CPPUNIT_ASSERT(getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    dispatchCommand(mxComponent, u".uno:ExportDirectToPDF"_ustr, args);
+
+    // fetch again in case it was deleted and undo
+    xSection.set(xSections->getByIndex(0), uno::UNO_QUERY);
+    // the problem was that PDF export hid the section
+    CPPUNIT_ASSERT(getProperty<bool>(xSection, "IsCurrentlyVisible"));
+
+    if (pPDFium)
+    {
+        SvFileStream aPDFFile(maTempFile.GetURL(), StreamMode::READ);
+        SvMemoryStream aMemory;
+        aMemory.WriteStream(aPDFFile);
+
+        std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
+            = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), 
OString());
+        CPPUNIT_ASSERT(pPdfDocument);
+        CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+        std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = 
pPdfDocument->openPage(0);
+        CPPUNIT_ASSERT(pPdfPage);
+        // there must be more objects on the page now (currently goes 2->3)
+        CPPUNIT_ASSERT_LESS(pPdfPage->getObjectCount(), nObjectsHidden);
+    }
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testHiddenTextFieldPDFExport)
+{
+    createSwDoc("set-variable-hidden-text.fodt");
+
+    getParagraph(1, "2");
+    getParagraph(2, "Expected");
+
+    uno::Sequence<css::beans::PropertyValue> args{
+        comphelper::makePropertyValue(u"SynchronMode"_ustr, true),
+        comphelper::makePropertyValue(u"URL"_ustr, maTempFile.GetURL())
+    };
+    dispatchCommand(mxComponent, u".uno:ExportDirectToPDF"_ustr, args);
+
+    getParagraph(1, "2");
+    // the problem was that this changed to Wrong
+    getParagraph(2, "Expected");
+
+    std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+    if (pPDFium)
+    {
+        SvFileStream aPDFFile(maTempFile.GetURL(), StreamMode::READ);
+        SvMemoryStream aMemory;
+        aMemory.WriteStream(aPDFFile);
+
+        std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
+            = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize(), 
OString());
+        CPPUNIT_ASSERT(pPdfDocument);
+        CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+        std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = 
pPdfDocument->openPage(0);
+        CPPUNIT_ASSERT(pPdfPage);
+        std::unique_ptr<vcl::pdf::PDFiumTextPage> pPdfTextPage = 
pPdfPage->getTextPage();
+        CPPUNIT_ASSERT(pPdfTextPage);
+        std::unique_ptr<vcl::pdf::PDFiumPageObject> pPageObject = 
pPdfPage->getObject(0);
+        OUString sText = pPageObject->getText(pPdfTextPage);
+        // the problem was that this changed to Wrong
+        CPPUNIT_ASSERT_EQUAL(u"Expected"_ustr, sText);
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest9, testTdf111969)
 {
     // given a document with a field surrounded by N-dashes (–date–)
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 0fb2a04e2674..ed7e4e82ed6b 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -356,29 +356,44 @@ static bool lcl_MoveAbsolute(SwDSParam* pParam, 
tools::Long nAbsPos)
     bool bRet = false;
     try
     {
-        if(pParam->aSelection.hasElements())
+        if(pParam->bScrollable)
         {
-            if(pParam->aSelection.getLength() <= nAbsPos)
+            bRet = pParam->xResultSet->absolute( nAbsPos );
+        }
+        else
+        {
+            OSL_FAIL("no absolute positioning available");
+        }
+    }
+    catch(const uno::Exception&)
+    {
+    }
+    return bRet;
+}
+
+static bool lcl_MoveSelectionOrAbsolute(SwDSParam *const pParam, tools::Long 
const nAbsPos)
+{
+    bool bRet = false;
+    try
+    {
+        if (pParam->aSelection.hasElements())
+        {
+            if (pParam->aSelection.getLength() <= nAbsPos)
             {
                 pParam->bEndOfDB = true;
-                bRet = false;
             }
             else
             {
                 pParam->nSelectionIndex = nAbsPos;
                 sal_Int32 nPos = 0;
                 pParam->aSelection.getConstArray()[ pParam->nSelectionIndex ] 
>>= nPos;
-                pParam->bEndOfDB = !pParam->xResultSet->absolute( nPos );
-                bRet = !pParam->bEndOfDB;
+                pParam->bEndOfDB = !pParam->xResultSet->absolute(nPos);
             }
-        }
-        else if(pParam->bScrollable)
-        {
-            bRet = pParam->xResultSet->absolute( nAbsPos );
+            bRet = !pParam->bEndOfDB;
         }
         else
         {
-            OSL_FAIL("no absolute positioning available");
+            bRet = lcl_MoveAbsolute(pParam, nAbsPos);
         }
     }
     catch(const uno::Exception&)
@@ -483,33 +498,13 @@ bool SwDBManager::Merge( const SwMergeDescriptor& 
rMergeDesc )
         return false;
     }
 
+    SwDSParam *const pTemp{FindDSData(aData, true)};
+    assert(pTemp && pTemp != m_pImpl->pMergeData.get());
     m_pImpl->pMergeData.reset(new SwDSParam(aData, xResSet, aSelection));
-    SwDSParam*  pTemp = FindDSData(aData, false);
-    if(pTemp)
-        *pTemp = *m_pImpl->pMergeData;
-    else
-    {
-        // calls from the calculator may have added a connection with an 
invalid commandtype
-        //"real" data base connections added here have to re-use the already 
available
-        //DSData and set the correct CommandType
-        aData.nCommandType = -1;
-        pTemp = FindDSData(aData, false);
-        if(pTemp)
-            *pTemp = *m_pImpl->pMergeData;
-        else
-        {
-            
m_DataSourceParams.push_back(std::make_unique<SwDSParam>(*m_pImpl->pMergeData));
-            try
-            {
-                uno::Reference<lang::XComponent> 
xComponent(m_DataSourceParams.back()->xConnection, uno::UNO_QUERY);
-                if(xComponent.is())
-                    xComponent->addEventListener(m_pImpl->m_xDisposeListener);
-            }
-            catch(const uno::Exception&)
-            {
-            }
-        }
-    }
+    // assign state with selection to existing entry in m_DataSourceParams
+    // so later SwCalc can find correct record
+    *pTemp = *m_pImpl->pMergeData;
+
     if(!m_pImpl->pMergeData->xConnection.is())
         m_pImpl->pMergeData->xConnection = xConnection;
     // add an XEventListener
@@ -2310,7 +2305,7 @@ bool SwDBManager::ToRecordId(sal_Int32 nSet)
     bool bRet = false;
     sal_Int32 nAbsPos = nSet;
     assert(nAbsPos >= 0);
-    bRet = lcl_MoveAbsolute(m_pImpl->pMergeData.get(), nAbsPos);
+    bRet = lcl_MoveSelectionOrAbsolute(m_pImpl->pMergeData.get(), nAbsPos);
     m_pImpl->pMergeData->bEndOfDB = !bRet;
     return bRet;
 }

Reply via email to