sw/qa/extras/uiwriter/uiwriter3.cxx              |   36 +++++++++++++++++++++++
 writerfilter/source/dmapper/NumberingManager.cxx |   19 +++++-------
 2 files changed, 45 insertions(+), 10 deletions(-)

New commits:
commit 5d0f0d1a70a0b001be9db95d85f1d33a5f23f13f
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Fri Nov 19 12:23:41 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Nov 30 10:07:47 2021 +0100

    tdf#97899 DOCX import: allow character formatting only of numbering
    
    After the DOCX round-trip of a numbering created in Writer
    using direct formatting (e.g. using Toggle Ordered/Unordered
    List icons), it was not possible to format only the numbering
    or bullets, e.g. selecting and formatting them by positioning
    the text cursor on the numbering. Set CharStyleName property
    during the DOCX import to allow this formatting.
    
    Note: default list styles of Writer is still not supported,
    resulting missing numbering after DOCX import.
    
    Change-Id: I6f2c5d6e0d63b15e9c28367181af1e9e083ae68d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125649
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 7b8ae6f90c37c18ff724c0751b5f73cca6ae02ac)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125999
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 80874d041267..43ef4250aaba 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -3250,6 +3250,42 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf103612)
                 "Text after section");
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf97899)
+{
+    SwDoc* pDoc = createSwDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
+    IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations());
+
+    // Create an Ordered List
+    rIDCO.InsertString(*pCursor, "a");
+    pWrtShell->SplitNode();
+    rIDCO.InsertString(*pCursor, "b");
+    pWrtShell->SplitNode();
+    rIDCO.InsertString(*pCursor, "c");
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    dispatchCommand(mxComponent, ".uno:DefaultNumbering", {});
+
+    // Save it as DOCX & load it again
+    reload("Office Open XML Text", "tdf97899-tmp.docx");
+    uno::Reference<container::XIndexAccess> xNumberingRules
+        = 
getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), 
"NumberingRules");
+    CPPUNIT_ASSERT(xNumberingRules->getCount());
+    uno::Sequence<beans::PropertyValue> aNumbering;
+    xNumberingRules->getByIndex(0) >>= aNumbering;
+    OUString sCharStyleName;
+    for (const auto& prop : aNumbering)
+    {
+        if (prop.Name == "CharStyleName")
+        {
+            prop.Value >>= sCharStyleName;
+            break;
+        }
+    }
+    CPPUNIT_ASSERT(!sCharStyleName.isEmpty());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx 
b/writerfilter/source/dmapper/NumberingManager.cxx
index 61dbea4a5563..8829aa52697f 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -568,16 +568,15 @@ void ListDef::CreateNumberingRules( DomainMapper& 
rDMapper,
                 lcl_mergeProperties( rAbsCharStyleProps, rCharStyleProps );
             }
 
-            if( aAbsCharStyleProps.hasElements() )
-            {
-                // Change the sequence into a vector
-                auto aStyleProps = 
comphelper::sequenceToContainer<PropertyValueVector_t>(aAbsCharStyleProps);
-
-                //create (or find) a character style containing the character
-                // attributes of the symbol and apply it to the numbering level
-                OUString sStyle = rDMapper.getOrCreateCharStyle( aStyleProps, 
/*bAlwaysCreate=*/true );
-                
aLvlProps.push_back(comphelper::makePropertyValue(getPropertyName(PROP_CHAR_STYLE_NAME),
 sStyle));
-            }
+            // Change the sequence into a vector
+            auto aStyleProps
+                = 
comphelper::sequenceToContainer<PropertyValueVector_t>(aAbsCharStyleProps);
+
+            //create (or find) a character style containing the character
+            // attributes of the symbol and apply it to the numbering level
+            OUString sStyle = rDMapper.getOrCreateCharStyle(aStyleProps, 
/*bAlwaysCreate=*/true);
+            aLvlProps.push_back(
+                
comphelper::makePropertyValue(getPropertyName(PROP_CHAR_STYLE_NAME), sStyle));
 
             OUString sText = pAbsLevel
                            ? pAbsLevel->GetBulletChar()

Reply via email to