Kaydet (Commit) 15452177 authored tarafından Marco Cecchetti's avatar Marco Cecchetti Kaydeden (comit) Andras Timar

svg export: no more an experimental feature

Removed experimental feature check.
Single slide exporting works as for multi slides exporting.

SVGExportTextDecorations unit test - fixed wrong XPath
The new way single slide are exported caused the xpath to the slide
group to be wrong,

Change-Id: I4db4dc77de4f0d1208418455e1fca3b5732c8477
Reviewed-on: https://gerrit.libreoffice.org/20459Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 689962fe
...@@ -716,17 +716,14 @@ bool SVGFilter::implExportDocument() ...@@ -716,17 +716,14 @@ bool SVGFilter::implExportDocument()
bool bRet = false; bool bRet = false;
sal_Int32 nLastPage = mSelectedPages.getLength() - 1; sal_Int32 nLastPage = mSelectedPages.getLength() - 1;
SvtMiscOptions aMiscOptions; mbSinglePage = (nLastPage == 0);
const bool bExperimentalMode = aMiscOptions.IsExperimentalMode();
mbSinglePage = ((nLastPage == 0) || !bExperimentalMode) && !comphelper::LibreOfficeKit::isActive();
mnVisiblePage = -1; mnVisiblePage = -1;
const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY ); const Reference< XPropertySet > xDefaultPagePropertySet( mxDefaultPage, UNO_QUERY );
const Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY ); const Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
// #i124608# // #i124608#
mbExportSelection = mbSinglePage && maShapeSelection.is() && maShapeSelection->getCount(); mbExportShapeSelection = mbSinglePage && maShapeSelection.is() && maShapeSelection->getCount();
if(xDefaultPagePropertySet.is()) if(xDefaultPagePropertySet.is())
{ {
...@@ -734,7 +731,7 @@ bool SVGFilter::implExportDocument() ...@@ -734,7 +731,7 @@ bool SVGFilter::implExportDocument()
xDefaultPagePropertySet->getPropertyValue( "Height" ) >>= nDocHeight; xDefaultPagePropertySet->getPropertyValue( "Height" ) >>= nDocHeight;
} }
if(mbExportSelection) if(mbExportShapeSelection)
{ {
// #i124608# create BoundRange and set nDocX, nDocY, nDocWidth and nDocHeight // #i124608# create BoundRange and set nDocX, nDocY, nDocWidth and nDocHeight
basegfx::B2DRange aShapeRange; basegfx::B2DRange aShapeRange;
...@@ -794,7 +791,7 @@ bool SVGFilter::implExportDocument() ...@@ -794,7 +791,7 @@ bool SVGFilter::implExportDocument()
// instead of centered. // instead of centered.
#define _SVG_WRITE_EXTENTS #define _SVG_WRITE_EXTENTS
#ifdef _SVG_WRITE_EXTENTS #ifdef _SVG_WRITE_EXTENTS
if( mbSinglePage ) if( !mbPresentation )
{ {
aAttr = OUString::number( nDocWidth * 0.01 ) + "mm"; aAttr = OUString::number( nDocWidth * 0.01 ) + "mm";
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", aAttr ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "width", aAttr );
...@@ -805,7 +802,7 @@ bool SVGFilter::implExportDocument() ...@@ -805,7 +802,7 @@ bool SVGFilter::implExportDocument()
#endif #endif
// #i124608# set viewBox explicitely to the exported content // #i124608# set viewBox explicitely to the exported content
if (mbExportSelection) if (mbExportShapeSelection)
{ {
aAttr = OUString::number(nDocX) + " " + OUString::number(nDocY) + " "; aAttr = OUString::number(nDocX) + " " + OUString::number(nDocY) + " ";
} }
...@@ -854,10 +851,9 @@ bool SVGFilter::implExportDocument() ...@@ -854,10 +851,9 @@ bool SVGFilter::implExportDocument()
if( implLookForFirstVisiblePage() ) // OK! We found at least one visible page. if( implLookForFirstVisiblePage() ) // OK! We found at least one visible page.
{ {
if( !mbSinglePage ) if( mbPresentation )
{ {
implGenerateMetaData(); implGenerateMetaData();
if( bExperimentalMode )
implExportAnimations(); implExportAnimations();
} }
else else
...@@ -893,11 +889,11 @@ bool SVGFilter::implExportDocument() ...@@ -893,11 +889,11 @@ bool SVGFilter::implExportDocument()
} }
// #i124608# export a given object selection, so no MasterPage export at all // #i124608# export a given object selection, so no MasterPage export at all
if (!mbExportSelection) if (!mbExportShapeSelection)
implExportMasterPages( mMasterPageTargets, 0, mMasterPageTargets.size() - 1 ); implExportMasterPages( mMasterPageTargets, 0, mMasterPageTargets.size() - 1 );
implExportDrawPages( mSelectedPages, 0, nLastPage ); implExportDrawPages( mSelectedPages, 0, nLastPage );
if( !mbSinglePage ) if( mbPresentation )
{ {
implGenerateScript(); implGenerateScript();
} }
...@@ -1488,7 +1484,7 @@ bool SVGFilter::implExportMasterPages( const std::vector< Reference< XDrawPage > ...@@ -1488,7 +1484,7 @@ bool SVGFilter::implExportMasterPages( const std::vector< Reference< XDrawPage >
// When the exported slides are more than one we wrap master page elements // When the exported slides are more than one we wrap master page elements
// with a svg <defs> element. // with a svg <defs> element.
OUString aContainerTag = (mbSinglePage) ? OUString( "g" ) : OUString( "defs" ); OUString aContainerTag = (!mbPresentation) ? OUString( "g" ) : OUString( "defs" );
SvXMLElementExport aContainerElement( *mpSVGExport, XML_NAMESPACE_NONE, aContainerTag, true, true ); SvXMLElementExport aContainerElement( *mpSVGExport, XML_NAMESPACE_NONE, aContainerTag, true, true );
bool bRet = false; bool bRet = false;
...@@ -1528,7 +1524,7 @@ bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rxPage ...@@ -1528,7 +1524,7 @@ bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rxPage
{ {
Reference< XShapes > xShapes; Reference< XShapes > xShapes;
if (mbExportSelection) if (mbExportShapeSelection)
{ {
// #i124608# export a given object selection // #i124608# export a given object selection
xShapes = maShapeSelection; xShapes = maShapeSelection;
...@@ -1544,7 +1540,7 @@ bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rxPage ...@@ -1544,7 +1540,7 @@ bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rxPage
// handling a slide visibility. // handling a slide visibility.
// In case the exported slides are more than one the initial // In case the exported slides are more than one the initial
// visibility of each slide is set to 'hidden'. // visibility of each slide is set to 'hidden'.
if( !mbSinglePage ) if( mbPresentation )
{ {
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", "hidden" ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", "hidden" );
} }
...@@ -1583,7 +1579,7 @@ bool SVGFilter::implExportPage( const OUString & sPageId, ...@@ -1583,7 +1579,7 @@ bool SVGFilter::implExportPage( const OUString & sPageId,
{ {
OUString sPageName = implGetInterfaceName( rxPage ); OUString sPageName = implGetInterfaceName( rxPage );
if( !(sPageName.isEmpty() || mbSinglePage )) if( mbPresentation && !sPageName.isEmpty() )
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrName, sPageName ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrName, sPageName );
{ {
...@@ -1623,7 +1619,7 @@ bool SVGFilter::implExportPage( const OUString & sPageId, ...@@ -1623,7 +1619,7 @@ bool SVGFilter::implExportPage( const OUString & sPageId,
// of the parent slide regardless of the value of the 'IsBackgroundVisible' property. // 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 // This means that we need to set up the visibility attribute only for the background
// element of a master page. // element of a master page.
if( mbSinglePage && bMaster ) if( !mbPresentation && bMaster )
{ {
if( !mVisiblePagePropSet.bIsBackgroundVisible ) if( !mVisiblePagePropSet.bIsBackgroundVisible )
{ {
...@@ -1650,7 +1646,7 @@ bool SVGFilter::implExportPage( const OUString & sPageId, ...@@ -1650,7 +1646,7 @@ bool SVGFilter::implExportPage( const OUString & sPageId,
OUString sBackgroundObjectsId = "bo-"; OUString sBackgroundObjectsId = "bo-";
sBackgroundObjectsId += sPageId; sBackgroundObjectsId += sPageId;
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sBackgroundObjectsId ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", sBackgroundObjectsId );
if( mbSinglePage ) if( !mbPresentation )
{ {
if( !mVisiblePagePropSet.bAreBackgroundObjectsVisible ) if( !mVisiblePagePropSet.bAreBackgroundObjectsVisible )
{ {
...@@ -1755,8 +1751,6 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape, ...@@ -1755,8 +1751,6 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape,
bool bIsFooter = ( aShapeClass == "Footer" ); bool bIsFooter = ( aShapeClass == "Footer" );
bool bIsDateTime = ( aShapeClass == "Date/Time" ); bool bIsDateTime = ( aShapeClass == "Date/Time" );
if( bIsPageNumber || bIsDateTime || bIsFooter ) if( bIsPageNumber || bIsDateTime || bIsFooter )
{
if( !mbSinglePage )
{ {
// to notify to the SVGActionWriter::ImplWriteActions method // to notify to the SVGActionWriter::ImplWriteActions method
// that we are dealing with a placeholder shape // that we are dealing with a placeholder shape
...@@ -1784,17 +1778,6 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape, ...@@ -1784,17 +1778,6 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape,
} }
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrTextAdjust, sTextAdjust ); 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", "hidden" );
}
}
}
} }
mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", aShapeClass ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", aShapeClass );
SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true ); SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
...@@ -1885,7 +1868,7 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape, ...@@ -1885,7 +1868,7 @@ bool SVGFilter::implExportShape( const Reference< XShape >& rxShape,
bool SVGFilter::implCreateObjects() bool SVGFilter::implCreateObjects()
{ {
if (mbExportSelection) if (mbExportShapeSelection)
{ {
// #i124608# export a given object selection // #i124608# export a given object selection
if (mSelectedPages.getLength() && mSelectedPages[0].is()) if (mSelectedPages.getLength() && mSelectedPages[0].is())
...@@ -2180,8 +2163,6 @@ IMPL_LINK_TYPED( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void ) ...@@ -2180,8 +2163,6 @@ IMPL_LINK_TYPED( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void )
{ {
bFieldProcessed = true; bFieldProcessed = true;
OUString aRepresentation; OUString aRepresentation;
if( !mbSinglePage )
{
if( mpSVGExport->IsEmbedFonts() && mpSVGExport->IsUsePositionedCharacters() ) if( mpSVGExport->IsEmbedFonts() && mpSVGExport->IsUsePositionedCharacters() )
{ {
// to notify to the SVGActionWriter::ImplWriteText method // to notify to the SVGActionWriter::ImplWriteText method
...@@ -2354,62 +2335,8 @@ IMPL_LINK_TYPED( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void ) ...@@ -2354,62 +2335,8 @@ IMPL_LINK_TYPED( SVGFilter, CalcFieldHdl, EditFieldInfo*, pInfo, void )
{ {
bFieldProcessed = false; bFieldProcessed = false;
} }
}
else // single page case
{
if( mVisiblePagePropSet.bAreBackgroundObjectsVisible )
{
const SvxFieldData* pField = pInfo->GetField().GetField();
if( ( pField->GetClassId() == text::textfield::Type::PRESENTATION_HEADER ) && mVisiblePagePropSet.bIsHeaderFieldVisible )
{
aRepresentation += mVisiblePagePropSet.sHeaderText;
}
else if( ( pField->GetClassId() == text::textfield::Type::PRESENTATION_FOOTER ) && mVisiblePagePropSet.bIsFooterFieldVisible )
{
aRepresentation += mVisiblePagePropSet.sFooterText;
}
else if( ( pField->GetClassId() == text::textfield::Type::PRESENTATION_DATE_TIME ) && mVisiblePagePropSet.bIsDateTimeFieldVisible )
{
// TODO: implement the variable case
aRepresentation += mVisiblePagePropSet.sDateTimeText;
}
else if( ( pField->GetClassId() == text::textfield::Type::PAGE ) && mVisiblePagePropSet.bIsPageNumberFieldVisible )
{
sal_Int16 nPageNumber = mVisiblePagePropSet.nPageNumber;
switch( mVisiblePagePropSet.nPageNumberingType )
{
case SVX_CHARS_UPPER_LETTER:
aRepresentation += OUString( (sal_Unicode)(char)( ( nPageNumber - 1 ) % 26 + 'A' ) );
break;
case SVX_CHARS_LOWER_LETTER:
aRepresentation += OUString( (sal_Unicode)(char)( ( nPageNumber - 1 ) % 26 + 'a' ) );
break;
case SVX_ROMAN_UPPER:
aRepresentation += SvxNumberFormat::CreateRomanString( nPageNumber, true /* upper */ );
break;
case SVX_ROMAN_LOWER:
aRepresentation += SvxNumberFormat::CreateRomanString( nPageNumber, false /* lower */ );
break;
// arabic numbering type is the default
case SVX_ARABIC:
// in case the numbering type is not handled we fall back on arabic numbering
default:
aRepresentation += OUString::number( nPageNumber );
break;
}
}
else
{
bFieldProcessed = false;
}
if( bFieldProcessed )
{
pInfo->SetRepresentation( aRepresentation );
}
}
} }
}
if (!bFieldProcessed) if (!bFieldProcessed)
maOldFieldHdl.Call( pInfo ); maOldFieldHdl.Call( pInfo );
} }
......
...@@ -77,7 +77,7 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) : ...@@ -77,7 +77,7 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
mxDefaultPage(), mxDefaultPage(),
maFilterData(), maFilterData(),
maShapeSelection(), maShapeSelection(),
mbExportSelection(false), mbExportShapeSelection(false),
maOldFieldHdl() maOldFieldHdl()
{ {
} }
......
...@@ -240,7 +240,7 @@ private: ...@@ -240,7 +240,7 @@ private:
Sequence< PropertyValue > maFilterData; Sequence< PropertyValue > maFilterData;
// #i124608# explicit ShapeSelection for export when export of the selection is wanted // #i124608# explicit ShapeSelection for export when export of the selection is wanted
Reference< XShapes > maShapeSelection; Reference< XShapes > maShapeSelection;
bool mbExportSelection; bool mbExportShapeSelection;
XDrawPageSequence mSelectedPages; XDrawPageSequence mSelectedPages;
std::vector< Reference< XDrawPage > > mMasterPageTargets; std::vector< Reference< XDrawPage > > mMasterPageTargets;
......
...@@ -99,16 +99,16 @@ public: ...@@ -99,16 +99,16 @@ public:
svgDoc->name = reinterpret_cast<char *>(xmlStrdup(reinterpret_cast<xmlChar const *>(OUStringToOString(maTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr()))); svgDoc->name = reinterpret_cast<char *>(xmlStrdup(reinterpret_cast<xmlChar const *>(OUStringToOString(maTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr())));
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG ), 1); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG ), 1);
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2] ), "class", "SlideGroup"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1] ), "class", "SlideGroup");
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G ), "class", "Slide"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1]/SVG_G/SVG_G ), "class", "Slide");
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1] ), "class", "TitleText"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1]/SVG_G/SVG_G/SVG_G/SVG_G[1] ), "class", "TitleText");
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT ), "class", "TextShape"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT ), "class", "TextShape");
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT/SVG_TSPAN ), "class", "TextParagraph"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT/SVG_TSPAN ), "class", "TextParagraph");
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "underline"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "underline");
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT ), "class", "TextShape"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT ), "class", "TextShape");
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "class", "TextParagraph"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "class", "TextParagraph");
assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "line-through"); assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[1]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "line-through");
} }
CPPUNIT_TEST_SUITE(SdSVGFilterTest); CPPUNIT_TEST_SUITE(SdSVGFilterTest);
......
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