Kaydet (Commit) 81a46fc8 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst eb1ecd8b
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
class SdrModel; class SdrModel;
SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoGradientTable_createInstance( SdrModel* pModel ); SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoGradientTable_createInstance( SdrModel* pModel );
SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoTextGradientTable_createInstance( SdrModel* pModel, sal_uInt16 nWhich );
SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoHatchTable_createInstance( SdrModel* pModel ); SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoHatchTable_createInstance( SdrModel* pModel );
SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoBitmapTable_createInstance( SdrModel* pModel ); SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoBitmapTable_createInstance( SdrModel* pModel );
SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoTransGradientTable_createInstance( SdrModel* pModel ); SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxUnoTransGradientTable_createInstance( SdrModel* pModel );
......
...@@ -35,8 +35,10 @@ using namespace ::cppu; ...@@ -35,8 +35,10 @@ using namespace ::cppu;
class SvxUnoGradientTable : public SvxUnoNameItemTable class SvxUnoGradientTable : public SvxUnoNameItemTable
{ {
bool m_bTextWhich;
public: public:
SvxUnoGradientTable( SdrModel* pModel ) throw(); SvxUnoGradientTable( SdrModel* pModel ) throw();
SvxUnoGradientTable( SdrModel* pModel, sal_uInt16 nWhich ) throw();
virtual ~SvxUnoGradientTable() throw(); virtual ~SvxUnoGradientTable() throw();
virtual NameOrIndex* createItem() const throw(); virtual NameOrIndex* createItem() const throw();
...@@ -50,7 +52,12 @@ public: ...@@ -50,7 +52,12 @@ public:
}; };
SvxUnoGradientTable::SvxUnoGradientTable( SdrModel* pModel ) throw() SvxUnoGradientTable::SvxUnoGradientTable( SdrModel* pModel ) throw()
: SvxUnoNameItemTable( pModel, XATTR_FILLGRADIENT, MID_FILLGRADIENT ) : SvxUnoNameItemTable( pModel, XATTR_FILLGRADIENT, MID_FILLGRADIENT ), m_bTextWhich(false)
{
}
SvxUnoGradientTable::SvxUnoGradientTable( SdrModel* pModel, sal_uInt16 nWhich ) throw()
: SvxUnoNameItemTable( pModel, nWhich, MID_FILLGRADIENT ), m_bTextWhich(true)
{ {
} }
...@@ -60,14 +67,20 @@ SvxUnoGradientTable::~SvxUnoGradientTable() throw() ...@@ -60,14 +67,20 @@ SvxUnoGradientTable::~SvxUnoGradientTable() throw()
OUString SAL_CALL SvxUnoGradientTable::getImplementationName() throw( uno::RuntimeException ) OUString SAL_CALL SvxUnoGradientTable::getImplementationName() throw( uno::RuntimeException )
{ {
return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoGradientTable") ); if (m_bTextWhich)
return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoTextGradientTable") );
else
return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoGradientTable") );
} }
uno::Sequence< OUString > SAL_CALL SvxUnoGradientTable::getSupportedServiceNames( ) uno::Sequence< OUString > SAL_CALL SvxUnoGradientTable::getSupportedServiceNames( )
throw( uno::RuntimeException ) throw( uno::RuntimeException )
{ {
uno::Sequence< OUString > aSNS( 1 ); uno::Sequence< OUString > aSNS( 1 );
aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable" )); if (m_bTextWhich)
aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GradientTable" ));
else
aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable" ));
return aSNS; return aSNS;
} }
...@@ -93,6 +106,11 @@ uno::Reference< uno::XInterface > SAL_CALL SvxUnoGradientTable_createInstance( S ...@@ -93,6 +106,11 @@ uno::Reference< uno::XInterface > SAL_CALL SvxUnoGradientTable_createInstance( S
return *new SvxUnoGradientTable(pModel); return *new SvxUnoGradientTable(pModel);
} }
uno::Reference< uno::XInterface > SAL_CALL SvxUnoTextGradientTable_createInstance( SdrModel* pModel, sal_uInt16 nWhich )
{
return *new SvxUnoGradientTable(pModel, nWhich);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -547,6 +547,7 @@ class SwXDocumentPropertyHelper : public SvxUnoForbiddenCharsTable ...@@ -547,6 +547,7 @@ class SwXDocumentPropertyHelper : public SvxUnoForbiddenCharsTable
{ {
css::uno::Reference < css::uno::XInterface > xDashTable; css::uno::Reference < css::uno::XInterface > xDashTable;
css::uno::Reference < css::uno::XInterface > xGradientTable; css::uno::Reference < css::uno::XInterface > xGradientTable;
css::uno::Reference < css::uno::XInterface > xTextGradientTable;
css::uno::Reference < css::uno::XInterface > xHatchTable; css::uno::Reference < css::uno::XInterface > xHatchTable;
css::uno::Reference < css::uno::XInterface > xBitmapTable; css::uno::Reference < css::uno::XInterface > xBitmapTable;
css::uno::Reference < css::uno::XInterface > xTransGradientTable; css::uno::Reference < css::uno::XInterface > xTransGradientTable;
......
...@@ -153,6 +153,7 @@ using ::osl::FileBase; ...@@ -153,6 +153,7 @@ using ::osl::FileBase;
#define SW_CREATE_TRANSGRADIENT_TABLE 0x05 #define SW_CREATE_TRANSGRADIENT_TABLE 0x05
#define SW_CREATE_MARKER_TABLE 0x06 #define SW_CREATE_MARKER_TABLE 0x06
#define SW_CREATE_DRAW_DEFAULTS 0x07 #define SW_CREATE_DRAW_DEFAULTS 0x07
#define SW_CREATE_TEXT_GRADIENT_TABLE 0x08
extern bool sw_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst ); extern bool sw_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst );
...@@ -1679,6 +1680,8 @@ Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServic ...@@ -1679,6 +1680,8 @@ Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServic
{ {
if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.DocumentSettings") ) ) if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.DocumentSettings") ) )
xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) ); xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.GradientTable") ) )
xRet = GetPropertyHelper()->GetDrawTable(SW_CREATE_TEXT_GRADIENT_TABLE);
} }
else if (sCategory == "chart2" ) else if (sCategory == "chart2" )
{ {
...@@ -3880,6 +3883,11 @@ Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(short nWhich) ...@@ -3880,6 +3883,11 @@ Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(short nWhich)
xDrawDefaults = (cppu::OWeakObject*)new SwSvxUnoDrawPool(m_pDoc); xDrawDefaults = (cppu::OWeakObject*)new SwSvxUnoDrawPool(m_pDoc);
xRet = xDrawDefaults; xRet = xDrawDefaults;
break; break;
case SW_CREATE_TEXT_GRADIENT_TABLE :
if(!xTextGradientTable.is())
xTextGradientTable = SvxUnoTextGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel(), RES_FILL_GRADIENT );
xRet = xTextGradientTable;
break;
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
default: OSL_FAIL("which table?"); default: OSL_FAIL("which table?");
#endif #endif
......
...@@ -1540,43 +1540,55 @@ void SvXMLExport::_ExportFontDecls() ...@@ -1540,43 +1540,55 @@ void SvXMLExport::_ExportFontDecls()
mxFontAutoStylePool->exportXML(); 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 ); try
if( xFact.is())
{ {
// export (fill-)gradient-styles uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( aServiceName ), uno::UNO_QUERY );
try if( xGradient.is() )
{ {
uno::Reference< container::XNameAccess > xGradient( xFact->createInstance( OUString("com.sun.star.drawing.GradientTable" ) ), uno::UNO_QUERY ); XMLGradientStyleExport aGradientStyle( rExport );
if( xGradient.is() )
{
XMLGradientStyleExport aGradientStyle( *this );
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() ); const OUString& rStrName = aNamesSeq[ i ];
sal_Int32 nCount = aNamesSeq.getLength();
for( sal_Int32 i=0; i<nCount; i++ )
{
const OUString& rStrName = aNamesSeq[ i ];
try // Avoid duplicated style names.
{ if (std::find(rGradientNames.begin(), rGradientNames.end(), rStrName) != rGradientNames.end())
uno::Any aValue = xGradient->getByName( rStrName ); continue;
aGradientStyle.exportXML( rStrName, aValue ); try
} {
catch(const container::NoSuchElementException&) 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 // export (fill-)hatch-styles
try try
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment