[Libreoffice-commits] core.git: Branch 'libreoffice-5-3-4' - sw/source xmloff/inc xmloff/Library_xo.mk xmloff/source

2017-06-15 Thread Troy Rollo
 sw/source/core/unocore/unostyle.cxx |3 
 sw/source/filter/xml/xmlfmt.cxx |   53 ++-
 xmloff/Library_xo.mk|1 
 xmloff/inc/prstylecond.hxx  |   23 ++
 xmloff/source/style/prstylecond.cxx |  125 
 xmloff/source/style/styleexp.cxx|   50 ++
 6 files changed, 251 insertions(+), 4 deletions(-)

New commits:
commit 6a53a750e48c8a7b6ea6bf263eae80179374016e
Author: Troy Rollo 
Date:   Tue Jun 6 17:41:33 2017 +1000

tdf#103091 conditional style conditions not saved

Change-Id: Iccf3eb531ee3382d27105e5ccce6013707a646b6
Reviewed-on: https://gerrit.libreoffice.org/38451
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 
(cherry picked from commit a5b4cb3f836c991d0647f55e1ef4920ce6115eac)
Reviewed-on: https://gerrit.libreoffice.org/38748
Tested-by: Michael Stahl 
Reviewed-by: Miklos Vajna 
Reviewed-by: Eike Rathke 

diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 63ce5d95beb6..ad6dd78b687e 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -2013,7 +2013,8 @@ void SwXStyle::SetPropertyValues_Impl(const 
uno::Sequence& rPropertyNa
 {
 if(!m_pDoc)
 throw uno::RuntimeException();
-const SfxItemPropertySet* pPropSet = 
aSwMapProvider.GetPropertySet(m_rEntry.m_nPropMapType);
+sal_Int8 nPropSetId = m_bIsConditional ? 
PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
+const SfxItemPropertySet* pPropSet = 
aSwMapProvider.GetPropertySet(nPropSetId);
 const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
 if(rPropertyNames.getLength() != rValues.getLength())
 throw lang::IllegalArgumentException();
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index b65cb0dc525b..b5aabd8cd96f 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -31,6 +31,7 @@
 #include "docary.hxx"
 #include 
 #include "unostyle.hxx"
+#include "unoprnms.hxx"
 #include "fmtpdsc.hxx"
 #include "pagedesc.hxx"
 #include 
@@ -44,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "xmlimp.hxx"
 #include "xmltbli.hxx"
 #include "cellatr.hxx"
@@ -51,10 +53,13 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
 using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
 using namespace ::xmloff::token;
 
 class SwXMLConditionParser_Impl
@@ -205,8 +210,11 @@ public:
 const uno::Reference< xml::sax::XAttributeList > & xAttrList );
 virtual ~SwXMLConditionContext_Impl() override;
 
-
 bool IsValid() const { return 0 != nCondition; }
+
+sal_uInt32 getCondition() const { return nCondition; }
+sal_uInt32 getSubCondition() const { return nSubCondition; }
+OUString const &getApplyStyle() const { return sApplyStyle; }
 };
 
 SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
