summaryrefslogtreecommitdiff
path: root/xmloff/source/core
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-01-28 18:07:45 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-01-29 15:20:59 +0100
commit81a46fc86a530f028a5bd2f5e52fe0372d50ee38 (patch)
treee42c3775afd4dc5c3ae2d4e1f63ab68a76392548 /xmloff/source/core
parenteb1ecd8bc2936e28be852722d6cb0c9fb0baeac4 (diff)
SvXMLExport::_ExportStyles: also try to export text gradients
They are not exported automatically, as SvxUnoNameItemTable needs a Which ID, and it's different for drawinglayer and Writer gradients. Change-Id: I5dd7d828b1f0e577e26510e3c5ca74386d000f16
Diffstat (limited to 'xmloff/source/core')
-rw-r--r--xmloff/source/core/xmlexp.cxx64
1 files changed, 38 insertions, 26 deletions
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 94e145412a34..0c5773b8cdbd 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -1540,43 +1540,55 @@ void SvXMLExport::_ExportFontDecls()
mxFontAutoStylePool->exportXML();
}
-void SvXMLExport::_ExportStyles( sal_Bool )
+void lcl_ExportGradientStyle(SvXMLExport& rExport, uno::Reference< lang::XMultiServiceFactory > xFact, OUString aServiceName, std::vector<OUString>& rGradientNames)
{
- uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
- if( xFact.is())
+ try
{
- // export (fill-)gradient-styles
- try
+ uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( aServiceName ), uno::UNO_QUERY );
+ if( xGradient.is() )
{
- uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( OUString("com.sun.star.drawing.GradientTable" ) ), uno::UNO_QUERY );
- if( xGradient.is() )
- {
- XMLGradientStyleExport aGradientStyle( *this );
+ XMLGradientStyleExport aGradientStyle( rExport );
- if( xGradient->hasElements() )
+ if( xGradient->hasElements() )
+ {
+ uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
+ sal_Int32 nCount = aNamesSeq.getLength();
+ for( sal_Int32 i=0; i<nCount; i++ )
{
- uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() );
- sal_Int32 nCount = aNamesSeq.getLength();
- for( sal_Int32 i=0; i<nCount; i++ )
- {
- const OUString& rStrName = aNamesSeq[ i ];
+ const OUString& rStrName = aNamesSeq[ i ];
- try
- {
- uno::Any aValue = xGradient->getByName( rStrName );
+ // Avoid duplicated style names.
+ if (std::find(rGradientNames.begin(), rGradientNames.end(), rStrName) != rGradientNames.end())
+ continue;
- aGradientStyle.exportXML( rStrName, aValue );
- }
- catch(const container::NoSuchElementException&)
- {
- }
+ try
+ {
+ uno::Any aValue = xGradient->getByName( rStrName );
+
+ aGradientStyle.exportXML( rStrName, aValue );
+ rGradientNames.push_back(rStrName);
+ }
+ catch(const container::NoSuchElementException&)
+ {
}
}
}
}
- catch(const lang::ServiceNotRegisteredException&)
- {
- }
+ }
+ catch(const lang::ServiceNotRegisteredException&)
+ {
+ }
+}
+
+void SvXMLExport::_ExportStyles( sal_Bool )
+{
+ uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY );
+ if( xFact.is())
+ {
+ // export (fill-)gradient-styles
+ std::vector<OUString> aGradientNames;
+ lcl_ExportGradientStyle(*this, xFact, "com.sun.star.drawing.GradientTable", aGradientNames);
+ lcl_ExportGradientStyle(*this, xFact, "com.sun.star.text.GradientTable", aGradientNames);
// export (fill-)hatch-styles
try