summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-08-23 17:32:05 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-08-23 17:34:55 +0200
commit5fd1516f82adf0330411adf90bee7e14cec856d5 (patch)
tree8f5518565538991fe89e59e738c2c6ffef6c666a /writerfilter
parent25af4f283fd9e8520a17350fd5e980ba9eb67f24 (diff)
refactor duplicated code to DomainMapper_Impl::getCurrentNumberingProperty
Change-Id: Id68df67e1301d0eed74c3bdcaabc7c601d72770b
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx63
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx31
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx3
3 files changed, 37 insertions, 60 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 205f586f22b2..4866e2d3b4b2 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1037,35 +1037,8 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
{
// Word inherits FirstLineIndent property of the numbering, even if ParaLeftMargin is set, Writer does not.
// So copy it explicitly, if necessary.
- PropertyMapPtr pContext = m_pImpl->GetTopContext();
- sal_Int32 nFirstLineIndent = 0;
-
- // See if we have a FirstLineIndent
- PropertyMap::iterator it = pContext->find(PropertyDefinition( PROP_NUMBERING_RULES, true ) );
- uno::Reference<container::XIndexAccess> xNumberingRules;
- if (it != pContext->end())
- xNumberingRules.set(it->second, uno::UNO_QUERY);
- it = pContext->find(PropertyDefinition( PROP_NUMBERING_LEVEL, true ) );
- sal_Int32 nNumberingLevel = -1;
- if (it != pContext->end())
- it->second >>= nNumberingLevel;
- if (xNumberingRules.is() && nNumberingLevel != -1)
- {
- uno::Sequence<beans::PropertyValue> aProps;
- xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
- for (int i = 0; i < aProps.getLength(); ++i)
- {
- const beans::PropertyValue& rProp = aProps[i];
+ sal_Int32 nFirstLineIndent = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
- if (rProp.Name == "FirstLineIndent")
- {
- rProp.Value >>= nFirstLineIndent;
- break;
- }
- }
- }
-
- // Then copy it over.
if (nFirstLineIndent != 0)
m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, true, uno::makeAny(nFirstLineIndent));
@@ -1079,39 +1052,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
{
// Word inherits FirstLineIndent/ParaLeftMargin property of the numbering, even if ParaRightMargin is set, Writer does not.
// So copy it explicitly, if necessary.
- PropertyMapPtr pContext = m_pImpl->GetTopContext();
- sal_Int32 nFirstLineIndent = 0;
- sal_Int32 nParaLeftMargin = 0;
-
- // See if we have a FirstLineIndent / ParaLeftMargin
- PropertyMap::iterator it = pContext->find(PropertyDefinition( PROP_NUMBERING_RULES, true ) );
- uno::Reference<container::XIndexAccess> xNumberingRules;
- if (it != pContext->end())
- xNumberingRules.set(it->second, uno::UNO_QUERY);
- it = pContext->find(PropertyDefinition( PROP_NUMBERING_LEVEL, true ) );
- sal_Int32 nNumberingLevel = -1;
- if (it != pContext->end())
- it->second >>= nNumberingLevel;
- if (xNumberingRules.is() && nNumberingLevel != -1)
- {
- uno::Sequence<beans::PropertyValue> aProps;
- xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
- for (int i = 0; i < aProps.getLength(); ++i)
- {
- const beans::PropertyValue& rProp = aProps[i];
-
- if (rProp.Name == "FirstLineIndent")
- {
- rProp.Value >>= nFirstLineIndent;
- }
- else if (rProp.Name == "IndentAt")
- {
- rProp.Value >>= nParaLeftMargin;
- }
- }
- }
+ sal_Int32 nFirstLineIndent = m_pImpl->getCurrentNumberingProperty("FirstLineIndent");
+ sal_Int32 nParaLeftMargin = m_pImpl->getCurrentNumberingProperty("IndentAt");
- // Then copy it over.
if (nFirstLineIndent != 0)
m_pImpl->GetTopContext()->Insert(PROP_PARA_FIRST_LINE_INDENT, true, uno::makeAny(nFirstLineIndent));
if (nParaLeftMargin != 0)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8bc792646952..18e8c45e5204 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3747,6 +3747,37 @@ void DomainMapper_Impl::processDeferredCharacterProperties()
}
}
+sal_Int32 DomainMapper_Impl::getCurrentNumberingProperty(OUString aProp)
+{
+ sal_Int32 nRet = 0;
+
+ PropertyMap::iterator it = m_pTopContext->find(PropertyDefinition( PROP_NUMBERING_RULES, true ) );
+ uno::Reference<container::XIndexAccess> xNumberingRules;
+ if (it != m_pTopContext->end())
+ xNumberingRules.set(it->second, uno::UNO_QUERY);
+ it = m_pTopContext->find(PropertyDefinition( PROP_NUMBERING_LEVEL, true ) );
+ sal_Int32 nNumberingLevel = -1;
+ if (it != m_pTopContext->end())
+ it->second >>= nNumberingLevel;
+ if (xNumberingRules.is() && nNumberingLevel != -1)
+ {
+ uno::Sequence<beans::PropertyValue> aProps;
+ xNumberingRules->getByIndex(nNumberingLevel) >>= aProps;
+ for (int i = 0; i < aProps.getLength(); ++i)
+ {
+ const beans::PropertyValue& rProp = aProps[i];
+
+ if (rProp.Name == aProp)
+ {
+ rProp.Value >>= nRet;
+ break;
+ }
+ }
+ }
+
+ return nRet;
+}
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index abe5ef4b17c1..55de1d4f1d80 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -643,6 +643,9 @@ public:
CONTEXT_CHARACTER is going to be used (e.g. by appendText()).
*/
void processDeferredCharacterProperties();
+
+ /// Get a property of the current numbering style's current level.
+ sal_Int32 getCurrentNumberingProperty(OUString aProp);
};
} //namespace dmapper
} //namespace writerfilter