summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMarco Cecchetti <mrcekets@gmail.com>2012-05-29 21:01:00 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2012-06-15 10:14:59 +0200
commita4f7622bcc32b14811f3969dcd073f79560b3967 (patch)
treed5839a9a7a8334f7a0186107451c41ec4f2c5a46 /filter
parent232490f3fba15bc9b6cb94723645fbc21b3c0f26 (diff)
The new slide elements structure is created by the svg export filter
directly. Master page elements structure reverted to old one, adapted the embedded script. Exporting a single slide is supported again.
Diffstat (limited to 'filter')
-rw-r--r--filter/source/svg/presentation_engine.js175
-rw-r--r--filter/source/svg/svgexport.cxx344
-rw-r--r--filter/source/svg/svgfilter.hxx14
3 files changed, 211 insertions, 322 deletions
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 6aeabe123d82..53ab74782963 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -630,6 +630,7 @@ var aOOOElemTextField = 'ooo:text_field';
// ooo attributes
var aOOOAttrNumberOfSlides = 'number-of-slides';
+var aOOOAttrStartSlideNumber= 'start-slide-number';
var aOOOAttrNumberingType = 'page-numbering-type';
var aOOOAttrSlide = 'slide';
@@ -929,98 +930,6 @@ function isTextFieldElement( aElement )
( sClassName === aDateTimeClassName );
}
-
-
-function tempWrapMasterPages()
-{
- var aSlideGroupElement = document.createElementNS( NSS['svg'], 'g' );
- aSlideGroupElement.setAttribute( 'class', 'SlideGroup' );
- //aSlideGroupElement.onmousedown = function( aEvt ) { return mouseHandlerDispatch( aEvt, MOUSE_DOWN ); };
- //aSlideGroupElement.setAttribute( 'visibility', 'hidden' );
-
-
- var aDrawPageSet = getElementsByClassName(ROOT_NODE, 'Slide');
- ROOT_NODE.insertBefore( aSlideGroupElement, aDrawPageSet[0] );
-
- var aMasterPageSet = getElementsByClassName(ROOT_NODE, 'Master_Slide');
- if( aMasterPageSet )
- {
- var aDefsElement = document.createElementNS( NSS['svg'], 'defs' );
-
- ROOT_NODE.insertBefore( aDefsElement, aMasterPageSet[0] );
- var i;
- for( i = 0; i < aMasterPageSet.length; ++i)
- {
- var aMasterPage = ROOT_NODE.removeChild( aMasterPageSet[i] );
- aDefsElement.appendChild( aMasterPage );
- }
- }
-}
-
-function tempCreateSlideView( aPageElement )
-{
- if( !aPageElement )
- return;
-
- var aSlideGroupElement = getElementByClassName( ROOT_NODE, 'SlideGroup' );
-
- var sId = aPageElement.getAttribute( 'id' );
- var sName = aPageElement.getAttributeNS( NSS['ooo'], 'name' );
- var sClipPath = aPageElement.getAttribute( 'clip-path' );
-
- aPageElement.removeAttribute( 'id' );
- aPageElement.removeAttributeNS( NSS['ooo'], 'name' );
- aPageElement.removeAttribute( 'visibility' );
- aPageElement.removeAttribute( 'clip-path' );
- aPageElement.setAttribute( 'class', aPageClassName );
-
- var aVisibilityStatusElement = document.createElementNS( NSS['svg'], 'g' );
- aVisibilityStatusElement.setAttribute( 'visibility', 'hidden' );
-
- var aSlideElement = document.createElementNS( NSS['svg'], 'g' );
- aSlideElement.setAttribute( 'id', sId );
- aSlideElement.setAttributeNS( NSS['ooo'], 'name', sName );
- aSlideElement.setAttribute( 'clip-path', sClipPath );
- aSlideElement.setAttribute( 'class', 'Slide' );
- aVisibilityStatusElement.appendChild( aSlideElement );
-
- aPageElement.parentNode.removeChild( aPageElement );
- aSlideElement.appendChild( aPageElement );
- aSlideGroupElement.appendChild( aVisibilityStatusElement );
-}
-
-function tempModMasterPage( aMasterPageElement, sId )
-{
- if( !aMasterPageElement )
- return;
-
-
- var aBackgroundObjectsElement =
- getElementByClassName( aMasterPageElement, 'BackgroundObjects' );
-
- var aBackgroundShapesElement = document.createElementNS( NSS['svg'], 'g' );
- aBackgroundShapesElement.setAttribute( 'id', 'bs-' + sId );
- aBackgroundShapesElement.setAttribute( 'class', 'BackgroundShapes' );
-
-
- if( aBackgroundObjectsElement.hasChildNodes() )
- {
- var aChildNode = aBackgroundObjectsElement.firstElementChild;
- while( aChildNode )
- {
- var aNextChildNode= aChildNode.nextElementSibling;
- if( !isTextFieldElement( aChildNode ) )
- {
- aBackgroundObjectsElement.removeChild( aChildNode );
- aBackgroundShapesElement.appendChild( aChildNode );
- }
- aChildNode = aNextChildNode;
- }
- }
- aBackgroundObjectsElement.appendChild( aBackgroundShapesElement );
-}
-
-
// ------------------------------------------------------------------------------------------ //
/*********************
** Debug Utilities **
@@ -1102,9 +1011,6 @@ aAnimatedElementDebugPrinter.off();
*/
function MetaDocument()
{
- // TODO to be implemented in C++
- tempWrapMasterPages();
-
// We look for the svg element that provides the following presentation
// properties:
// - the number of slides in the presentation;
@@ -1120,7 +1026,7 @@ function MetaDocument()
assert( typeof this.nNumberOfSlides == 'number' && this.nNumberOfSlides > 0,
'MetaDocument: number of slides is zero or undefined.' );
// - the index of the slide to show when the presentation starts;
- this.nStartSlideNumber = 0;
+ this.nStartSlideNumber = parseInt( aMetaDocElem.getAttributeNS( NSS['ooo'], aOOOAttrStartSlideNumber ) ) || 0;
// - the numbering type used in the presentation, default type is arabic.
this.sPageNumberingType = aMetaDocElem.getAttributeNS( NSS['ooo'], aOOOAttrNumberingType ) || 'arabic';
@@ -1241,13 +1147,6 @@ function MetaSlide( sMetaSlideId, aMetaDoc )
'MetaSlide: slide element <' + this.slideId + '> not found.' );
this.nSlideNumber = parseInt( this.slideId.substr(2) );
- // ------------------------------
- // TODO: to be implemented in C++
- tempCreateSlideView(this.slideElement);
- this.slideElement = this.theDocument.getElementById( this.slideId );
- assert( this.slideElement, 'MetaSlide: slide element <' + this.slideId + '> not found.' );
- // ------------------------------
-
// Each slide element is wrapped by a <g> element that is responsible for
// the slide element visibility. In fact the visibility attribute has
// to be set on the parent of the slide element and not directly on
@@ -1434,12 +1333,11 @@ getSlideAnimationsRoot : function()
}; // end MetaSlide prototype
-/** Class MasterPage **
+/** Class MasterPage
* This class gives direct access to a master page element and to the following
* elements included in the master page:
* - the background element,
* - the background objects group element,
- * - the background shapes group element.
* Moreover for each text field element a Placeholder object is created which
* manages the text field element itself.
*
@@ -1449,23 +1347,19 @@ getSlideAnimationsRoot : function()
* background image
* </g>
* <g class='BackgroundObjects'>
- * <g class='BackgroundFields'>
- * <g class='Date/Time'>
- * date/time placeholder
- * </g>
- * <g class='Header'>
- * header placeholder
- * </g>
- * <g class='Footer'>
- * footer placeholder
- * </g>
- * <g class='Slide_Number'>
- * slide number placeholder
- * </g>
+ * <g class='Date/Time'>
+ * date/time placeholder
* </g>
- * <g class='BackgroundShapes'>
- * shapes
+ * <g class='Header'>
+ * header placeholder
* </g>
+ * <g class='Footer'>
+ * footer placeholder
+ * </g>
+ * <g class='Slide_Number'>
+ * slide number placeholder
+ * </g>
+ * shapes
* </g>
* </g>
*
@@ -1482,19 +1376,12 @@ function MasterPage( sMasterPageId )
assert( this.element,
'MasterPage: master page element <' + this.id + '> not found.' );
- // ------------------------------
- // TODO: to be implemented in C++
- tempModMasterPage( this.element, this.id );
- this.element = document.getElementById( this.id );
- assert( this.element, 'MasterPage: master page element <' + this.id + '> not found.' );
- // ------------------------------
-
// The master page background element and its id attribute.
this.background = getElementByClassName( this.element, 'Background' );
if( this.background )
{
this.backgroundId = this.background.getAttribute( 'id' );
-// this.backgroundVisibility = initVisibilityProperty( this.background );
+ this.backgroundVisibility = initVisibilityProperty( this.background );
}
else
{
@@ -1508,7 +1395,7 @@ function MasterPage( sMasterPageId )
if( this.backgroundObjects )
{
this.backgroundObjectsId = this.backgroundObjects.getAttribute( 'id' );
-// this.backgroundObjectsVisibility = initVisibilityProperty( this.backgroundObjects );
+ this.backgroundObjectsVisibility = initVisibilityProperty( this.backgroundObjects );
}
else
{
@@ -1516,24 +1403,9 @@ function MasterPage( sMasterPageId )
log( 'MasterPage: the background objects element is not valid.' );
}
- // The background shapes group element that contains all the shape of
- // the master page that are not text fields.
- this.backgroundShapes = getElementByClassName( this.backgroundObjects, 'BackgroundShapes' );
- if( this.backgroundShapes )
- {
- this.backgroundShapesId = this.backgroundShapes.getAttribute( 'id' );
- }
- else
- {
- this.backgroundShapesId = '';
- log( 'MasterPage: the background shapes element is not valid.' );
- }
-
// We populate the collection of placeholders.
this.aPlaceholderShapeSet = new Object();
this.initPlaceholderShapes();
-
- this.removeVisibilityAttributes();
}
MasterPage.prototype =
@@ -1546,13 +1418,6 @@ initPlaceholderShapes : function()
this.aPlaceholderShapeSet[ aDateTimeClassName ] = new PlaceholderShape( this, aDateTimeClassName );
this.aPlaceholderShapeSet[ aFooterClassName ] = new PlaceholderShape( this, aFooterClassName );
this.aPlaceholderShapeSet[ aHeaderClassName ] = new PlaceholderShape( this, aHeaderClassName );
-},
-
-removeVisibilityAttributes : function()
-{
- this.element.removeAttribute( 'visibility' );
- this.background.removeAttribute( 'visibility' );
- this.backgroundObjects.removeAttribute( 'visibility' );
}
}; // end MasterPage prototype
@@ -1601,8 +1466,6 @@ PlaceholderShape.prototype.init = function()
var aTextFieldElement = getElementByClassName( this.masterPage.backgroundObjects, this.className );
if( aTextFieldElement )
{
- aTextFieldElement.removeAttribute( 'visibility' ); // TODO to be handled in C++ ?
-
var aPlaceholderElement = getElementByClassName( aTextFieldElement, 'PlaceholderText' );
if( aPlaceholderElement )
{
@@ -1809,7 +1672,7 @@ MasterPageView.prototype.createElement = function()
this.aBackgroundShapesElement = theDocument.createElementNS( NSS['svg'], 'use' );
this.aBackgroundShapesElement.setAttribute( 'class', 'BackgroundShapes' );
setNSAttribute( 'xlink', this.aBackgroundShapesElement,
- 'href', '#' + this.aMasterPage.backgroundShapesId );
+ 'href', '#' + this.aMasterPage.backgroundObjectsId );
// node linking
this.aBackgroundObjectsElement.appendChild( this.aBackgroundFieldsElement );
@@ -1900,6 +1763,8 @@ TextFieldHandler.prototype.cloneElement = function()
assert( this.aTextFieldElement,
'TextFieldHandler.cloneElement: aTextFieldElement is not defined' );
this.aTextFieldElement.setAttribute( 'id', this.sId );
+ // Text field placeholder visibility is always set to 'hidden'.
+ this.aTextFieldElement.removeAttribute( 'visibility' );
// The actual <text> element where the field content has to be placed.
this.aTextPlaceholderElement = getElementByClassName( this.aTextFieldElement, 'PlaceholderText' );
assert( this.aTextPlaceholderElement,
@@ -1940,7 +1805,7 @@ TextFieldHandler.prototype.setTextContent = function( sText )
{
if( !this.aTextPlaceholderElement )
{
- log( 'TextFieldHandler.setTextContent: text element is not valid in placeholder of type '
+ log( 'PlaceholderShape.setTextContent: text element is not valid in placeholder of type '
+ this.className + ' that belongs to master slide ' + this.masterPage.id );
return;
}
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 0e80740addbb..12a3ed37228d 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -74,6 +74,7 @@ static const char aOOOElemTextField[] = NSPREFIX "text_field";
// ooo xml attributes for meta_slides
static const char aOOOAttrNumberOfSlides[] = NSPREFIX "number-of-slides";
+static const char aOOOAttrStartSlideNumber[] = NSPREFIX "start-slide-number";
static const char aOOOAttrNumberingType[] = NSPREFIX "page-numbering-type";
// ooo xml attributes for meta_slide
@@ -648,22 +649,6 @@ sal_Bool SVGFilter::implLookForFirstVisiblePage()
( ( xPropSet->getPropertyValue( B2UCONST( "Visible" ) ) >>= bVisible ) && bVisible ) )
{
mnVisiblePage = nCurPage;
-
- Reference< XMasterPageTarget > xMasterTarget( xDrawPage, UNO_QUERY );
- if( xMasterTarget.is() )
- {
- Reference< XDrawPage > xMasterPage( xMasterTarget->getMasterPage() );
-
- for( sal_Int32 nMaster = 0, nMasterCount = mMasterPageTargets.getLength();
- ( nMaster < nMasterCount ) && ( -1 == mnVisibleMasterPage );
- ++nMaster )
- {
- const Reference< XDrawPage > & xMasterTestPage = mMasterPageTargets[nMaster];
-
- if( xMasterTestPage.is() && xMasterTestPage == xMasterPage )
- mnVisibleMasterPage = nMaster;
- }
- }
}
}
}
@@ -686,7 +671,7 @@ sal_Bool SVGFilter::implExportDocument()
mbSinglePage = (nLastPage == 0) || !bExperimentalMode;
mnVisiblePage = -1;
- mnVisibleMasterPage = -1;
+// mnVisibleMasterPage = -1;
const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY );
const Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
@@ -812,8 +797,8 @@ sal_Bool SVGFilter::implExportDocument()
mpSVGFontExport->EmbedFonts();
}
- implExportPages( mMasterPageTargets, 0, mMasterPageTargets.getLength() - 1, mnVisibleMasterPage, sal_True /* is a master page */ );
- implExportPages( mSelectedPages, 0, nLastPage, mnVisiblePage, sal_False /* is not a master page */ );
+ implExportMasterPages( mMasterPageTargets, 0, mMasterPageTargets.getLength() - 1 );
+ implExportDrawPages( mSelectedPages, 0, nLastPage );
if( !mbSinglePage )
{
@@ -875,6 +860,7 @@ sal_Bool SVGFilter::implGenerateMetaData()
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", B2UCONST( aOOOElemMetaSlides ) );
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrNumberOfSlides, OUString::valueOf( nCount ) );
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrStartSlideNumber, OUString::valueOf( mnVisiblePage ) );
/*
* Add a (global) Page Numbering Type attribute for the document
@@ -889,6 +875,9 @@ sal_Bool SVGFilter::implGenerateMetaData()
SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage();
SdrModel* pSdrModel = pSdrPage->GetModel();
nPageNumberingType = pSdrModel->GetPageNumType();
+
+ // That is used by CalcFieldHdl method.
+ mVisiblePagePropSet.nPageNumberingType = nPageNumberingType;
}
if( nPageNumberingType != SVX_NUMBER_NONE )
{
@@ -1024,20 +1013,6 @@ sal_Bool SVGFilter::implGenerateMetaData()
{
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMasterObjectsVisibility, B2UCONST( "hidden" ) );
}
- if( i == mnVisiblePage )
- {
- mVisiblePagePropSet.bIsBackgroundVisible = bBackgroundVisibility;
- mVisiblePagePropSet.bAreBackgroundObjectsVisible = bBackgroundObjectsVisibility;
- mVisiblePagePropSet.bIsPageNumberFieldVisible = bPageNumberVisibility;
- mVisiblePagePropSet.bIsDateTimeFieldVisible = bDateTimeVisibility;
- mVisiblePagePropSet.bIsFooterFieldVisible = bFooterVisibility;
- mVisiblePagePropSet.bIsHeaderFieldVisible = bHeaderVisibility;
- mVisiblePagePropSet.nPageNumberingType = nPageNumberingType;
- mVisiblePagePropSet.bIsDateTimeFieldFixed = bDateTimeFixed;
- mVisiblePagePropSet.nDateTimeFormat = aVariableDateTimeField.format;
- mVisiblePagePropSet.sDateTimeText = aFixedDateTimeField.text;
- mVisiblePagePropSet.sFooterText = aFooterField.text;
- }
}
}
@@ -1244,17 +1219,21 @@ sal_Bool SVGFilter::implGetPagePropSet( const Reference< XDrawPage > & rxPage )
return bRet;
}
+
// -----------------------------------------------------------------------------
-sal_Bool SVGFilter::implExportPages( const SVGFilter::XDrawPageSequence & rxPages,
- sal_Int32 nFirstPage, sal_Int32 nLastPage,
- sal_Int32 nVisiblePage, sal_Bool bMaster )
+sal_Bool SVGFilter::implExportMasterPages( const SVGFilter::XDrawPageSequence & rxPages,
+ sal_Int32 nFirstPage, sal_Int32 nLastPage )
{
DBG_ASSERT( nFirstPage <= nLastPage,
"SVGFilter::implExportPages: nFirstPage > nLastPage" );
- sal_Bool bRet = sal_False;
+ // When the exported slides are more than one we wrap master page elements
+ // with a svg <defs> element.
+ OUString aContainerTag = (mbSinglePage) ? B2UCONST( "g" ) : B2UCONST( "defs" );
+ SvXMLElementExport aContainerElement( *mpSVGExport, XML_NAMESPACE_NONE, aContainerTag, sal_True, sal_True );
+ sal_Bool bRet = sal_False;
for( sal_Int32 i = nFirstPage; i <= nLastPage; ++i )
{
if( rxPages[i].is() )
@@ -1267,127 +1246,168 @@ sal_Bool SVGFilter::implExportPages( const SVGFilter::XDrawPageSequence & rxPage
const OUString & sPageId = implGetValidIDFromInterface( rxPages[i] );
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sPageId );
- OUString sPageName = implGetInterfaceName( rxPages[i] );
- if( !(sPageName.isEmpty() || mbSinglePage ))
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrName, sPageName );
+ bRet = implExportPage( sPageId, rxPages[i], xShapes, sal_True /* is a master page */ ) || bRet;
+ }
+ }
+ }
+ return bRet;
+}
- {
- {
- Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
+// -----------------------------------------------------------------------------
- if( xExtDocHandler.is() )
- {
- OUString aDesc;
+sal_Bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rxPages,
+ sal_Int32 nFirstPage, sal_Int32 nLastPage )
+{
+ DBG_ASSERT( nFirstPage <= nLastPage,
+ "SVGFilter::implExportPages: nFirstPage > nLastPage" );
- if( bMaster )
- aDesc = B2UCONST( "Master_Slide" );
- else
- aDesc = B2UCONST( "Slide" );
+ // We wrap all slide in a group element with class name "SlideGroup".
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "SlideGroup" ) );
+ SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", aDesc );
- }
- }
+ sal_Bool bRet = sal_False;
+ for( sal_Int32 i = nFirstPage; i <= nLastPage; ++i )
+ {
+ Reference< XShapes > xShapes( rxPages[i], UNO_QUERY );
- // We don't set a visibility attribute for a master page element
- // as the visibility of each master page sub element (background,
- // placeholder shapes, background objects) is managed separately.
- OUString aAttrVisibilityValue;
- if( !bMaster )
- {
- if( i == nVisiblePage )
- aAttrVisibilityValue = B2UCONST( "visible" );
- else
- aAttrVisibilityValue = B2UCONST( "hidden" );
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", aAttrVisibilityValue );
- }
- else
- { // when we export the shapes of a master page (implExportShape) we need
- // to know if it is the master page targeted by the initially visible slide
- mbIsPageVisible = ( i == nVisiblePage );
- }
+ if( xShapes.is() )
+ {
+ // Insert the <g> open tag related to the svg element for
+ // handling a slide visibility.
+ // In case the exported slides are more than one the initial
+ // visibility of each slide is set to 'hidden'.
+ if( !mbSinglePage )
+ {
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", B2UCONST( "hidden" ) );
+ }
+ SvXMLElementExport aGElement( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
- // Adding a clip path to each exported slide and master page,
- // so in case bitmaps or other elements exceed the slide margins
- // they are trimmed, even when they are shown inside a thumbnail view.
- OUString sClipPathAttrValue = B2UCONST( "url(#" ) + msClipPathId + B2UCONST( ")" );
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "clip-path", sClipPathAttrValue );
+ {
+ // add id attribute
+ const OUString & sPageId = implGetValidIDFromInterface( rxPages[i] );
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sPageId );
- // insert the <g> open tag related to the Slide/Master_Slide
- SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "Slide" ) );
- // In case the page has a background object we append it .
- if( (mpObjects->find( rxPages[i] ) != mpObjects->end()) )
- {
- const GDIMetaFile& rMtf = (*mpObjects)[ rxPages[i] ].GetRepresentation();
- if( rMtf.GetActionSize() )
- {
- // background id = "bg-" + page id
- OUString sBackgroundId = B2UCONST( "bg-" );
- sBackgroundId += sPageId;
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sBackgroundId );
-
- // At present (LibreOffice 3.4.0) the 'IsBackgroundVisible' property is not handled
- // by Impress; anyway we handle this property as referring only to the visibility
- // of the master page background. So if a slide has its own background object,
- // the visibility of such a background object is always inherited from the visibility
- // of the parent slide regardless of the value of the 'IsBackgroundVisible' property.
- // This means that we need to set up the visibility attribute only for the background
- // element of a master page.
- if( bMaster )
- {
- if( i == nVisiblePage && mVisiblePagePropSet.bIsBackgroundVisible )
- aAttrVisibilityValue = B2UCONST( "visible" );
- else
- aAttrVisibilityValue = B2UCONST( "hidden" );
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", aAttrVisibilityValue );
- }
+ // Adding a clip path to each exported slide , so in case
+ // bitmaps or other elements exceed the slide margins, they are
+ // trimmed, even when they are shown inside a thumbnail view.
+ OUString sClipPathAttrValue = B2UCONST( "url(#" ) + msClipPathId + B2UCONST( ")" );
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "clip-path", sClipPathAttrValue );
+
+ SvXMLElementExport aSlideElement( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
+
+ bRet = implExportPage( sPageId, rxPages[i], xShapes, sal_False /* is not a master page */ ) || bRet;
+ }
+ } // append the </g> closing tag related to the svg element handling the slide visibility
+ }
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "Background" ) );
+ return bRet;
+}
- // insert the <g> open tag related to the Background
- SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
+// -----------------------------------------------------------------------------
+sal_Bool SVGFilter::implExportPage( const ::rtl::OUString & sPageId,
+ const Reference< XDrawPage > & rxPage,
+ const Reference< XShapes > & xShapes,
+ sal_Bool bMaster )
+{
+ sal_Bool bRet = sal_False;
- // append all elements that make up the Background
- const Point aNullPt;
- mpSVGWriter->WriteMetaFile( aNullPt, rMtf.GetPrefSize(), rMtf, SVGWRITER_WRITE_FILL );
- } // insert the </g> closing tag related to the Background
- }
+ {
+ OUString sPageName = implGetInterfaceName( rxPage );
+ if( !(sPageName.isEmpty() || mbSinglePage ))
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrName, sPageName );
- // In case we are dealing with a master page we need to to group all its shapes
- // into a group element, this group will make up the so named "background objects"
- if( bMaster )
- {
- // background objects id = "bo-" + page id
- OUString sBackgroundObjectsId = B2UCONST( "bo-" );
- sBackgroundObjectsId += sPageId;
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sBackgroundObjectsId );
+ {
+ Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
- if( i == nVisiblePage && mVisiblePagePropSet.bAreBackgroundObjectsVisible )
- aAttrVisibilityValue = B2UCONST( "visible" );
- else
- aAttrVisibilityValue = B2UCONST( "hidden" );
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", aAttrVisibilityValue );
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "BackgroundObjects" ) );
+ if( xExtDocHandler.is() )
+ {
+ OUString aDesc;
- // insert the <g> open tag related to the Background Objects
- SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
+ if( bMaster )
+ aDesc = B2UCONST( "Master_Slide" );
+ else
+ aDesc = B2UCONST( "Page" );
- // append all shapes that make up the Master Slide
- bRet = implExportShapes( xShapes ) || bRet;
- } // append the </g> closing tag related to the Background Objects
- else
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", aDesc );
+ }
+ }
+
+ // insert the <g> open tag related to the DrawPage/MasterPage
+ SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
+
+ // In case the page has a background object we append it .
+ if( (mpObjects->find( rxPage ) != mpObjects->end()) )
+ {
+ const GDIMetaFile& rMtf = (*mpObjects)[ rxPage ].GetRepresentation();
+ if( rMtf.GetActionSize() )
+ {
+ // background id = "bg-" + page id
+ OUString sBackgroundId = B2UCONST( "bg-" );
+ sBackgroundId += sPageId;
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sBackgroundId );
+
+ // At present (LibreOffice 3.4.0) the 'IsBackgroundVisible' property is not handled
+ // by Impress; anyway we handle this property as referring only to the visibility
+ // of the master page background. So if a slide has its own background object,
+ // the visibility of such a background object is always inherited from the visibility
+ // of the parent slide regardless of the value of the 'IsBackgroundVisible' property.
+ // This means that we need to set up the visibility attribute only for the background
+ // element of a master page.
+ if( mbSinglePage && bMaster )
+ {
+ if( !mVisiblePagePropSet.bIsBackgroundVisible )
{
- // append all shapes that make up the Slide
- bRet = implExportShapes( xShapes ) || bRet;
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", B2UCONST( "hidden" ) );
}
- } // append the </g> closing tag related to the Slide/Master_Slide
+ }
+
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "Background" ) );
+
+ // insert the <g> open tag related to the Background
+ SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
+
+ // append all elements that make up the Background
+ const Point aNullPt;
+ mpSVGWriter->WriteMetaFile( aNullPt, rMtf.GetPrefSize(), rMtf, SVGWRITER_WRITE_FILL );
+ } // insert the </g> closing tag related to the Background
+ }
+
+ // In case we are dealing with a master page we need to to group all its shapes
+ // into a group element, this group will make up the so named "background objects"
+ if( bMaster )
+ {
+ // background objects id = "bo-" + page id
+ OUString sBackgroundObjectsId = B2UCONST( "bo-" );
+ sBackgroundObjectsId += sPageId;
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sBackgroundObjectsId );
+ if( mbSinglePage )
+ {
+ if( !mVisiblePagePropSet.bAreBackgroundObjectsVisible )
+ {
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", B2UCONST( "hidden" ) );
+ }
}
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "BackgroundObjects" ) );
+
+ // insert the <g> open tag related to the Background Objects
+ SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True );
+
+ // append all shapes that make up the Master Slide
+ bRet = implExportShapes( xShapes ) || bRet;
+ } // append the </g> closing tag related to the Background Objects
+ else
+ {
+ // append all shapes that make up the Slide
+ bRet = implExportShapes( xShapes ) || bRet;
}
- }
+ } // append the </g> closing tag related to the Slide/Master_Slide
return bRet;
}
+
// -----------------------------------------------------------------------------
sal_Bool SVGFilter::implExportShapes( const Reference< XShapes >& rxShapes )
@@ -1451,34 +1471,24 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape )
const Size aSize( aBoundRect.Width, aBoundRect.Height );
if( rMtf.GetActionSize() )
- { // for text field shapes we set up visibility and text-adjust attributes
- // TODO should we set up visibility for all text field shapes to hidden at start ?
+ { // for text field shapes we set up text-adjust attributes
+ // and set visibility to hidden
OUString aShapeClass = implGetClassFromShape( rxShape );
if( mbPresentation )
{
- sal_Bool bIsPageNumber = aShapeClass == "Slide_Number";
- sal_Bool bIsFooter = aShapeClass == "Footer";
- sal_Bool bIsDateTime = aShapeClass == "Date/Time";
+ sal_Bool bIsPageNumber = ( aShapeClass == "Slide_Number" );
+ sal_Bool bIsFooter = ( aShapeClass == "Footer" );
+ sal_Bool bIsDateTime = ( aShapeClass == "Date/Time" );
if( bIsPageNumber || bIsDateTime || bIsFooter )
{
- // to notify to the SVGActionWriter::ImplWriteActions method
- // that we are dealing with a placeholder shape
- pElementId = &sPlaceholderTag;
-
- // if the text field does not belong to the visible page its svg:visibility
- // attribute is set to 'hidden'; else it depends on the related property of the visible page
- OUString aAttrVisibilityValue( B2UCONST( "hidden" ) );
- if(mbIsPageVisible && mVisiblePagePropSet.bAreBackgroundObjectsVisible && (
- ( bIsPageNumber && mVisiblePagePropSet.bIsPageNumberFieldVisible ) ||
- ( bIsDateTime && mVisiblePagePropSet.bIsDateTimeFieldVisible ) ||
- ( bIsFooter && mVisiblePagePropSet.bIsFooterFieldVisible ) ) )
- {
- aAttrVisibilityValue = B2UCONST( "visible" );
- }
- mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", aAttrVisibilityValue );
-
if( !mbSinglePage )
{
+ // to notify to the SVGActionWriter::ImplWriteActions method
+ // that we are dealing with a placeholder shape
+ pElementId = &sPlaceholderTag;
+
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", B2UCONST( "hidden" ) );
+
sal_uInt16 nTextAdjust = ParagraphAdjust_LEFT;
OUString sTextAdjust;
xShapePropSet->getPropertyValue( B2UCONST( "ParaAdjust" ) ) >>= nTextAdjust;
@@ -1499,6 +1509,16 @@ sal_Bool SVGFilter::implExportShape( const Reference< XShape >& rxShape )
}
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrTextAdjust, sTextAdjust );
}
+ else // single page case
+ {
+ if( !mVisiblePagePropSet.bAreBackgroundObjectsVisible || (
+ ( bIsPageNumber && !mVisiblePagePropSet.bIsPageNumberFieldVisible ) ||
+ ( bIsDateTime && !mVisiblePagePropSet.bIsDateTimeFieldVisible ) ||
+ ( bIsFooter && !mVisiblePagePropSet.bIsFooterFieldVisible ) ) )
+ {
+ mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", B2UCONST( "hidden" ) );
+ }
+ }
}
}
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", aShapeClass );
@@ -1769,12 +1789,13 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo )
if( pInfo && mbPresentation )
{
bFieldProcessed = true;
- // to notify to the SVGActionWriter::ImplWriteText method
- // that we are dealing with a placeholder shape
- OUString aRepresentation = sPlaceholderTag;
-
+ OUString aRepresentation = B2UCONST("");
if( !mbSinglePage )
{
+ // to notify to the SVGActionWriter::ImplWriteText method
+ // that we are dealing with a placeholder shape
+ aRepresentation = sPlaceholderTag;
+
if( !mCreateOjectsCurrentMasterPage.is() )
{
OSL_FAIL( "error: !mCreateOjectsCurrentMasterPage.is()" );
@@ -1929,7 +1950,7 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo )
}
pInfo->SetRepresentation( aRepresentation );
}
- else
+ else // single page case
{
if( mVisiblePagePropSet.bAreBackgroundObjectsVisible )
{
@@ -1973,7 +1994,6 @@ IMPL_LINK( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo )
}
}
}
-
pInfo->SetRepresentation( aRepresentation );
}
}
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 9b5c7fed092b..0f52b3edc482 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -65,6 +65,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
#include <osl/diagnose.h>
+#include <sal/log.hxx>
#include <rtl/process.h>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b2dpolygonclipper.hxx>
@@ -273,8 +274,6 @@ private:
sal_Bool mbExportAll;
sal_Bool mbSinglePage;
sal_Int32 mnVisiblePage;
- sal_Int32 mnVisibleMasterPage;
- sal_Bool mbIsPageVisible;
PagePropertySet mVisiblePagePropSet;
::rtl::OUString msClipPathId;
UCharSetMapMap mTextFieldCharSets;
@@ -302,9 +301,14 @@ private:
sal_Bool implExportDocument();
sal_Bool implExportAnimations();
- sal_Bool implExportPages( const XDrawPageSequence& rxPages,
- sal_Int32 nFirstPage, sal_Int32 nLastPage,
- sal_Int32 nVisiblePage, sal_Bool bMaster );
+ sal_Bool implExportMasterPages( const XDrawPageSequence& rxPages,
+ sal_Int32 nFirstPage, sal_Int32 nLastPage );
+ sal_Bool implExportDrawPages( const XDrawPageSequence& rxPages,
+ sal_Int32 nFirstPage, sal_Int32 nLastPage );
+ sal_Bool implExportPage( const ::rtl::OUString & sPageId,
+ const Reference< XDrawPage > & rxPage,
+ const Reference< XShapes > & xShapes,
+ sal_Bool bMaster );
sal_Bool implExportShapes( const Reference< XShapes >& rxShapes );
sal_Bool implExportShape( const Reference< XShape >& rxShape );