cui/source/tabpages/numpages.cxx                        |    9 +++++++++
 include/editeng/numitem.hxx                             |    3 ++-
 include/xmloff/xmltoken.hxx                             |    2 ++
 offapi/com/sun/star/text/LabelFollow.idl                |    4 ++++
 sw/qa/extras/odfexport/data/chapter-number-new-line.odt |binary
 sw/qa/extras/odfexport/odfexport.cxx                    |   11 +++++++++++
 sw/source/core/txtnode/ndtxt.cxx                        |    5 +++++
 sw/source/core/unocore/unosett.cxx                      |   14 +++++++++++---
 sw/source/ui/misc/num.cxx                               |    8 ++++++++
 sw/source/ui/misc/outline.cxx                           |    1 +
 sw/uiconfig/swriter/ui/outlinepositionpage.ui           |    3 +++
 xmloff/source/core/xmltoken.cxx                         |    1 +
 xmloff/source/style/xmlnume.cxx                         |    7 +++++++
 xmloff/source/style/xmlnumi.cxx                         |   11 +++++++++--
 xmloff/source/token/tokens.txt                          |    2 ++
 15 files changed, 75 insertions(+), 6 deletions(-)

New commits:
commit 4f5928ea8022d879764cc882f01a1b642645d66f
Author: Nithin Kumar Padavu <nithin...@gmail.com>
Date:   Sat Apr 7 15:10:06 2018 +0000

    tdf#112384 sw: Allow New line as a label followed by chapter numbering
    
    reference-language also added to token list
    
    Change-Id: I32713508d3611dc2bce10b2c5abb1e1a4167bdaf
    Reviewed-on: https://gerrit.libreoffice.org/52561
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 8f1a169f59d3..eb9fea50f28f 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -2451,6 +2451,7 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& 
rRenderContext, const ::tool
                         break;
                         case SvxNumberFormat::SPACE:
                         case SvxNumberFormat::NOTHING:
+                        case SvxNumberFormat::NEWLINE:
                         {
                             nTextXPos = nNumberXPos + nBulletWidth;
                         }
@@ -2861,6 +2862,10 @@ void SvxNumPositionTabPage::InitControls()
         {
             nPos = 2;
         }
+        else if ( aNumFmtArr[nLvl]->GetLabelFollowedBy() == 
SvxNumberFormat::NEWLINE )
+        {
+            nPos = 3;
+        }
         m_pLabelFollowedByLB->SelectEntryPos( nPos );
     }
     else
@@ -3323,6 +3328,10 @@ IMPL_LINK_NOARG(SvxNumPositionTabPage, 
LabelFollowedByHdl_Impl, ListBox&, void)
         {
             eLabelFollowedBy = SvxNumberFormat::NOTHING;
         }
+        else if ( nPos == 3 )
+        {
+            eLabelFollowedBy = SvxNumberFormat::NEWLINE;
+        }
     }
 
     // set value at the chosen list levels
diff --git a/include/editeng/numitem.hxx b/include/editeng/numitem.hxx
index f6fb25eb8476..520e12cfbdc5 100644
--- a/include/editeng/numitem.hxx
+++ b/include/editeng/numitem.hxx
@@ -95,7 +95,8 @@ public:
     {
         LISTTAB,
         SPACE,
-        NOTHING
+        NOTHING,
+        NEWLINE
     };
 
 private:
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index bb76cbf48678..b741dc43ac9b 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3312,6 +3312,8 @@ namespace xmloff { namespace token {
         // tdf#115319
         XML_REFERENCE_LANGUAGE,
 
+        XML_NEWLINE,
+
         XML_TOKEN_END
     };
 
diff --git a/offapi/com/sun/star/text/LabelFollow.idl 
b/offapi/com/sun/star/text/LabelFollow.idl
index c27acbcc6a7e..24c944cbc170 100644
--- a/offapi/com/sun/star/text/LabelFollow.idl
+++ b/offapi/com/sun/star/text/LabelFollow.idl
@@ -44,6 +44,10 @@ published constants LabelFollow
         /** nothing
          */
         const short NOTHING = 2;
+
+        /** new line
+         */
+        const short NEWLINE = 3;
 };
 
 
diff --git a/sw/qa/extras/odfexport/data/chapter-number-new-line.odt 
b/sw/qa/extras/odfexport/data/chapter-number-new-line.odt
new file mode 100644
index 000000000000..68a427f72e79
Binary files /dev/null and 
b/sw/qa/extras/odfexport/data/chapter-number-new-line.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx 
b/sw/qa/extras/odfexport/odfexport.cxx
index 7566ec25ad6e..219ef5bd8b07 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -1964,6 +1964,17 @@ DECLARE_ODFEXPORT_TEST(testSignatureLineProperties, 
"signatureline-properties.fo
     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xShape, 
"SignatureLineShowSignDate"));
 }
 