@@ -257,10 +265,12 @@ typedef 
std::vector> SwXMLConditions_
 class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
 {
 std::unique_ptr pConditions;
+uno::Reference < style::XStyle > xNewStyle;
 
 protected:
 
 virtual uno::Reference < style::XStyle > Create() override;
+virtual void Finish( bool bOverwrite ) override;
 
 public:
 
@@ -280,7 +290,6 @@ public:
 
 uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
 {
-uno::Reference < style::XStyle > xNewStyle;
 
 if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
 {
@@ -302,6 +311,46 @@ uno::Reference < style::XStyle > 
SwXMLTextStyleContext_Impl::Create()
 return xNewStyle;
 }
 
+void
+SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
+{
+
+if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() && 
xNewStyle.is() )
+{
+CommandStruct const *aCommands = SwCondCollItem::GetCmds();
+
+Reference< XPropertySet > xPropSet( xNewStyle, UNO_QUERY );
+
+uno::Sequence< beans::NamedValue > aSeq( pConditions->size() );
+
+std::vector>::size_type i;
+unsigned j;
+
+for( i = 0; i < pConditions->size(); ++i )
+{
+if( (*pConditions)[i]->IsValid() )
+{
+sal_uInt32 nCond = (*pConditions)[i]->getCondition();
+sal_uInt32 nSubCond = (*pConditions)[i]->getSubCondition();
+
+for( j = 0; j < COND_COMMAND_COUNT; ++j )
+{
+if( aCommands[j].nCnd == nCond &&
+aCommands[j].nSubCond == nSubCond )
+{
+aSeq[i

[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sw/source xmloff/inc xmloff/Library_xo.mk xmloff/source

2017-06-14 Thread Troy Rollo
 sw/source/core/unocore/unostyle.cxx |3 
 sw/source/filter/xml/xmlfmt.cxx |   52 ++
 xmloff/Library_xo.mk|1 
 xmloff/inc/prstylecond.hxx  |   23 ++
 xmloff/source/style/prstylecond.cxx |  125 
 xmloff/source/style/styleexp.cxx|   50 ++
 6 files changed, 251 insertions(+), 3 deletions(-)

New commits:
commit 5649def882dfd00bd9e7f8d9d079955daf80bebb
Author: Troy Rollo 
Date:   Tue Jun 6 17:41:33 2017 +1000

tdf#103091 conditional style conditions not saved

Change-Id: Iccf3eb531ee3382d27105e5ccce6013707a646b6
Reviewed-on: https://gerrit.libreoffice.org/38451
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 
(cherry picked from commit a5b4cb3f836c991d0647f55e1ef4920ce6115eac)
Reviewed-on: https://gerrit.libreoffice.org/38746

diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index f9d3a06acbf2..2cce53ca24b6 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1997,7 +1997,8 @@ void SwXStyle::SetPropertyValues_Impl(const 
uno::Sequence& rPropertyNa
 {
 if(!m_pDoc)
 throw uno::RuntimeException();
-const SfxItemPropertySet* pPropSet = 
aSwMapProvider.GetPropertySet(m_rEntry.m_nPropMapType);
+sal_Int8 nPropSetId = m_bIsConditional ? 
PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
+const SfxItemPropertySet* pPropSet = 
aSwMapProvider.GetPropertySet(nPropSetId);
 const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
 if(rPropertyNames.getLength() != rValues.getLength())
 throw lang::IllegalArgumentException();
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index 685e7bc1dd75..ec0ac4cb77d0 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -31,6 +31,7 @@
 #include "docary.hxx"
 #include 
 #include "unostyle.hxx"
+#include "unoprnms.hxx"
 #include "fmtpdsc.hxx"
 #include "pagedesc.hxx"
 #include 
@@ -44,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "xmlimp.hxx"
 #include "xmltbli.hxx"
 #include "cellatr.hxx"
@@ -51,10 +53,13 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
 using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
 using namespace ::xmloff::token;
 
 class SwXMLConditionParser_Impl
@@ -205,6 +210,10 @@ public:
 const uno::Reference< xml::sax::XAttributeList > & xAttrList );
 
 bool IsValid() const { return Master_CollCondition::NONE != nCondition; }
+
+Master_CollCondition getCondition() const { return nCondition; }
+sal_uInt32 getSubCondition() const { return nSubCondition; }
+OUString const &getApplyStyle() const { return sApplyStyle; }
 };
 
 SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
@@ -250,10 +259,12 @@ typedef 
std::vector> SwXMLConditions_
 class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
 {
 std::unique_ptr pConditions;
+uno::Reference < style::XStyle > xNewStyle;
 
 protected:
 
 virtual uno::Reference < style::XStyle > Create() override;
+virtual void Finish( bool bOverwrite ) override;
 
 public:
 
@@ -273,7 +284,6 @@ public:
 
 uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
 {
-uno::Reference < style::XStyle > xNewStyle;
 
 if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
 {
@@ -295,6 +305,46 @@ uno::Reference < style::XStyle > 
SwXMLTextStyleContext_Impl::Create()
 return xNewStyle;
 }
 
+void
+SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
+{
+
+if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() && 
xNewStyle.is() )
+{
+CommandStruct const *aCommands = SwCondCollItem::GetCmds();
+
+Reference< XPropertySet > xPropSet( xNewStyle, UNO_QUERY );
+
+uno::Sequence< beans::NamedValue > aSeq( pConditions->size() );
+
+std::vector>::size_type i;
+unsigned j;
+
+for( i = 0; i < pConditions->size(); ++i )
+{
+if( (*pConditions)[i]->IsValid() )
+{
+Master_CollCondition nCond = (*pConditions)[i]->getCondition();
+sal_uInt32 nSubCond = (*pConditions)[i]->getSubCondition();
+
+for( j = 0; j < COND_COMMAND_COUNT; ++j )
+{
+if( aCommands[j].nCnd == nCond &&
+aCommands[j].nSubCond == nSubCond )
+{
+aSeq[i].Name = GetCommandContextByIndex( j );
+aSeq[i].Value <<= GetImport().GetStyleDisplayName( 
GetFamily(), (*pConditions)[i]-&g

[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/source xmloff/inc xmloff/Library_xo.mk xmloff/source

2017-06-13 Thread Troy Rollo
 sw/source/core/unocore/unostyle.cxx |3 
 sw/source/filter/xml/xmlfmt.cxx |   53 ++-
 xmloff/Library_xo.mk|1 
 xmloff/inc/prstylecond.hxx  |   23 ++
 xmloff/source/style/prstylecond.cxx |  125 
 xmloff/source/style/styleexp.cxx|   50 ++
 6 files changed, 251 insertions(+), 4 deletions(-)

New commits:
commit e9869b9b38d4e4e7f893aecb26f73d985f17e350
Author: Troy Rollo 
Date:   Tue Jun 6 17:41:33 2017 +1000

tdf#103091 conditional style conditions not saved

Change-Id: Iccf3eb531ee3382d27105e5ccce6013707a646b6
Reviewed-on: https://gerrit.libreoffice.org/38451
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 
(cherry picked from commit a5b4cb3f836c991d0647f55e1ef4920ce6115eac)
Reviewed-on: https://gerrit.libreoffice.org/38747

diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 63ce5d95beb6..ad6dd78b687e 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -2013,7 +2013,8 @@ void SwXStyle::SetPropertyValues_Impl(const 
uno::Sequence& rPropertyNa
 {
 if(!m_pDoc)
 throw uno::RuntimeException();
-const SfxItemPropertySet* pPropSet = 
aSwMapProvider.GetPropertySet(m_rEntry.m_nPropMapType);
+sal_Int8 nPropSetId = m_bIsConditional ? 
PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
+const SfxItemPropertySet* pPropSet = 
aSwMapProvider.GetPropertySet(nPropSetId);
 const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
 if(rPropertyNames.getLength() != rValues.getLength())
 throw lang::IllegalArgumentException();
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index b65cb0dc525b..b5aabd8cd96f 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -31,6 +31,7 @@
 #include "docary.hxx"
 #include 
 #include "unostyle.hxx"
+#include "unoprnms.hxx"
 #include "fmtpdsc.hxx"
 #include "pagedesc.hxx"
 #include 
@@ -44,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "xmlimp.hxx"
 #include "xmltbli.hxx"
 #include "cellatr.hxx"
@@ -51,10 +53,13 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
 using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
 using namespace ::xmloff::token;
 
 class SwXMLConditionParser_Impl
@@ -205,8 +210,11 @@ public:
 const uno::Reference< xml::sax::XAttributeList > & xAttrList );
 virtual ~SwXMLConditionContext_Impl() override;
 
-
 bool IsValid() const { return 0 != nCondition; }
+
+sal_uInt32 getCondition() const { return nCondition; }
+sal_uInt32 getSubCondition() const { return nSubCondition; }
+OUString const &getApplyStyle() const { return sApplyStyle; }
 };
 
 SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
@@ -257,10 +265,12 @@ typedef 
std::vector> SwXMLConditions_
 class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
 {
 std::unique_ptr pConditions;
+uno::Reference < style::XStyle > xNewStyle;
 
 protected:
 
 virtual uno::Reference < style::XStyle > Create() override;
+virtual void Finish( bool bOverwrite ) override;
 
 public:
 
@@ -280,7 +290,6 @@ public:
 
 uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
 {
-uno::Reference < style::XStyle > xNewStyle;
 
 if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
 {
@@ -302,6 +311,46 @@ uno::Reference < style::XStyle > 
SwXMLTextStyleContext_Impl::Create()
 return xNewStyle;
 }
 
+void
+SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
+{
+
+if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() && 
xNewStyle.is() )
+{
+CommandStruct const *aCommands = SwCondCollItem::GetCmds();
+
+Reference< XPropertySet > xPropSet( xNewStyle, UNO_QUERY );
+
+uno::Sequence< beans::NamedValue > aSeq( pConditions->size() );
+
+std::vector>::size_type i;
+unsigned j;
+
+for( i = 0; i < pConditions->size(); ++i )
+{
+if( (*pConditions)[i]->IsValid() )
+{
+sal_uInt32 nCond = (*pConditions)[i]->getCondition();
+sal_uInt32 nSubCond = (*pConditions)[i]->getSubCondition();
+
+for( j = 0; j < COND_COMMAND_COUNT; ++j )
+{
+if( aCommands[j].nCnd == nCond &&
+aCommands[j].nSubCond == nSubCond )
+{
+aSeq[i].Name = GetCommandContextByIndex( j );
+aSeq[i].Value <<= GetImport().GetStyleDisplayName( 
GetFamily(), (*pConditions)[i]-&g

[Libreoffice-commits] core.git: sw/source xmloff/inc xmloff/Library_xo.mk xmloff/source

2017-06-13 Thread Troy Rollo
 sw/source/core/unocore/unostyle.cxx |3 
 sw/source/filter/xml/xmlfmt.cxx |   52 ++
 xmloff/Library_xo.mk|1 
 xmloff/inc/prstylecond.hxx  |   23 ++
 xmloff/source/style/prstylecond.cxx |  125 
 xmloff/source/style/styleexp.cxx|   50 ++
 6 files changed, 251 insertions(+), 3 deletions(-)

New commits:
commit a5b4cb3f836c991d0647f55e1ef4920ce6115eac
Author: Troy Rollo 
Date:   Tue Jun 6 17:41:33 2017 +1000

tdf#103091 conditional style conditions not saved

Change-Id: Iccf3eb531ee3382d27105e5ccce6013707a646b6
Reviewed-on: https://gerrit.libreoffice.org/38451
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index f9d3a06acbf2..2cce53ca24b6 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1997,7 +1997,8 @@ void SwXStyle::SetPropertyValues_Impl(const 
uno::Sequence& rPropertyNa
 {
 if(!m_pDoc)
 throw uno::RuntimeException();
-const SfxItemPropertySet* pPropSet = 
aSwMapProvider.GetPropertySet(m_rEntry.m_nPropMapType);
+sal_Int8 nPropSetId = m_bIsConditional ? 
PROPERTY_MAP_CONDITIONAL_PARA_STYLE : m_rEntry.m_nPropMapType;
+const SfxItemPropertySet* pPropSet = 
aSwMapProvider.GetPropertySet(nPropSetId);
 const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
 if(rPropertyNames.getLength() != rValues.getLength())
 throw lang::IllegalArgumentException();
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index 685e7bc1dd75..ec0ac4cb77d0 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -31,6 +31,7 @@
 #include "docary.hxx"
 #include 
 #include "unostyle.hxx"
+#include "unoprnms.hxx"
 #include "fmtpdsc.hxx"
 #include "pagedesc.hxx"
 #include 
@@ -44,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "xmlimp.hxx"
 #include "xmltbli.hxx"
 #include "cellatr.hxx"
@@ -51,10 +53,13 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
 using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
 using namespace ::xmloff::token;
 
 class SwXMLConditionParser_Impl
@@ -205,6 +210,10 @@ public:
 const uno::Reference< xml::sax::XAttributeList > & xAttrList );
 
 bool IsValid() const { return Master_CollCondition::NONE != nCondition; }
+
+Master_CollCondition getCondition() const { return nCondition; }
+sal_uInt32 getSubCondition() const { return nSubCondition; }
+OUString const &getApplyStyle() const { return sApplyStyle; }
 };
 
 SwXMLConditionContext_Impl::SwXMLConditionContext_Impl(
@@ -250,10 +259,12 @@ typedef 
std::vector> SwXMLConditions_
 class SwXMLTextStyleContext_Impl : public XMLTextStyleContext
 {
 std::unique_ptr pConditions;
+uno::Reference < style::XStyle > xNewStyle;
 
 protected:
 
 virtual uno::Reference < style::XStyle > Create() override;
+virtual void Finish( bool bOverwrite ) override;
 
 public:
 
@@ -273,7 +284,6 @@ public:
 
 uno::Reference < style::XStyle > SwXMLTextStyleContext_Impl::Create()
 {
-uno::Reference < style::XStyle > xNewStyle;
 
 if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() )
 {
@@ -295,6 +305,46 @@ uno::Reference < style::XStyle > 
SwXMLTextStyleContext_Impl::Create()
 return xNewStyle;
 }
 
+void
+SwXMLTextStyleContext_Impl::Finish( bool bOverwrite )
+{
+
+if( pConditions && XML_STYLE_FAMILY_TEXT_PARAGRAPH == GetFamily() && 
xNewStyle.is() )
+{
+CommandStruct const *aCommands = SwCondCollItem::GetCmds();
+
+Reference< XPropertySet > xPropSet( xNewStyle, UNO_QUERY );
+
+uno::Sequence< beans::NamedValue > aSeq( pConditions->size() );
+
+std::vector>::size_type i;
+unsigned j;
+
+for( i = 0; i < pConditions->size(); ++i )
+{
+if( (*pConditions)[i]->IsValid() )
+{
+Master_CollCondition nCond = (*pConditions)[i]->getCondition();
+sal_uInt32 nSubCond = (*pConditions)[i]->getSubCondition();
+
+for( j = 0; j < COND_COMMAND_COUNT; ++j )
+{
+if( aCommands[j].nCnd == nCond &&
+aCommands[j].nSubCond == nSubCond )
+{
+aSeq[i].Name = GetCommandContextByIndex( j );
+aSeq[i].Value <<= GetImport().GetStyleDisplayName( 
GetFamily(), (*pConditions)[i]->getApplyStyle() );
+break;
+}
+}
+}
+}
+
+xPropSet

[Libreoffice-commits] core.git: Branch 'libreoffice-4-1' - sw/qa sw/source

2013-08-26 Thread Troy Rollo
 sw/qa/complex/writer/CheckCrossReferences.java  |   74 
 sw/qa/complex/writer/testdocuments/CheckCrossReferences.odt |binary
 sw/source/core/doc/number.cxx   |   16 --
 3 files changed, 56 insertions(+), 34 deletions(-)

New commits:
commit 4760c79afe37eaa95a93f3e8ad0a2775c86359dd
Author: Troy Rollo 
Date:   Mon Aug 26 15:14:40 2013 +0200

fdo#33960: sw: fix cross reference fields some more

Change-Id: I46f9cf4132835c10ad82c9b014e5e8647902ab5e
Signed-off-by: Michael Stahl 

diff --git a/sw/qa/complex/writer/CheckCrossReferences.java 
b/sw/qa/complex/writer/CheckCrossReferences.java
index 541ea49..c12f81a 100644
--- a/sw/qa/complex/writer/CheckCrossReferences.java
+++ b/sw/qa/complex/writer/CheckCrossReferences.java
@@ -38,28 +38,20 @@ public class CheckCrossReferences {
 public com.sun.star.text.XTextField getNextField()
 throws com.sun.star.uno.Exception
 {
-if ( xPortionEnum != null ) {
-while ( xPortionEnum.hasMoreElements() ) {
-com.sun.star.beans.XPropertySet xPortionProps =
+while (true) {
+while (xPortionEnum == null) {
+if (!xParaEnum.hasMoreElements())
+fail("Cannot retrieve next field.");
+
+com.sun.star.container.XEnumerationAccess aPara =
 UnoRuntime.queryInterface(
-com.sun.star.beans.XPropertySet.class , 
xPortionEnum.nextElement());
-final String sPortionType =
-xPortionProps.getPropertyValue( "TextPortionType" 
).toString();
-if ( sPortionType.equals( "TextField") ) {
-com.sun.star.text.XTextField xField = 
UnoRuntime.queryInterface(
-com.sun.star.text.XTextField.class,
-xPortionProps.getPropertyValue( "TextField" ) );
-assertNotNull("Cannot retrieve next field.", xField);
-return xField;
-}
+com.sun.star.container.XEnumerationAccess.class, 
xParaEnum.nextElement());
+xPortionEnum = aPara.createEnumeration();
 }
-}
 
-while ( xParaEnum.hasMoreElements() ) {
-com.sun.star.container.XEnumerationAccess aPara =
-UnoRuntime.queryInterface(
-com.sun.star.container.XEnumerationAccess.class, 
xParaEnum.nextElement());
-xPortionEnum = aPara.createEnumeration();
+if ( xPortionEnum == null )
+break;
+
 while ( xPortionEnum.hasMoreElements() ) {
 com.sun.star.beans.XPropertySet xPortionProps =
 UnoRuntime.queryInterface(
@@ -74,9 +66,9 @@ public class CheckCrossReferences {
 return xField;
 }
 }
+xPortionEnum = null;
 }
 
-fail("Cannot retrieve next field.");
 return null; // unreachable
 }
 
@@ -135,6 +127,12 @@ public class CheckCrossReferences {
 final String FldResult4 = "1";
 final String FldResult5 = "1";
 final String FldResult6 = "A.1";
+final String FldResult7 = "2(a)";
+final String FldResult8 = "2(b)";
+final String FldResult9 = "2";
+final String FldResult10 = "1(a)";
+final String FldResult11 = "(b)";
+final String FldResult12 = "(a)";
 
 // variables for current field
 com.sun.star.text.XTextField xField = null;
@@ -175,6 +173,42 @@ public class CheckCrossReferences {
 checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult6 );
 checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult4 );
 checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult6 );
+
+xField = getNextField();
+xProps = getFieldProps( xField );
+checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult7 );
+checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult12 );
+checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult7 );
+
+xField = getNextField();
+xProps = getFieldProps( xField );
+checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult8 );
+checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER_NO_CONTEXT, FldResult11 );
+checkField( xField, xProps, 
com.sun.star.text.ReferenceFieldPart.NUMBER_FULL_CONTEXT, FldResult8 );
+
+xField 

Re: [PATCH][RESEND] Writer - cross-references to numbered paragraphs still wrong (bug ID 36960)

2013-08-22 Thread Troy Rollo
On Wed, 21 Aug 2013, Miklos Vajna wrote:
> Hi Troy,
> 
> On Sat, Aug 17, 2013 at 01:06:21PM +1000, Troy Rollo  
wrote:
> > Bug 36960 was never fixed correctly (or rather, I suspect it was fixed,
> > then broken when work was done to make the tests pass).
> 
> What but is this? https://bugs.freedesktop.org/show_bug.cgi?id=36960 is
> "Missing AudioFolders for Sony Walkman NWZ-S638F".
> 
> Thanks,
> 
> Miklos

It should be 33960
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[PATCH][RESEND] Writer - cross-references to numbered paragraphs still wrong (bug ID 36960)

2013-08-19 Thread Troy Rollo
Bug 36960 was never fixed correctly (or rather, I suspect it was fixed, then 
broken when work was done to make the tests pass). The attached patch fixes 
the bug and adds new tests for cross-references to numbered paragraphs. The 
nature of the bug is that if you have numbered paragraphs like this:

   1. one
(a) two
(b) three
   2. four
(a) five

a cross reference in paragraph 2(a), to paragraph 1(a), returns "1.(a)", which 
is not correct.


CheckCrossReferences.odt
Description: application/vnd.oasis.opendocument.text
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 27b2cb9..66be2d8e 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -739,7 +739,6 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
 if ( rNodeNum.GetLevelInListTree() >= 0 )
 {
 bool bOldHadPrefix = true;
-bool bFirstIteration = true;
 OUString sOldPrefix;
 
 const SwNodeNum* pWorkingNodeNum( &rNodeNum );
@@ -779,7 +778,7 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
 aExtremities.nPrefixChars -= nStrip;
 }
 
-if ((bFirstIteration || bOldHadPrefix) &&
+if ((bOldHadPrefix) &&
  aExtremities.nSuffixChars &&
  !aExtremities.nPrefixChars
)
@@ -788,10 +787,6 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
 while (aPrevStr.Len() - nStrip2 < aExtremities.nSuffixChars)
 {
 char const cur = aPrevStr.GetChar(nStrip2);
-if  (!bFirstIteration && '\t' != cur && ' ' != cur)
-{
-break;
-}
 --nStrip2;
 }
 if (nStrip2 < aPrevStr.Len())
@@ -799,7 +794,7 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
 aPrevStr.Erase(nStrip2, aPrevStr.Len() - nStrip2);
 }
 }
-else if (sOldPrefix.getLength())
+else if (!aExtremities.nSuffixChars && !bOldHadPrefix)
 {
 aRefNumStr.Insert(sOldPrefix, 0);
 }
@@ -809,11 +804,6 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
 
 aRefNumStr.Insert( aPrevStr, 0 );
 }
-else if ( aRefNumStr.Len() > 0 )
-{
-sOldPrefix += " ";
-bOldHadPrefix = true;
-}
 
 if ( bInclSuperiorNumLabels && pWorkingNodeNum->GetLevelInListTree() > 0 )
 {
@@ -830,7 +820,6 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum,
 {
 break;
 }
-bFirstIteration = false;
 } while ( pWorkingNodeNum &&
   pWorkingNodeNum->GetLevelInListTree() >= 0 &&
   static_cast(pWorkingNodeNum->GetLevelInListTree()) >= nRestrictInclToThisLevel );
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: LibreOffice blanket license statement ...

2012-05-11 Thread Troy Rollo
All of my past & future contributions to LibreOffice may be licensed under the 
MPL/LGPLv3+ dual license

On Friday 11 May 2012, Michael Meeks wrote:
> Hi Troy,
> 
>   I'm just working through the MPL/LGPLv3+ re-licensing audit at
> the moment (so we can include code from Apache OpenOffice :-) What would
> really help reduce the work would be if we could have a blanket
> statement from you for all past/future contributions we can link into:
> 
> http://wiki.documentfoundation.org/Development/Developers
> 
>   Something like:
> 
> "All of my past & future contributions to LibreOffice may be
>  licensed under the MPL/LGPLv3+ dual license"
> 
>   sent to the libreoffice@lists.freedesktop.org would be wonderful (no
> subscription required). Your nice fixes are much appreciated :-)
> 
>   Thanks !
> 
>   Michael.


-- 
t...@troy.rollo.name - Sydney, Australia


smime.p7s
Description: S/MIME cryptographic signature
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] fix for fdo#33960 "cross reference to a list number, dot bug" makes sw/qa/complex/writer fail

2011-09-07 Thread Troy Rollo
On Wednesday 07 September 2011, Stephan Bergmann wrote:

> Troy, will you come up with a fix that brings
> sw/source/core/doc/number.cxx and
> sw/qa/complex/writer/CheckCrossReferences.java in sync again?

I won't be able to do that until mid November due to other commitments.

-- 
t...@troy.rollo.name - Sydney, Australia


signature.asc
Description: This is a digitally signed message part.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] fix for fdo#33960 "cross reference to a list number, dot bug" makes sw/qa/complex/writer fail

2011-09-06 Thread Troy Rollo
On Wednesday 07 September 2011, Stephan Bergmann wrote:
> > 
> >  final String FldResult1 = "*i*";
> >  final String FldResult2 = "+b+*i*";
> >  final String FldResult3 = "-1-+b+*i*";
> > 
> > -final String FldResult4 = "1.";
> > -final String FldResult5 = " 1.";
> > -final String FldResult6 = "A. 1.";
> > +final String FldResult4 = "1";
> > +final String FldResult5 = " 1";
> > +final String FldResult6 = "A 1";

The last one should be "A.1" rather than "A 1". The second last should be "1" 
rather than " 1". The ule implemented was actually somewhat more complex than 
the simple rule described in the bug report.


signature.asc
Description: This is a digitally signed message part.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Fix fdo#36868 - doc import list numbering error

2011-07-23 Thread Troy Rollo
This patch appears to be fix fdo#36868. The problem is that the paragraph
style was never being assigned an outline list level. The saved file did
not have an sprmPOutLvl for that paragraph (although it did have one for
the level 0 style), just an sprmPIlvl and an sprmPIlfo. Therefore there
was no call to SwWW8ImplReader::Read_POutLvl to set nOutlineLevel.

---
 sw/source/filter/ww8/ww8par3.cxx |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index a772166..64d6e3a 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1704,6 +1704,8 @@ void SwWW8ImplReader::SetStylesList(sal_uInt16 nStyle, 
sal_uInt16 nActLFO,
 {
 rStyleInf.nLFOIndex  = nActLFO;
 rStyleInf.nListLevel = nActLevel;
+if (nActLevel > 0) // it must be an outline list
+rStyleInf.nOutlineLevel = nActLevel;
 
 if (
 (USHRT_MAX > nActLFO) &&
-- 
1.7.2.5

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Fix parent level count in numbering from docx

2011-07-22 Thread Troy Rollo
Before this patch, when importing from docx, if there were no parent
numbering levels in the number formats for outline numbered paragraphs, the
import would include all parent levels back to the second numbering level,
in the third and subsequent numbering levels.

---
 writerfilter/source/dmapper/NumberingManager.cxx |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/writerfilter/source/dmapper/NumberingManager.cxx 
b/writerfilter/source/dmapper/NumberingManager.cxx
index f987250..c6b9e8b 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -144,7 +144,7 @@ void ListLevel::SetValue( Id nId, sal_Int32 nValue )
 sal_Int16 ListLevel::GetParentNumbering( OUString sText, sal_Int16 nLevel, 
 OUString& rPrefix, OUString& rSuffix )
 {
-sal_Int16 nParentNumbering = nLevel;
+sal_Int16 nParentNumbering = 1;
 
 //now parse the text to find %n from %1 to %nLevel+1
 //everything before the first % and the last %x is prefix and suffix
-- 
1.7.2.5

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Fix field values in export to docx

2011-07-22 Thread Troy Rollo
Prior to this patch, fields were being exported to docx file with the
field value being the name of the field. This patch changes it to
export the field value as the field value.
---
 sw/source/filter/ww8/docxattributeoutput.cxx |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 6086213..390bd60 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -806,8 +806,10 @@ void DocxAttributeOutput::EndField_Impl( FieldInfos& 
rInfos )
 // Write the Field latest value
 m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
 
-// Find another way for hyperlinks
-RunText( rInfos.pField->GetFieldName() );
+String sExpand( rInfos.pField->ExpandField( true ) );
+sExpand.SearchAndReplaceAll( 0x0A, 0x0B );
+RunText( sExpand );
+
 m_pSerializer->endElementNS( XML_w, XML_r );
 }
 
-- 
1.7.2.5

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Import of xrefs to numbered paragraphs from docx

2011-07-22 Thread Troy Rollo
This replaces the earlier version of this patch, which was wrong for the
NUMBER_FULL_CONTEXT cross-reference type.
---
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   20 +++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9944c8c..b3e88ea 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2680,6 +2680,21 @@ void DomainMapper_Impl::CloseFieldCommand()
 //above-below
 nFieldPart = text::ReferenceFieldPart::UP_DOWN;
 }
+else if( lcl_FindInCommand( pContext->GetCommand(), 
'r', sValue ))
+{
+//number
+nFieldPart = text::ReferenceFieldPart::NUMBER;
+}
+else if( lcl_FindInCommand( pContext->GetCommand(), 
'n', sValue ))
+{
+//number-no-context
+nFieldPart = 
text::ReferenceFieldPart::NUMBER_NO_CONTEXT;
+}
+else if( lcl_FindInCommand( pContext->GetCommand(), 
'w', sValue ))
+{
+//number-full-context
+nFieldPart = 
text::ReferenceFieldPart::NUMBER_FULL_CONTEXT;
+}
 xFieldProperties->setPropertyValue(
 rPropNameSupplier.GetName( 
PROP_REFERENCE_FIELD_PART ), uno::makeAny( nFieldPart ));
 }
@@ -2980,7 +2995,10 @@ void DomainMapper_Impl::AddBookmark( const 
::rtl::OUString& rBookmarkName, const
 xCursor->gotoRange( xTextAppend->getEnd(), true );
 uno::Reference< container::XNamed > xBkmNamed( xBookmark, 
uno::UNO_QUERY_THROW );
 //todo: make sure the name is not used already!
-xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
+if ( aBookmarkIter->second.m_sBookmarkName.getLength() > 0 )
+xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
+else
+xBkmNamed->setName( rBookmarkName );
 xTextAppend->insertTextContent( uno::Reference< text::XTextRange 
>( xCursor, uno::UNO_QUERY_THROW), xBookmark, !xCursor->isCollapsed() );
 m_aBookmarkMap.erase( aBookmarkIter );
 }
-- 
1.7.2.5

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Import of xrefs to numbered paragraphs from docx

2011-07-21 Thread Troy Rollo
The first part of this patch adds importing of cross-references to numbered
paragraphs from docx file.

The second part provides a fix to imports of bookmarks from docx, which in
the test files I have end up importing with an empty bookmark name. The
problem is that for each bookmark, DomainMapper_Impl::AddBookmark is called
twice - once with an empty string for rBookmarkName, and once for the
string that is in the file. The fix I have used is to ensure the passed in
name is used if the bookmark has presiously been added, and the old one has
an empty string as the name. This works, but I am not sure it is correct -
I have not investigated why it is called with an empty string in the first
place.
---
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   20 +++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9944c8c..28d6215 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2680,6 +2680,21 @@ void DomainMapper_Impl::CloseFieldCommand()
 //above-below
 nFieldPart = text::ReferenceFieldPart::UP_DOWN;
 }
+else if( lcl_FindInCommand( pContext->GetCommand(), 
'r', sValue ))
+{
+//number
+nFieldPart = text::ReferenceFieldPart::NUMBER;
+}
+else if( lcl_FindInCommand( pContext->GetCommand(), 
'n', sValue ))
+{
+//number-no-context
+nFieldPart = 
text::ReferenceFieldPart::NUMBER_NO_CONTEXT;
+}
+else if( lcl_FindInCommand( pContext->GetCommand(), 
'w', sValue ))
+{
+//number-full-context
+nFieldPart = text::ReferenceFieldPart::UP_DOWN;
+}
 xFieldProperties->setPropertyValue(
 rPropNameSupplier.GetName( 
PROP_REFERENCE_FIELD_PART ), uno::makeAny( nFieldPart ));
 }
@@ -2980,7 +2995,10 @@ void DomainMapper_Impl::AddBookmark( const 
::rtl::OUString& rBookmarkName, const
 xCursor->gotoRange( xTextAppend->getEnd(), true );
 uno::Reference< container::XNamed > xBkmNamed( xBookmark, 
uno::UNO_QUERY_THROW );
 //todo: make sure the name is not used already!
-xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
+if ( aBookmarkIter->second.m_sBookmarkName.getLength() > 0 )
+xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
+else
+xBkmNamed->setName( rBookmarkName );
 xTextAppend->insertTextContent( uno::Reference< text::XTextRange 
>( xCursor, uno::UNO_QUERY_THROW), xBookmark, !xCursor->isCollapsed() );
 m_aBookmarkMap.erase( aBookmarkIter );
 }
-- 
1.7.2.5

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PUSHED] Preserve RTF \'00 sequences (NUL) in strings

2011-07-20 Thread Troy Rollo
On Tuesday 19 July 2011, Caolán McNamara wrote:

> Ahhh, gotcha. Indeed, nice catch. Looks good to me, and gives the
> expected results. Pushed. Can you confirm the patch is under our
> preferred LGPLv3+/MPLv1.1 combo ?

Sure, although I doubt there would be any copyright in that particular patch.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PATCH] Fix 33898 - import/export xrefs to numbered paras

2011-07-19 Thread Troy Rollo
On Tuesday 19 July 2011, Korrawit Pruegsanusak wrote:
> Hello Troy,
> 
> Digging mailing-list archive and just glancing at your patch,
> isn't this patch against fdo#33960 ?
> (https://bugs.freedesktop.org/show_bug.cgi?id=33960)
> IMHO it isn't likely to be 33898.

It should have said 33893 (although I also posted a fix to 33960 separately).
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PATCH] Preserve RTF \'00 sequences (NUL) in strings

2011-07-19 Thread Troy Rollo
On Tuesday 19 July 2011, Caolán McNamara wrote:
> Well, this'll work I guess, and I'm minded to push it, but why ;-) Is
> there a concrete bug this fixes ?

Yes, but it is a little obscure. If you take the attached ODT file, save it as 
an RTF, and then load the RTF, the prefix to the paragraph number will be 
wrong ("\x05(" instead of "(["). With the patch, it works. The problem is that 
in this file, the leveltext field in the number format is (correctly) exported 
to RTF as follows:

  \'05([\'00])

Without the patch the embedded NUL gets dropped, so the resulting string on 
reading is:

"\x05([])"

With that string, the following test in rtfnum.cxx fails:

   if( DelCharAtEnd( sLvlText, ';' ).Len() &&
sLvlText.Len() && sLvlText.Len() ==
(sal_uInt16)(sLvlText.GetChar( 0 )) + 1 )
sLvlText.Erase( 0, 1 );

If the correct string ("\x05([\0])") were read, the test would succeed, and 
the first character would be stripped, giving "([\0])"

Later, when the string is decoded in the number format we get "\x05(" as the 
prefix instead of "([". The suffix comes out OK because the missing NUL is 
made up for by the additional \x05 - so the suffix is in the right position in 
the string.  However the prefix was shifted one position to the right.

This particular manifestation of the problem only shows up clearly when the 
first list level has a visible prefix before the number.


Number RTF test.odt
Description: application/vnd.oasis.opendocument.text
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Fix 33898 - import/export xrefs to numbered paras

2011-07-17 Thread Troy Rollo
---
 sw/source/filter/rtf/rtffld.cxx  |   50 -
 sw/source/filter/ww8/ww8atr.cxx  |   12 +++
 sw/source/filter/ww8/ww8par5.cxx |   63 +++--
 3 files changed, 65 insertions(+), 60 deletions(-)

diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx
index f5d9058..ccac5f1 100644
--- a/sw/source/filter/rtf/rtffld.cxx
+++ b/sw/source/filter/rtf/rtffld.cxx
@@ -813,8 +813,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr )
 case RTFFLD_REF:
 {
 String sOrigBkmName;
-bool bChapterNr = false;
-bool bAboveBelow = false;
+REFERENCEMARK eFormat = REF_CONTENT;
 
 RtfFieldSwitch aRFS( aSaveStr );
 while( !aRFS.IsAtEnd() )
@@ -828,42 +827,35 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr )
 sOrigBkmName = sParam;
 break;
 
+/* References to numbers in Word could be either to a 
numbered
+paragraph or to a chapter number. However Word does not 
seem to
+have the capability we do, of refering to the chapter 
number some
+other bookmark is in. As a result, cross-references to 
chapter
+numbers in a word document will be cross-references to a 
numbered
+paragraph, being the chapter heading paragraph. As it 
happens, our
+cross-references to numbered paragraphs will do the right 
thing
+when the target is a numbered chapter heading, so there is 
no need
+for us to use the REF_CHAPTER bookmark format on import.
+*/
 case 'n':
+eFormat = REF_NUMBER_NO_CONTEXT;
+break;
 case 'r':
+eFormat = REF_NUMBER;
+break;
 case 'w':
-bChapterNr = true; // activate flag 'Chapter Number'
+eFormat = REF_NUMBER_FULL_CONTEXT;
 break;
 
 case 'p':
-bAboveBelow = true;
+eFormat = REF_UPDOWN;
 break;
 }
 }
-if (!bAboveBelow || bChapterNr)
-{
-if (bChapterNr)
-{
-SwGetRefField aFld(
-(SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD 
),
-sOrigBkmName,REF_BOOKMARK,0,REF_CHAPTER);
-pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
-}
-else
-{
-SwGetRefField aFld(
-(SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD 
),
-sOrigBkmName,REF_BOOKMARK,0,REF_CONTENT);
-pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
-}
-}
-
-if( bAboveBelow )
-{
-SwGetRefField aFld( (SwGetRefFieldType*)
-pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName, 
REF_BOOKMARK, 0,
-REF_UPDOWN );
-pDoc->InsertPoolItem(*pPam, SwFmtFld(aFld), 0);
-}
+SwGetRefField aFld(
+(SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ),
+sOrigBkmName,REF_BOOKMARK,0,eFormat);
+pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 );
 }
 break;
 
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 0ea9201..1464e42 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2831,6 +2831,18 @@ void AttributeOutputBase::TextField( const SwFmtFld& 
rField )
 sStr = FieldString(eFld);
 sStr += GetExport().GetBookmarkName(nSubType,
 &rRFld.GetSetRefName(), 0);
+switch (pFld->GetFormat())
+{
+case REF_NUMBER:
+sStr.APPEND_CONST_ASC(" \\r");
+break;
+case REF_NUMBER_NO_CONTEXT:
+sStr.APPEND_CONST_ASC(" \\n");
+break;
+case REF_NUMBER_FULL_CONTEXT:
+sStr.APPEND_CONST_ASC(" \\w");
+break;
+}
 break;
 case REF_FOOTNOTE:
 case REF_ENDNOTE:
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 759293d..62d73b6 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -2089,8 +2089,7 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8

[Libreoffice] [PATCH] Preserve RTF \'00 sequences (NUL) in strings

2011-07-17 Thread Troy Rollo
---
 svtools/source/svrtf/parrtf.cxx |   22 +-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/svtools/source/svrtf/parrtf.cxx b/svtools/source/svrtf/parrtf.cxx
index 0b722d8..0c60834 100644
--- a/svtools/source/svrtf/parrtf.cxx
+++ b/svtools/source/svrtf/parrtf.cxx
@@ -341,7 +341,27 @@ void SvRTFParser::ScanText( const sal_Unicode cBreak )
 ByteString aByteString;
 while (1)
 {
-aByteString.Append((char)GetHexValue());
+char c = (char)GetHexValue();
+
+if (c)
+{
+aByteString.Append(c);
+}
+else
+{
+/* \'00 is a valid internal character in  a
+* string in RTF, however ByteString::Append
+* does nothing if '\0' is passed in. It is
+* otherwise capable of handling strings with
+* embedded NULs, so add a '\1' and then
+* change it, as ByteString::SetChar does not
+* care if the character is '\0'.
+*/
+int nLen = aByteString.Len();
+
+aByteString.Append('\001');
+aByteString.SetChar(nLen, '\0');
+}
 
 bool bBreak = false;
 sal_Char nSlash = '\\';
-- 
1.7.2.5

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [Libreoffice] [PATCH] Implement new rule for xref to numbered paragraphs

2011-07-12 Thread Troy Rollo
On Tuesday 12 July 2011, Caolán McNamara wrote:
> This looks good, however what does it do :-) Set sane leading/trailing
> text/space defaults for a new list numbering level based on the previous
> one ?

Implements the rules discussed in 


(I was busy with study commitments between then and early July - catching up 
now on all the other things I was neglecting then).
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Implement new rule for xref to numbered paragraphs

2011-07-11 Thread Troy Rollo
---
 sw/inc/numrule.hxx|   10 ++-
 sw/source/core/doc/number.cxx |   56 ++---
 2 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx
index 26d0eff..392ac06 100644
--- a/sw/inc/numrule.hxx
+++ b/sw/inc/numrule.hxx
@@ -105,6 +105,13 @@ class SW_DLLPUBLIC SwNumRule
 public:
 typedef std::vector< SwTxtNode* > tTxtNodeList;
 typedef std::vector< SwTxtFmtColl* > tParagraphStyleList;
+
+struct Extremities
+{
+sal_uInt16 nPrefixChars;
+sal_uInt16 nSuffixChars;
+};
+
 private:
 friend void _FinitCore();
 
@@ -171,7 +178,8 @@ public:
 String MakeNumString( const SwNumberTree::tNumberVector & rNumVector,
   const sal_Bool bInclStrings = sal_True,
   const sal_Bool bOnlyArabic = sal_False,
-  const unsigned int _nRestrictToThisLevel = MAXLEVEL 
) const;
+  const unsigned int _nRestrictToThisLevel = MAXLEVEL,
+  Extremities* pExtremities = 0 ) const;
 String MakeRefNumString( const SwNodeNum& rNodeNum,
  const bool bInclSuperiorNumLabels = false,
  const sal_uInt8 nRestrictInclToThisLevel = 0 ) 
const;
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index a977649..57fcd19 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -671,12 +671,16 @@ String SwNumRule::MakeNumString( const SwNodeNum& rNum, 
sal_Bool bInclStrings,
 String SwNumRule::MakeNumString( const SwNumberTree::tNumberVector & 
rNumVector,
  const sal_Bool bInclStrings,
  const sal_Bool bOnlyArabic,
- const unsigned int _nRestrictToThisLevel ) 
const
+ const unsigned int _nRestrictToThisLevel,
+ SwNumRule::Extremities* pExtremities ) const
 {
 String aStr;
 
 unsigned int nLevel = rNumVector.size() - 1;
 
+if ( pExtremities )
+pExtremities->nPrefixChars = pExtremities->nSuffixChars = 0;
+
 if ( nLevel > _nRestrictToThisLevel )
 {
 nLevel = _nRestrictToThisLevel;
@@ -734,8 +738,16 @@ String SwNumRule::MakeNumString( const 
SwNumberTree::tNumberVector & rNumVector,
 SVX_NUM_CHAR_SPECIAL != rMyNFmt.GetNumberingType() &&
 SVX_NUM_BITMAP != rMyNFmt.GetNumberingType() )
 {
-aStr.Insert( rMyNFmt.GetPrefix(), 0 );
-aStr += rMyNFmt.GetSuffix();
+String const &rPrefix = rMyNFmt.GetPrefix();
+String const &rSuffix = rMyNFmt.GetSuffix();
+
+aStr.Insert( rPrefix, 0 );
+aStr += rSuffix;
+if ( pExtremities )
+{
+pExtremities->nPrefixChars = rPrefix.Len();
+pExtremities->nSuffixChars = rSuffix.Len();
+}
 }
 }
 }
@@ -752,6 +764,8 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& 
rNodeNum,
 
 if ( rNodeNum.GetLevelInListTree() >= 0 )
 {
+sal_Bool bOldHadPrefix = sal_True;
+
 const SwNodeNum* pWorkingNodeNum( &rNodeNum );
 do
 {
@@ -768,11 +782,45 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& 
rNodeNum,
pWorkingNodeNum->GetTxtNode() &&
pWorkingNodeNum->GetTxtNode()->HasNumber() ) )
 {
-aRefNumStr.Insert( MakeNumString( 
pWorkingNodeNum->GetNumberVector() ), 0 );
+Extremities aExtremities;
+String aPrevStr = MakeNumString( 
pWorkingNodeNum->GetNumberVector(),
+ sal_True, sal_False, MAXLEVEL,
+ &aExtremities);
+intnLen = aPrevStr.Len();
+intnStrip = 0;
+sal_Unicodec;
+
+
+while ( nStrip < aExtremities.nPrefixChars &&
+   ( '\t' == ( c = aPrevStr.GetChar( nStrip ) ) ||
+ ' ' == c) )
+{
+++nStrip;
+}
+
+if (nStrip)
+{
+aPrevStr.Erase( 0, nStrip );
+aExtremities.nPrefixChars -= nStrip;
+nLen -= nStrip;
+}
+
+if ( bOldHadPrefix &&
+ aExtremities.nSuffixChars &&
+ !aExtremities.nPrefixChars
+   )
+{
+aPrevStr.Erase( nLen - aExtremities.nSuffixChars, 
aExtremities.nSuffixChars );
+}
+bOldHadPrefix = ( aExtremities.nPrefixChars >  0);
+
+aRefNumStr.Insert( aPrevS

Re: [Libreoffice] [PATCH] Cross-references to numbered paragraphs: remove trailing dots at the end of a cross-reference, or where they precede an open parenthesis that starts the next paragraph level

2011-04-16 Thread Troy Rollo
On Thursday 14 April 2011, Cedric Bosdonnat wrote:
> This is quite restrictive as it only clears the ending '.' I think that
> the same should apply whatever the suffix is.. Would one want to have
> [1-] as the reference?

If it were 20 years ago and I was designing on a clear slate, I agree it would 
be better to have a more complete rule. The rule I implemented is the rule 
used by Microsoft Word (as determined by testing), which I used for the 
following reasons:

1. The rule has operated for a long time now without, as far as I can see, any 
serious complaints about it.

2. Using the same rule as Microsoft Word will create fewer problems for 
document interchange with Microsoft Word.
 
> Why that test for strings starting with '(' ?

For the same reasons. I agree that, with a clean slate, the rule would be 
different.

I guess it depends on how important it is to keep document consistency high in 
interchange with Word.  If that is not important I can prepare a more complete 
set of rules, submit the rules for approval, and then implement a new patch. 
My initial thought was that the correct (clean slate) rule would be:

1. Strip any leading white space (but not trailing - although rule 2 might get 
that);
2. If there is formatting content after the number, and not before the number, 
strip it if either: 
(a) This is the last component in the reference; or
(b) The next component has formatting content before the number.

However I would note that one of the default outline numbering formats  (the 
"1." "(a)" format) in LibreOffice includes white space in front of the number 
at the first list level. Thus this rule would strip the white space, where on 
my testing MS Word would not. This would create a common inconsistency when 
going from LibreOffice to MS word.


signature.asc
Description: This is a digitally signed message part.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[Libreoffice] [PATCH] Cross-references to numbered paragraphs: remove trailing dots at the end of a cross-reference, or where they precede an open parenthesis that starts the next paragraph level in t

2011-04-14 Thread Troy Rollo
---
 sw/source/core/doc/number.cxx |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 95ea5c8..d7df858 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -770,7 +770,15 @@ String SwNumRule::MakeRefNumString( const SwNodeNum& 
rNodeNum,
pWorkingNodeNum->GetTxtNode() &&
pWorkingNodeNum->GetTxtNode()->HasNumber() ) )
 {
-aRefNumStr.Insert( MakeNumString( 
pWorkingNodeNum->GetNumberVector() ), 0 );
+String aPrevStr = MakeNumString( 
pWorkingNodeNum->GetNumberVector() );
+intnLen = aPrevStr.Len();
+
+if ( nLen > 0 && aPrevStr.GetChar(nLen - 1) == '.' &&
+ ( aRefNumStr.Len() == 0 ||
+  aRefNumStr.GetChar(0) == '(' )
+   )
+aPrevStr.Erase( nLen - 1, 1 );
+aRefNumStr.Insert( aPrevStr, 0 );
 }
 else if ( aRefNumStr.Len() > 0 )
 {
-- 
1.7.2.5

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice