summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMarco Cecchetti <mrcekets@gmail.com>2011-07-20 22:33:13 +0200
committerThorsten Behrens <tbehrens@novell.com>2011-08-26 18:25:20 +0200
commit2ba4caca79923ffe6db3a07a59ba84886b43f84a (patch)
treecefa31e05c7ac79a5c5cd39261f172d635b4ccd7 /filter
parentac756a96b8fd6bd9177bfd1b4b01eff9e8ab2820 (diff)
Now a unique id for each page and each shape is generated through the UnoInterfaceToUniqueIdentifierMapper class.
This class is the same used for generating a unique identifier for pages and shapes when a presentation is saved in odp format. No change to the presentation engine script has been needed.
Diffstat (limited to 'filter')
-rw-r--r--filter/source/svg/svgexport.cxx127
-rw-r--r--filter/source/svg/svgfilter.hxx12
2 files changed, 79 insertions, 60 deletions
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index b23e40a91a7b..09d09343b6f2 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -51,6 +51,8 @@
#include <comphelper/processfactory.hxx>
#include <i18npool/lang.h>
#include <svl/zforlist.hxx>
+#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
+
#include <boost/preprocessor/repetition/repeat.hpp>
@@ -87,6 +89,9 @@ static const char aOOOAttrDateTimeField[] = NSPREFIX "date-time-field";
static const char aOOOAttrFooterField[] = NSPREFIX "footer-field";
static const char aOOOAttrHeaderField[] = NSPREFIX "header-field";
+// ooo xml attributes for pages and shapes
+static const char aOOOAttrName[] = NSPREFIX "name";
+
// ooo xml attributes for date_time_field
static const char aOOOAttrDateTimeFormat[] = NSPREFIX "date-time-format";
@@ -507,7 +512,6 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
const PropertyValue* pValue = rDescriptor.getConstArray();
sal_Bool bRet = sal_False;
- mnMasterSlideId = mnSlideId = mnDrawingGroupId = mnDrawingId = 0;
maFilterData.realloc( 0 );
for ( sal_Int32 i = 0 ; i < nLength; ++i)
@@ -593,46 +597,57 @@ sal_Bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
// #110680#
// mpSVGExport = new SVGExport( xDocHandler );
- mpSVGExport = new SVGExport( xServiceFactory, xDocHandler, maFilterData );
+ mpSVGExport = new SVGExport( xServiceFactory, xDocHandler, maFilterData );
- try
+ if( mpSVGExport != NULL )
{
- mxDefaultPage = mSelectedPages[0];
+ // create an id for each draw page
+ for( sal_Int32 i = 0; i < mSelectedPages.getLength(); ++i )
+ implRegisterInterface( mSelectedPages[i] );
+
+ // create an id for each master page
+ for( sal_Int32 i = 0; i < mMasterPageTargets.getLength(); ++i )
+ implRegisterInterface( mMasterPageTargets[i] );
- if( mxDefaultPage.is() )
+ try
{
- SvxDrawPage* pSvxDrawPage = SvxDrawPage::getImplementation( mxDefaultPage );
+ mxDefaultPage = mSelectedPages[0];
- if( pSvxDrawPage )
+ if( mxDefaultPage.is() )
{
- mpDefaultSdrPage = pSvxDrawPage->GetSdrPage();
- mpSdrModel = mpDefaultSdrPage->GetModel();
+ SvxDrawPage* pSvxDrawPage = SvxDrawPage::getImplementation( mxDefaultPage );
- if( mpSdrModel )
+ if( pSvxDrawPage )
{
- SdrOutliner& rOutl = mpSdrModel->GetDrawOutliner(NULL);
+ mpDefaultSdrPage = pSvxDrawPage->GetSdrPage();
+ mpSdrModel = mpDefaultSdrPage->GetModel();
+
+ if( mpSdrModel )
+ {
+ SdrOutliner& rOutl = mpSdrModel->GetDrawOutliner(NULL);
- maOldFieldHdl = rOutl.GetCalcFieldValueHdl();
- rOutl.SetCalcFieldValueHdl( LINK( this, SVGFilter, CalcFieldHdl) );
+ maOldFieldHdl = rOutl.GetCalcFieldValueHdl();
+ rOutl.SetCalcFieldValueHdl( LINK( this, SVGFilter, CalcFieldHdl) );
+ }
}
+ bRet = implExportDocument();
}
- bRet = implExportDocument();
}
- }
- catch( ... )
- {
- delete mpSVGDoc, mpSVGDoc = NULL;
- OSL_FAIL( "Exception caught" );
- }
+ catch( ... )
+ {
+ delete mpSVGDoc, mpSVGDoc = NULL;
+ OSL_FAIL( "Exception caught" );
+ }
- if( mpSdrModel )
- mpSdrModel->GetDrawOutliner( NULL ).SetCalcFieldValueHdl( maOldFieldHdl );
+ if( mpSdrModel )
+ mpSdrModel->GetDrawOutliner( NULL ).SetCalcFieldValueHdl( maOldFieldHdl );
- delete mpSVGWriter, mpSVGWriter = NULL;
- delete mpSVGExport, mpSVGExport = NULL;
- delete mpSVGFontExport, mpSVGFontExport = NULL;
- delete mpObjects, mpObjects = NULL;
- mbPresentation = sal_False;
+ delete mpSVGWriter, mpSVGWriter = NULL;
+ delete mpSVGExport, mpSVGExport = NULL;
+ delete mpSVGFontExport, mpSVGFontExport = NULL;
+ delete mpObjects, mpObjects = NULL;
+ mbPresentation = sal_False;
+ }
}
}
}
@@ -1222,9 +1237,13 @@ sal_Bool SVGFilter::implExportPages( const SVGFilter::XDrawPageSequence & rxPage
if( xShapes.is() )
{
// add id attribute
- OUString sPageId = implGetValidIDFromInterface( xShapes );
+ const OUString & sPageId = implGetValidIDFromInterface( rxPages[i] );
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sPageId );
+ OUString sPageName = implGetInterfaceName( rxPages[i] );
+ if( sPageName.getLength() )
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrName, sPageName );
+
{
{
Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
@@ -1457,8 +1476,6 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape )
}
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", aShapeClass );
SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
- OUString aId( B2UCONST( "DrawingGroup_" ) );
- OUString aObjName( implGetValidIDFromInterface( rxShape, true ) ), aObjDesc;
Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
@@ -1478,8 +1495,14 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape )
xExtDocHandler->characters( aDescription );
}
- if( aObjName.getLength() )
- ( ( aId += B2UCONST( "(" ) ) += aObjName ) += B2UCONST( ")" );
+
+ Reference< XInterface > xRef( rxShape, UNO_QUERY );
+ const OUString& rShapeId = implGetValidIDFromInterface( xRef );
+ if( rShapeId.getLength() )
+ {
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", rShapeId );
+ //mpSVGExport->AddAttributeIdLegacy( XML_NAMESPACE_DRAW, rShapeId );
+ }
{
SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
@@ -1682,32 +1705,32 @@ OUString SVGFilter::implGetClassFromShape( const Reference< XShape >& rxShape )
// -----------------------------------------------------------------------------
-OUString SVGFilter::implGetValidIDFromInterface( const Reference< XInterface >& rxIf, sal_Bool bUnique )
+//inline
+void SVGFilter::implRegisterInterface( const Reference< XInterface >& rxIf )
+{
+ if( rxIf.is() )
+ (mpSVGExport->getInterfaceToIdentifierMapper()).registerReference( rxIf );
+}
+
+// -----------------------------------------------------------------------------
+
+//inline
+const ::rtl::OUString & SVGFilter::implGetValidIDFromInterface( const Reference< XInterface >& rxIf )
+{
+ return (mpSVGExport->getInterfaceToIdentifierMapper()).getIdentifier( rxIf );
+}
+
+
+// -----------------------------------------------------------------------------
+
+OUString SVGFilter::implGetInterfaceName( const Reference< XInterface >& rxIf )
{
Reference< XNamed > xNamed( rxIf, UNO_QUERY );
OUString aRet;
-
if( xNamed.is() )
{
- aRet = xNamed->getName().replace( ' ', '_' ).
- replace( ':', '_' ).
- replace( ',', '_' ).
- replace( ';', '_' ).
- replace( '&', '_' ).
- replace( '!', '_' ).
- replace( '|', '_' );
- }
-
- if( ( aRet.getLength() > 0 ) && bUnique )
- {
- while( ::std::find( maUniqueIdVector.begin(), maUniqueIdVector.end(), aRet ) != maUniqueIdVector.end() )
- {
- aRet += B2UCONST( "_" );
- }
-
- maUniqueIdVector.push_back( aRet );
+ aRet = xNamed->getName().replace( ' ', '_' );
}
-
return aRet;
}
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 37037ac9766a..924cdfbd0196 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -261,7 +261,6 @@ class SVGFilter : public cppu::WeakImplHelper4 < XFilter,
{
public:
typedef ::boost::unordered_map< Reference< XInterface >, ObjectRepresentation, HashReferenceXInterface > ObjectMap;
- typedef ::std::vector< ::rtl::OUString > UniqueIdVector;
typedef ::boost::unordered_set< Reference< XInterface >, HashReferenceXInterface > ObjectSet;
typedef Sequence< Reference< XInterface > > ObjectSequence;
typedef Sequence< Reference< XDrawPage > > XDrawPageSequence;
@@ -298,11 +297,6 @@ private:
XDrawPageSequence mSelectedPages;
XDrawPageSequence mMasterPageTargets;
- UniqueIdVector maUniqueIdVector;
- sal_Int32 mnMasterSlideId;
- sal_Int32 mnSlideId;
- sal_Int32 mnDrawingGroupId;
- sal_Int32 mnDrawingId;
Link maOldFieldHdl;
sal_Bool implImport( const Sequence< PropertyValue >& rDescriptor ) throw (RuntimeException);
@@ -329,7 +323,9 @@ private:
sal_Bool implCreateObjectsFromBackground( const Reference< XDrawPage >& rxMasterPage );
::rtl::OUString implGetClassFromShape( const Reference< XShape >& rxShape );
- ::rtl::OUString implGetValidIDFromInterface( const Reference< XInterface >& rxIf, sal_Bool bUnique = sal_False );
+ void implRegisterInterface( const Reference< XInterface >& rxIf );
+ const ::rtl::OUString & implGetValidIDFromInterface( const Reference< XInterface >& rxIf );
+ ::rtl::OUString implGetInterfaceName( const Reference< XInterface >& rxIf );
sal_Bool implLookForFirstVisiblePage();
Any implSafeGetPagePropSet( const ::rtl::OUString & sPropertyName,
const Reference< XPropertySet > & rxPropSet,
@@ -357,9 +353,9 @@ public:
virtual ~SVGFilter();
};
+// -----------------------------------------------------------------------------
-// -----------------------------------------------------------------------------
class SvStream;
class Graphic;