[Libreoffice-commits] .: Branch 'libreoffice-3-6' - writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri Jul 20 05:12:37 PDT 2012


 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   74 +++++++++++-----------
 1 file changed, 40 insertions(+), 34 deletions(-)

New commits:
commit 5586159e46d5f38e322c88459e1e7beed8133161
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 19 23:34:18 2012 +0100

    Resolves: fdo#51772 failure to import a specific .rtf file
    
    In this example the xCharacterStyles->getByName(aCharStyle) throws, and the
    whole import is abandoned
    
    i.e.  xRet.set(xCharacterStyles->getByName(aCharStyle), uno::UNO_QUERY);
    
    so to keep things simple wrap the entire block in a try catch and return
    an empty xRet. Could use the hasByName around the specific failing query.
    
    Change-Id: I4f4970534cc2ff15c7d96ff2ee0a9affcfce1737
    Signed-off-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 897402c..270bb12 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3620,42 +3620,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;
+    try
+    {
+        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_THROW);
+                break;
+            }
         }
     }
+    catch( const uno::Exception& )
+    {
+    }
     return xRet;
 }
 


More information about the Libreoffice-commits mailing list