[Libreoffice-commits] .: 2 commits - writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Tue Jun 19 00:28:58 PDT 2012


 writerfilter/source/dmapper/DomainMapper.cxx      |   23 ++++++++----
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   42 ++++++++++++++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    2 +
 3 files changed, 60 insertions(+), 7 deletions(-)

New commits:
commit 2123ede032ca64f696ef54af4ad3238974ca2b5d
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Jun 19 09:28:28 2012 +0100

    n#758883 dmapper: paragraph-level run props should affect numberings as well
    
    Change-Id: I707105f6da53a6cb790d743738875acde561e20f

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index c3b8a10..d4b01d6 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1437,6 +1437,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
     Value::Pointer_t pValue = rSprm.getValue();
     sal_Int32 nIntValue = pValue->getInt();
     rtl::OUString sStringValue = pValue->getString();
+    PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
 
     switch(nSprmId)
     {
@@ -1983,6 +1984,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
                         rContext->Insert(ePropertyId, true, aBold );
                         if( nSprmId != NS_sprm::LN_CFBoldBi ) // sprmCFBoldBi
                             rContext->Insert(PROP_CHAR_WEIGHT_ASIAN, true, aBold );
+
+                        uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
+                        if (xCharStyle.is())
+                            xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_WEIGHT), aBold);
                     }
                     break;
                     case 61: /*sprmCFItalic*/
@@ -2060,6 +2065,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
                 //Asian get the same value as Western
                 rContext->Insert( PROP_CHAR_HEIGHT, true, aVal );
                 rContext->Insert( PROP_CHAR_HEIGHT_ASIAN, true, aVal );
+
+                uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
+                if (xCharStyle.is())
+                    xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal);
             }
         }
         break;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 1dcb7f5..1ca32f6 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3561,6 +3561,48 @@ void DomainMapper_Impl::ApplySettingsTable()
     }
 }
 
+uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharStyle()
+{
+    uno::Reference<beans::XPropertySet> xRet;
+    OUString aStyle = GetCurrentParaStyleId();
+    if (aStyle.isEmpty() || GetTopContextType() != CONTEXT_PARAGRAPH)
+        return xRet;
+    const StyleSheetEntryPtr pEntry = GetStyleSheetTable()->FindStyleSheetByISTD(aStyle);
+    if (!pEntry)
+        return xRet;
+    const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
+    sal_Int32 nListId = pStyleSheetProperties->GetListId();
+    sal_Int32 nListLevel = pStyleSheetProperties->GetListLevel();
+    if (nListId < 0 || nListLevel < 0)
+        return xRet;
+
+    // So we are in a paragraph style and it has numbering. Look up the relevant character style.
+    OUString aListName = ListDef::GetStyleName(nListId);
+    uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY);
+    uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
+    uno::Reference<container::XNameAccess> xNumberingStyles;
+    xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
+    uno::Reference<beans::XPropertySet> xStyle(xNumberingStyles->getByName(aListName), uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xLevels(xStyle->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aProps;
+    xLevels->getByIndex(nListLevel) >>= aProps;
+    for (int i = 0; i < aProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aProps[i];
+
+        if (rProp.Name == "CharStyleName")
+        {
+            OUString aCharStyle;
+            rProp.Value >>= aCharStyle;
+            uno::Reference<container::XNameAccess> xCharacterStyles;
+            xStyleFamilies->getByName("CharacterStyles") >>= xCharacterStyles;
+            xRet.set(xCharacterStyles->getByName(aCharStyle), uno::UNO_QUERY);
+            break;
+        }
+    }
+    return xRet;
+}
+
 SectionPropertyMap * DomainMapper_Impl::GetSectionContext()
 {
     SectionPropertyMap* pSectionContext = 0;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 07f6934..77a2b62 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -613,6 +613,8 @@ public:
 
     void ApplySettingsTable();
     SectionPropertyMap * GetSectionContext();
+    /// If the current paragraph has a numbering style associated, this method returns its character style
+    com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> GetCurrentNumberingCharStyle();
 };
 } //namespace dmapper
 } //namespace writerfilter
commit 14d6cf1f8f86027d58fe56feae3139c314fbb058
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Jun 19 09:28:06 2012 +0100

    n#758883 dmapper: always set list id during stylesheet import
    
    This way the sprm handlers can be aware that a numbering is provided by
    that style.
    
    Change-Id: I5b5f1570a9e50fd8b3372f5ac7a6cd48e9751254

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 9f3d115..c3b8a10 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1484,15 +1484,15 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
             //convert the ListTable entry to a NumberingRules propery and apply it
             ListsManager::Pointer pListTable = m_pImpl->GetListTable();
             ListDef::Pointer pList = pListTable->GetList( nIntValue );
+            if( m_pImpl->IsStyleSheetImport() )
+            {
+                //style sheets cannot have a numbering rule attached
+                StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
+                pStyleSheetPropertyMap->SetListId( nIntValue );
+            }
             if( pList.get( ) )
             {
-                if( m_pImpl->IsStyleSheetImport() )
-                {
-                    //style sheets cannot have a numbering rule attached
-                    StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
-                    pStyleSheetPropertyMap->SetListId( nIntValue );
-                }
-                else
+                if( !m_pImpl->IsStyleSheetImport() )
                 {
                     uno::Any aRules = uno::makeAny( pList->GetNumberingRules( ) );
                     rContext->Insert( PROP_NUMBERING_RULES, true, aRules );


More information about the Libreoffice-commits mailing list