summaryrefslogtreecommitdiff
path: root/filter/source/svg/svgwriter.cxx
diff options
context:
space:
mode:
authorMarco Cecchetti <mrcekets@gmail.com>2011-07-10 17:14:28 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2011-07-11 09:57:18 +0200
commit5e68d551d54cd5fb3ee8700562491239c977cda3 (patch)
treecc288368835c719356ed69c2d4f0d4d279945659 /filter/source/svg/svgwriter.cxx
parent2cabcc1f62cfc1b57241796776d3b7007b250829 (diff)
Implemented a new way for exporting and handling placeholder text elements
Diffstat (limited to 'filter/source/svg/svgwriter.cxx')
-rw-r--r--filter/source/svg/svgwriter.cxx122
1 files changed, 79 insertions, 43 deletions
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index b6878891baba..364036f35fb1 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -32,6 +32,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_filter.hxx"
+#include "svgfilter.hxx"
#include "svgfontexport.hxx"
#include "svgwriter.hxx"
#include <vcl/unohelp.hxx>
@@ -1174,74 +1175,101 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText,
mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform );
}
- // this class attribute is used by the JavaScript based presentation engine
- // to modify the text content of placeholder text shapes of the master slide
- mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "TextBlock" ) );
mpContext->AddPaintAttr( COL_TRANSPARENT, aTextColor );
- // for each line of text there should be at least one group element of class TextBlock
+ // for each line of text there should be at least one group element
SvXMLElementExport aSVGGElem( mrExport, XML_NAMESPACE_NONE, aXMLElemG, sal_True, sal_False );
- if( nLen > 1 )
- {
- aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( rText.GetChar( nLen - 1 ) );
+ sal_Bool bIsPlaceholderField = sal_False;
- if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) )
+ if( mbIsPlacehlolderShape )
+ {
+ OUString sTextContent = rText;
+ bIsPlaceholderField = sTextContent.match( sPlaceholderTag );
+ // for a placeholder text field we export only one <text> svg element
+ if( bIsPlaceholderField )
{
- const double fFactor = (double) nWidth / aNormSize.Width();
-
- for( long i = 0; i < ( nLen - 1 ); i++ )
- pDX[ i ] = FRound( pDX[ i ] * fFactor );
+ OUString sCleanTextContent;
+ static const sal_Int32 nFrom = sPlaceholderTag.getLength();
+ if( sTextContent.getLength() > nFrom )
+ {
+ sCleanTextContent = sTextContent.copy( nFrom );
+ }
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, "class", B2UCONST( "PlaceholderText" ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
+ // At least for the single slide case we need really to export placeholder text
+ mrExport.GetDocHandler()->characters( sCleanTextContent );
+ }
}
- else
+ }
+
+ if( !bIsPlaceholderField )
+ {
+ if( nLen > 1 )
{
- ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBI( ::vcl::unohelper::CreateBreakIterator() );
- const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLocale();
- sal_Int32 nCurPos = 0, nLastPos = 0, nX = aPos.X();
+ aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( rText.GetChar( nLen - 1 ) );
- // write single glyphs at absolute text positions
- for( sal_Bool bCont = sal_True; bCont; )
+ if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) )
{
- sal_Int32 nCount = 1;
+ const double fFactor = (double) nWidth / aNormSize.Width();
- nLastPos = nCurPos;
- nCurPos = xBI->nextCharacters( rText, nCurPos, rLocale,
- ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL,
- nCount, nCount );
-
- nCount = nCurPos - nLastPos;
- bCont = ( nCurPos < rText.Len() ) && nCount;
+ for( long i = 0; i < ( nLen - 1 ); i++ )
+ pDX[ i ] = FRound( pDX[ i ] * fFactor );
+ }
+ else
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBI( ::vcl::unohelper::CreateBreakIterator() );
+ const ::com::sun::star::lang::Locale& rLocale = Application::GetSettings().GetLocale();
+ sal_Int32 nCurPos = 0, nLastPos = 0, nX = aPos.X();
- if( nCount )
+ // write single glyphs at absolute text positions
+ for( sal_Bool bCont = sal_True; bCont; )
{
- const ::rtl::OUString aGlyph( rText.Copy( nLastPos, nCount ) );
+ sal_Int32 nCount = 1;
- mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( nX ) );
- mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
+ nLastPos = nCurPos;
+ nCurPos = xBI->nextCharacters( rText, nCurPos, rLocale,
+ ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL,
+ nCount, nCount );
+ nCount = nCurPos - nLastPos;
+ bCont = ( nCurPos < rText.Len() ) && nCount;
+
+ if( nCount )
{
- SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
- mrExport.GetDocHandler()->characters( aGlyph );
- }
+ const ::rtl::OUString aGlyph( rText.Copy( nLastPos, nCount ) );
- if( bCont )
- nX = aPos.X() + pDXArray[ nCurPos - 1 ];
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( nX ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
+
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
+ mrExport.GetDocHandler()->characters( aGlyph );
+ }
+
+ if( bCont )
+ nX = aPos.X() + pDXArray[ nCurPos - 1 ];
+ }
}
}
}
- }
- else
- {
- mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) );
- mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
-
+ else
{
- SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
- mrExport.GetDocHandler()->characters( rText );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, ::rtl::OUString::valueOf( aPos.X() ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, ::rtl::OUString::valueOf( aPos.Y() ) );
+
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, sal_True, sal_False );
+ mrExport.GetDocHandler()->characters( rText );
+ }
}
}
+
if( !mrExport.IsUseNativeTextDecoration() )
{
if( rFont.GetStrikeout() != STRIKEOUT_NONE || rFont.GetUnderline() != UNDERLINE_NONE )
@@ -1339,6 +1367,14 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
if( mnInnerMtfCount )
nWriteFlags |= SVGWRITER_NO_SHAPE_COMMENTS;
+ mbIsPlacehlolderShape = false;
+ if( pElementId != NULL && ( *pElementId == sPlaceholderTag ) )
+ {
+ mbIsPlacehlolderShape = true;
+ // since we utilize pElementId in an improper way we reset it to NULL before to go on
+ pElementId = NULL;
+ }
+
for( sal_uLong nCurAction = 0, nCount = rMtf.GetActionSize(); nCurAction < nCount; nCurAction++ )
{
const MetaAction* pAction = rMtf.GetAction( nCurAction );