editeng/source/editeng/impedit4.cxx |    5 ++++
 sw/inc/usrfld.hxx                   |    2 -
 sw/source/filter/ww8/ww8par.cxx     |   43 +++++++++++++++++++++---------------
 sw/source/filter/ww8/ww8par5.cxx    |   30 ++++++++++++++++++++-----
 sw/source/uibase/shells/textsh.cxx  |    9 +++++--
 5 files changed, 62 insertions(+), 27 deletions(-)

New commits:
commit 2ae662ed5e2a92ae8c1a2e6b61dcc9b67f94419f
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Thu Mar 21 12:10:40 2024 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Apr 4 21:45:41 2024 +0200

    tdf#160301 import DOCVARIABLE fields as user fields
    
    DOCVARIBLE fields in *.doc files are imported as user fields.
    
    Change-Id: Ib723d8a586ca644e0b158f839caef33b2b6225a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165096
    Tested-by: Jenkins
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    (cherry picked from commit ad4b72a0eacf6bb6887236ea3a3807b1264de822)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165721

diff --git a/sw/inc/usrfld.hxx b/sw/inc/usrfld.hxx
index 28d582c4c5ac..f7371ef52c6e 100644
--- a/sw/inc/usrfld.hxx
+++ b/sw/inc/usrfld.hxx
@@ -102,7 +102,7 @@ inline void SwUserFieldType::SetType(sal_uInt16 nSub)
  * Tracks the number format and the language, conversion between the float and
  * string representation is independent from the system locale.
  */
-class SwUserField final : public SwValueField
+class SW_DLLPUBLIC SwUserField final : public SwValueField
 {
     sal_uInt16  m_nSubType;
 
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 10ccaa487816..976a68b88a69 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/packages/XPackageEncryption.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
 
 #include <i18nlangtag/languagetag.hxx>
 
@@ -4808,27 +4809,35 @@ void SwWW8ImplReader::ReadDocVars()
         aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
     if (m_bVer67)        return;
 
-    uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
-        m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
-    uno::Reference<document::XDocumentProperties> xDocProps(
-        xDPS->getDocumentProperties());
-    OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
-    uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
-        xDocProps->getUserDefinedProperties();
-    OSL_ENSURE(xUserDefinedProps.is(), "UserDefinedProperties is null");
-
-    for(size_t i=0; i<aDocVarStrings.size(); i++)
+    uno::Reference< text::XTextFieldsSupplier > 
xFieldsSupplier(m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
+    uno::Reference<css::lang::XMultiServiceFactory> 
xTextFactory(m_pDocShell->GetModel(), uno::UNO_QUERY);
+    uno::Reference< container::XNameAccess > xFieldMasterAccess = 
xFieldsSupplier->getTextFieldMasters();
+    for(size_t i = 0; i < aDocVarStrings.size(); i++)
     {
         const OUString &rName = aDocVarStrings[i];
         uno::Any aValue;
-        aValue <<= rName;
-        try {
-            xUserDefinedProps->addProperty( rName,
-                beans::PropertyAttribute::REMOVABLE,
-                aValue );
-        } catch (const uno::Exception &) {
-            // ignore
+        if (aDocValueStrings.size() > i)
+        {
+            OUString value = aDocValueStrings[i];
+            value = value.replaceAll("
", "
");
+            value = value.replaceAll(" ", "
");
+            aValue <<= value;
+        }
+
+        uno::Reference< beans::XPropertySet > xMaster;
+        OUString sFieldMasterService("com.sun.star.text.FieldMaster.User." + 
rName);
+
+        // Find or create Field Master
+        if (xFieldMasterAccess->hasByName(sFieldMasterService))
+        {
+            xMaster.set(xFieldMasterAccess->getByName(sFieldMasterService), 
uno::UNO_QUERY_THROW);
+        }
+        else
+        {
+            
xMaster.set(xTextFactory->createInstance("com.sun.star.text.FieldMaster.User"), 
uno::UNO_QUERY_THROW);
+            xMaster->setPropertyValue("Name", uno::Any(rName));
         }
+        xMaster->setPropertyValue("Content", aValue);
     }
 }
 
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index c87c33dde0e1..6750fa21ae76 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -58,6 +58,7 @@
 #include <IDocumentState.hxx>
 #include <flddat.hxx>
 #include <docufld.hxx>
+#include <usrfld.hxx>
 #include <reffld.hxx>
 #include <IMark.hxx>
 #include <expfld.hxx>
@@ -1831,12 +1832,29 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* 
pF, OUString& rStr )
         aData = aData.replaceAll("\"", "");
     }
 
-    const auto pType(static_cast<SwDocInfoFieldType*>(
-        
m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo)));
-    SwDocInfoField aField(pType, nSub|nReg, aData, GetFieldResult(pF), 
nFormat);
-    if (bDateTime)
-        ForceFieldLanguage(aField, nLang);
-    m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, 
SwFormatField(aField));
+    bool bDone = false;
+    if (DI_CUSTOM == nSub)
+    {
+        const auto pType(static_cast<SwUserFieldType*>(
+            m_rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::User, 
aData, false)));
+        if (pType)
+        {
+            SwUserField aField(pType, 0, nFormat);
+            if (bDateTime)
+                ForceFieldLanguage(aField, nLang);
+            m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, 
SwFormatField(aField));
+            bDone = true;
+        }
+    }
+    if (!bDone)
+    {
+        const auto pType(static_cast<SwDocInfoFieldType*>(
+            
m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo)));
+        SwDocInfoField aField(pType, nSub|nReg, aData, GetFieldResult(pF), 
nFormat);
+        if (bDateTime)
+            ForceFieldLanguage(aField, nLang);
+        m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, 
SwFormatField(aField));
+    }
 
     return eF_ResT::OK;
 }
commit 1d53871ac5cbb222c53a5aa17050a1c68126e4b8
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Tue Mar 19 09:19:38 2024 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Apr 4 21:45:26 2024 +0200

    tdf#63259 cycle case on sentences
    
    Cycle case will be applied to the sentence if the cursor is at
    a sentence end. Writer now also keeps the word/sentence selection
    after case change.
    
    Change-Id: I9dd561775ac612689526bcb118533ba81b5722be
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165018
    Tested-by: Jenkins
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165800

diff --git a/editeng/source/editeng/impedit4.cxx 
b/editeng/source/editeng/impedit4.cxx
index 3c92a7abfede..0258900725ea 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -2702,6 +2702,11 @@ EditSelection ImpEditEngine::TransliterateText( const 
EditSelection& rSelection,
     if ( !aSel.HasRange() )
     {
         aSel = SelectWord( aSel, 
css::i18n::WordType::ANYWORD_IGNOREWHITESPACES, true, true );
+        if (!aSel.HasRange() && aSel.Min().GetIndex() > 0 &&
+            
OUString(".!?").indexOf(aSel.Min().GetNode()->GetChar(aSel.Min().GetIndex() - 
1)) > -1 )
+        {
+            aSel = SelectSentence(aSel);
+        }
     }
 
     // tdf#107176: if there's still no range, just return aSel
diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index 97de98540151..29242d99463b 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -885,10 +885,13 @@ void SwTextShell::ExecRotateTransliteration( SfxRequest 
const & rReq )
         }
         else
         {
-            rSh.Push(); // save cur cursor
-            if ((rSh.IsEndWrd() || rSh.IsStartWord() || rSh.IsInWord()) && 
rSh.SelWrd())
+            if (rSh.IsEndSentence())
+            {
+                rSh.BwdSentence(true);
+                rSh.TransliterateText(m_aRotateCase.getNextMode());
+            }
+            else if ((rSh.IsEndWrd() || rSh.IsStartWord() || rSh.IsInWord()) 
&& rSh.SelWrd())
                 rSh.TransliterateText(m_aRotateCase.getNextMode());
-            rSh.Pop(SwCursorShell::PopMode::DeleteCurrent);
         }
     }
 }

Reply via email to