+DECLARE_ODFEXPORT_TEST(testChapterNumberingNewLine, 
"chapter-number-new-line.odt")
+{
+    uno::Reference<text::XChapterNumberingSupplier> 
xNumberingSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xNumberingRules = 
xNumberingSupplier->getChapterNumberingRules();
+    comphelper::SequenceAsHashMap hashMap(xNumberingRules->getByIndex(0));
+
+    //This failed Actual Value was LISTTAB instead of NEWLINE
+    CPPUNIT_ASSERT_EQUAL(
+        sal_Int16(SvxNumberFormat::NEWLINE), 
hashMap["LabelFollowedBy"].get<sal_Int16>());
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index c9c5bbfb579a..3ef80bd0d93f 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -4138,6 +4138,11 @@ OUString SwTextNode::GetLabelFollowedBy() const
                     return OUString(" ");
                 }
                 break;
+                case SvxNumberFormat::NEWLINE:
+                {
+                    return OUString("\n");
+                }
+                break;
                 case SvxNumberFormat::NOTHING:
                 {
                     // intentionally left blank.
diff --git a/sw/source/core/unocore/unosett.cxx 
b/sw/source/core/unocore/unosett.cxx
index 5c503cfd6901..3825caeb1951 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1368,6 +1368,10 @@ uno::Sequence<beans::PropertyValue> 
SwXNumberingRules::GetPropertiesForNumFormat
         {
             nINT16 = LabelFollow::NOTHING;
         }
+        else if ( rFormat.GetLabelFollowedBy() == SvxNumberFormat::NEWLINE )
+        {
+            nINT16 = LabelFollow::NEWLINE;
+        }
         
aPropertyValues.push_back(comphelper::makePropertyValue(UNO_NAME_LABEL_FOLLOWED_BY,
 nINT16));
 
         // ListtabStopPosition
@@ -1756,18 +1760,22 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
                 {
                     sal_Int16 nValue = 0;
                     pProp->Value >>= nValue;
-                    if ( nValue == 0 )
+                    if ( nValue == LabelFollow::LISTTAB )
                     {
                         aFormat.SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
                     }
-                    else if ( nValue == 1 )
+                    else if ( nValue == LabelFollow::SPACE )
                     {
                         aFormat.SetLabelFollowedBy( SvxNumberFormat::SPACE );
                     }
-                    else if ( nValue == 2 )
+                    else if ( nValue == LabelFollow::NOTHING )
                     {
                         aFormat.SetLabelFollowedBy( SvxNumberFormat::NOTHING );
                     }
+                    else if ( nValue == LabelFollow::NEWLINE )
+                    {
+                        aFormat.SetLabelFollowedBy( SvxNumberFormat::NEWLINE );
+                    }
                     else
                     {
                         bWrongArg = true;
diff --git a/sw/source/ui/misc/num.cxx b/sw/source/ui/misc/num.cxx
index 6d6a52c2d71d..2bfe5e816ea3 100644
--- a/sw/source/ui/misc/num.cxx
+++ b/sw/source/ui/misc/num.cxx
@@ -331,6 +331,10 @@ void SwNumPositionTabPage::InitControls()
         {
             nPos = 2;
         }
+        else if ( aNumFormatArr[nLvl]->GetLabelFollowedBy() == 
SvxNumberFormat::NEWLINE )
+        {
+            nPos = 3;
+        }
         m_pLabelFollowedByLB->SelectEntryPos( nPos );
     }
     else
@@ -769,6 +773,10 @@ IMPL_LINK_NOARG(SwNumPositionTabPage, 
LabelFollowedByHdl_Impl, ListBox&, void)
         {
             eLabelFollowedBy = SvxNumberFormat::NOTHING;
         }
+        else if ( nPos == 3 )
+        {
+            eLabelFollowedBy = SvxNumberFormat::NEWLINE;
+        }
     }
 
     // set value at the chosen list levels
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index 1de834c33858..f0cdf8b9ee1b 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -1035,6 +1035,7 @@ void NumberingPreview::Paint(vcl::RenderContext& 
rRenderContext, const tools::Re
                         break;
                         case SvxNumberFormat::SPACE:
                         case SvxNumberFormat::NOTHING:
+                        case SvxNumberFormat::NEWLINE:
                         {
                             nTextXPos = nNumberXPos + nBulletWidth;
                         }
diff --git a/sw/uiconfig/swriter/ui/outlinepositionpage.ui 
b/sw/uiconfig/swriter/ui/outlinepositionpage.ui
index ed1cc21308de..510f7445afb5 100644
--- a/sw/uiconfig/swriter/ui/outlinepositionpage.ui
+++ b/sw/uiconfig/swriter/ui/outlinepositionpage.ui
@@ -46,6 +46,9 @@
       <row>
         <col id="0" translatable="yes" 
context="outlinepositionpage|liststore2">Nothing</col>
       </row>
+      <row>
+        <col id="0" translatable="yes" 
context="outlinepositionpage|liststore2">New Line</col>
+      </row>
     </data>
   </object>
   <object class="GtkBox" id="OutlinePositionPage">
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 1475d4f99b19..7566c1065119 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3305,6 +3305,7 @@ namespace xmloff { namespace token {
 
         // for optional language-dependent reference formats
         TOKEN( "reference-language",              XML_REFERENCE_LANGUAGE ),
+        TOKEN( "newline",                         XML_NEWLINE ),
 #if OSL_DEBUG_LEVEL > 0
         { 0, nullptr, nullptr,                       XML_TOKEN_END }
 #else
diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx
index e3965469916c..dea4bb10d5a8 100644
--- a/xmloff/source/style/xmlnume.cxx
+++ b/xmloff/source/style/xmlnume.cxx
@@ -485,6 +485,13 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 
nLevel,
                 GetExport().AddAttribute( XML_NAMESPACE_TEXT,
                                           XML_LABEL_FOLLOWED_BY, eValue );
 
+                if (eLabelFollowedBy == LabelFollow::NEWLINE)
+                {
+                    eValue = XML_NEWLINE;
+                    GetExport().AddAttribute( XML_NAMESPACE_LO_EXT,
+                                          XML_LABEL_FOLLOWED_BY, eValue );
+                }
+
                 if ( eLabelFollowedBy == LabelFollow::LISTTAB &&
                      nListtabStopPosition > 0 )
                 {
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 42ccda81d3ea..ad1a081a3957 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -928,6 +928,8 @@ static const SvXMLTokenMapEntry* 
lcl_getStyleAlignmentAttributesAttrTokenMap()
     {
         { XML_NAMESPACE_TEXT, XML_LABEL_FOLLOWED_BY,
                 XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY },
+        { XML_NAMESPACE_LO_EXT, XML_LABEL_FOLLOWED_BY,
+                XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY },
         { XML_NAMESPACE_TEXT, XML_LIST_TAB_STOP_POSITION,
                 XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION },
         { XML_NAMESPACE_FO, XML_TEXT_INDENT,
@@ -951,6 +953,7 @@ 
SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAli
     SvXMLUnitConverter& rUnitConv = GetImport().GetMM100UnitConverter();
 
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+    sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB;
     for( sal_Int16 i=0; i < nAttrCount; i++ )
     {
         const OUString& rAttrName = xAttrList->getNameByIndex( i );
@@ -965,12 +968,15 @@ 
SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAli
         {
         case XML_TOK_STYLE_ATTRIBUTES_ATTR_LABEL_FOLLOWED_BY:
             {
-                sal_Int16 eLabelFollowedBy = LabelFollow::LISTTAB;
+                if( eLabelFollowedBy == LabelFollow::NEWLINE)
+                    //NewLine from LO_EXT has precedence over other values of 
the Non LO_EXT namespace
+                    break;
                 if( IsXMLToken( rValue, XML_SPACE ) )
                     eLabelFollowedBy = LabelFollow::SPACE;
                 else if( IsXMLToken( rValue, XML_NOTHING ) )
                     eLabelFollowedBy = LabelFollow::NOTHING;
-                rListLevel.SetLabelFollowedBy( eLabelFollowedBy );
+                else if( IsXMLToken( rValue, XML_NEWLINE ) )
+                    eLabelFollowedBy = LabelFollow::NEWLINE;
             }
             break;
         case XML_TOK_STYLE_ATTRIBUTES_ATTR_LISTTAB_STOP_POSITION:
@@ -987,6 +993,7 @@ 
SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAli
             break;
         }
     }
+    rListLevel.SetLabelFollowedBy( eLabelFollowedBy );
 }
 
 void SvxXMLListStyleContext::SetAttribute( sal_uInt16 nPrefixKey,
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 6c68ea0c339b..04275393f2bc 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -3077,4 +3077,6 @@ max-numerator-digits
 zeros-numerator-digits
 zeros-denominator-digits
 integer-fraction-delimiter
+reference-language
+newline
 TOKEN_END_DUMMY
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to