diff options
Diffstat (limited to 'sdext/source/pdfimport/tree/drawtreevisiting.cxx')
-rw-r--r-- | sdext/source/pdfimport/tree/drawtreevisiting.cxx | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 2fd17d059e23..5f1bb429ce8a 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -36,13 +36,15 @@ #include "drawtreevisiting.hxx" #include "genericelements.hxx" -#include <basegfx/polygon/b2dpolypolygontools.hxx> -#include <basegfx/range/b2drange.hxx> +#include "basegfx/polygon/b2dpolypolygontools.hxx" +#include "basegfx/range/b2drange.hxx" -#include <com/sun/star/i18n/XBreakIterator.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include "com/sun/star/i18n/XBreakIterator.hpp" +#include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "comphelper/processfactory.hxx" -#include <com/sun/star/i18n/ScriptType.hpp> +#include "com/sun/star/i18n/ScriptType.hpp" +#include "com/sun/star/i18n/DirectionProperty.hpp" + #include <string.h> using namespace ::com::sun::star; @@ -79,6 +81,18 @@ const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > return mxBreakIter; } +const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification >& DrawXmlEmitter::GetCharacterClassification() +{ + if ( !mxCharClass.is() ) + { + Reference< XComponentContext > xContext( m_rEmitContext.m_xContext, uno::UNO_SET_THROW ); + Reference< XMultiComponentFactory > xMSF( xContext->getServiceManager(), uno::UNO_SET_THROW ); + Reference < XInterface > xInterface = xMSF->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.i18n.CharacterClassification"), xContext); + mxCharClass = uno::Reference< i18n::XCharacterClassification >( xInterface, uno::UNO_QUERY ); + } + return mxCharClass; +} + void DrawXmlEmitter::visit( HyperlinkElement& elem, const std::list< Element* >::const_iterator& ) { if( elem.Children.empty() ) @@ -119,30 +133,25 @@ void DrawXmlEmitter::visit( TextElement& elem, const std::list< Element* >::cons rtl::OUString str(elem.Text.getStr()); - // Check for CTL - bool isComplex = false; - for(int i=0; i< elem.Text.getLength(); i++) - { - sal_Int16 nType = GetBreakIterator()->getScriptType( str, i + 1); - if (nType == ::com::sun::star::i18n::ScriptType::COMPLEX) - isComplex = true; - } - - #if 0 - // FIXME: need to have a service to do this mirroring - if (isComplex) // If so, reverse string + // Check for RTL + bool isRTL = false; + Reference< i18n::XCharacterClassification > xCC( GetCharacterClassification() ); + if( xCC.is() ) { - rtl::OUString flippedStr(RTL_CONSTASCII_USTRINGPARAM( "" )); - for(int i = str.getLength() - 1; i >= 0; i--) + for(int i=1; i< elem.Text.getLength(); i++) { - sal_Unicode cChar = str[ i ]; - cChar = static_cast<sal_Unicode>(GetMirroredChar( cChar )); - rtl::OUString uC(cChar); - flippedStr += uC; + sal_Int16 nType = xCC->getCharacterDirection( str, i ); + if ( nType == ::com::sun::star::i18n::DirectionProperty_RIGHT_TO_LEFT || + nType == ::com::sun::star::i18n::DirectionProperty_RIGHT_TO_LEFT_ARABIC || + nType == ::com::sun::star::i18n::DirectionProperty_RIGHT_TO_LEFT_EMBEDDING || + nType == ::com::sun::star::i18n::DirectionProperty_RIGHT_TO_LEFT_OVERRIDE + ) + isRTL = true; } - str = flippedStr; } - #endif + + if (isRTL) // If so, reverse string + str = m_rProcessor.mirrorString( str ); m_rEmitContext.rEmitter.beginTag( "text:span", aProps ); |