diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-07-19 23:34:18 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-07-19 23:34:18 +0100 |
commit | 0daa92026d95a113cf29619aa1aaebfef65b7ce6 (patch) | |
tree | f2169f1e6d3830169d68ac2155316d3a91ab31bf | |
parent | 390fc89057e5cf8a701846836740be09fd8e850e (diff) |
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
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 472a850e5808..1536bcdfc6d9 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -3638,42 +3638,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; } |