diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-11-27 14:20:33 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-11-27 17:44:31 +0100 |
commit | 08fdc4f365e84bcb7fa22a96b0399d4c2e902e28 (patch) | |
tree | 4e578922cfb4a25b06046782c9f370142fd8df05 /sw | |
parent | 0168313e95c7c00fb92e30088c8a12353e82c2c2 (diff) |
simplify options here
Change-Id: I9faa4ea8aec6ecd439751323b76bf2d8b071e4ac
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 66 |
1 files changed, 25 insertions, 41 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 9aca6e14c752..814138b084f4 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -212,49 +212,33 @@ void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL, std::exception) { SolarMutexGuard aGuard; - if(IsValid() && !rURL.isEmpty()) + if(!IsValid() || rURL.isEmpty()) + throw uno::RuntimeException(); + SwgReaderOption aOpt; + aOpt.SetFrameFormats(true); + aOpt.SetTextFormats(true); + aOpt.SetPageDescs(true); + aOpt.SetNumRules(true); + aOpt.SetMerge(false); + for(const auto& rProperty: aOptions) { - bool bLoadStyleText = true; - bool bLoadStylePage = true; - bool bLoadStyleOverwrite = true; - bool bLoadStyleNumbering = true; - bool bLoadStyleFrame = true; - - int nCount = aOptions.getLength(); - const beans::PropertyValue* pArray = aOptions.getConstArray(); - for(int i = 0; i < nCount; i++) - { - const uno::Any* pVal = &pArray[i].Value; - if( pVal->getValueType() == cppu::UnoType<bool>::get() ) - { - const OUString sName = pArray[i].Name; - bool bVal = *static_cast<sal_Bool const *>(pVal->getValue()); - if( sName == UNO_NAME_OVERWRITE_STYLES ) - bLoadStyleOverwrite = bVal; - else if( sName == UNO_NAME_LOAD_NUMBERING_STYLES ) - bLoadStyleNumbering = bVal; - else if( sName == UNO_NAME_LOAD_PAGE_STYLES ) - bLoadStylePage = bVal; - else if( sName == UNO_NAME_LOAD_FRAME_STYLES ) - bLoadStyleFrame = bVal; - else if( sName == UNO_NAME_LOAD_TEXT_STYLES ) - bLoadStyleText = bVal; - } - } - - SwgReaderOption aOpt; - aOpt.SetFrameFormats( bLoadStyleFrame ); - aOpt.SetTextFormats( bLoadStyleText ); - aOpt.SetPageDescs( bLoadStylePage ); - aOpt.SetNumRules( bLoadStyleNumbering ); - aOpt.SetMerge( !bLoadStyleOverwrite ); - - sal_uLong nErr = m_pDocShell->LoadStylesFromFile( rURL, aOpt, true ); - if( nErr ) - throw io::IOException(); + if(rProperty.Value.getValueType() != cppu::UnoType<bool>::get()) + continue; + const bool bValue = rProperty.Value.get<bool>(); + if(rProperty.Name == UNO_NAME_OVERWRITE_STYLES) + aOpt.SetMerge(!bValue); + else if(rProperty.Name == UNO_NAME_LOAD_NUMBERING_STYLES) + aOpt.SetNumRules(bValue); + else if(rProperty.Name == UNO_NAME_LOAD_PAGE_STYLES) + aOpt.SetPageDescs(bValue); + else if(rProperty.Name == UNO_NAME_LOAD_FRAME_STYLES) + aOpt.SetFrameFormats(bValue); + else if(rProperty.Name == UNO_NAME_LOAD_TEXT_STYLES) + aOpt.SetTextFormats(bValue); } - else - throw uno::RuntimeException(); + const sal_uLong nErr = m_pDocShell->LoadStylesFromFile( rURL, aOpt, true ); + if(nErr) + throw io::IOException(); } uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions() |