You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2012/01/26 10:16:52 UTC

svn commit: r1236110 - in /incubator/ooo/trunk/main: drawinglayer/inc/drawinglayer/primitive2d/ drawinglayer/source/primitive2d/ svgio/source/svgreader/

Author: alg
Date: Thu Jan 26 09:16:51 2012
New Revision: 1236110

URL: http://svn.apache.org/viewvc?rev=1236110&view=rev
Log:
#118834# Unified usage of TextBreakupHelper as single tooling class for i18n text primitive breakup

Modified:
    incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textbreakuphelper.hxx
    incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx
    incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textbreakuphelper.cxx
    incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx
    incubator/ooo/trunk/main/svgio/source/svgreader/svgcharacternode.cxx
    incubator/ooo/trunk/main/svgio/source/svgreader/svgtextpathnode.cxx

Modified: incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textbreakuphelper.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textbreakuphelper.hxx?rev=1236110&r1=1236109&r2=1236110&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textbreakuphelper.hxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textbreakuphelper.hxx Thu Jan 26 09:16:51 2012
@@ -31,8 +31,8 @@
 
 namespace drawinglayer
 {
-	namespace primitive2d
-	{
+    namespace primitive2d
+    {
         enum BreakupUnit
         {
             BreakupUnit_character,
@@ -43,17 +43,16 @@ namespace drawinglayer
         class DRAWINGLAYER_DLLPUBLIC TextBreakupHelper
         {
         private:
-            const Primitive2DReference              mxSource;
+            const TextSimplePortionPrimitive2D&     mrSource;
             Primitive2DSequence                     mxResult;
-            const TextSimplePortionPrimitive2D*     mpSource;
-    		TextLayouterDevice                      maTextLayouter;
+            TextLayouterDevice                      maTextLayouter;
             basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose maDecTrans;
 
             /// bitfield
             bool                                    mbNoDXArray : 1;
 
             /// create a portion from nIndex to nLength and append to rTempResult
-            void breakupPortion(Primitive2DVector& rTempResult, sal_uInt32 nIndex, sal_uInt32 nLength);
+            void breakupPortion(Primitive2DVector& rTempResult, sal_uInt32 nIndex, sal_uInt32 nLength, bool bWordLineMode);
 
             /// breakup complete primitive
             void breakup(BreakupUnit aBreakupUnit);
@@ -65,22 +64,19 @@ namespace drawinglayer
             virtual bool allowChange(sal_uInt32 nCount, basegfx::B2DHomMatrix& rNewTransform, sal_uInt32 nIndex, sal_uInt32 nLength);
 
             /// allow read access to evtl. useful local parts
-            const TextSimplePortionPrimitive2D* getCastedSource() const { return mpSource; }
             const TextLayouterDevice& getTextLayouter() const { return maTextLayouter; }
             const basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& getDecTrans() const { return maDecTrans; }
+            const TextSimplePortionPrimitive2D& getSource() const { return mrSource; }
 
         public:
-            TextBreakupHelper(const Primitive2DReference& rxSource);
+            TextBreakupHelper(const TextSimplePortionPrimitive2D& rSource);
             virtual ~TextBreakupHelper();
 
             /// get result
             const Primitive2DSequence& getResult(BreakupUnit aBreakupUnit = BreakupUnit_character) const;
-
-            /// data read access
-            const Primitive2DReference& getSource() const { return mxSource; }
         };
 
-	} // end of namespace primitive2d
+    } // end of namespace primitive2d
 } // end of namespace drawinglayer
 
 //////////////////////////////////////////////////////////////////////////////

Modified: incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx?rev=1236110&r1=1236109&r2=1236110&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx Thu Jan 26 09:16:51 2012
@@ -81,13 +81,6 @@ namespace drawinglayer
                 const ::std::vector< double >& rDXArray,
                 const attribute::FontAttribute& rFontAttribute) const;
 
-			void impCorrectTextBoundary(
-				::com::sun::star::i18n::Boundary& rNextWordBoundary) const;
-
-			void impSplitSingleWords(
-                std::vector< Primitive2DReference >& rTarget,
-                basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& rDecTrans) const;
-
         protected:
 			/// local decomposition.
 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
@@ -134,6 +127,10 @@ namespace drawinglayer
 			bool getEmphasisMarkBelow() const { return mbEmphasisMarkBelow; }
 			bool getShadow() const { return mbShadow; }
 
+            /// check if this needs to be a TextDecoratedPortionPrimitive2D or
+            /// if a TextSimplePortionPrimitive2D would be suficcient
+            bool decoratedIsNeeded() const;
+
 			/// compare operator
 			virtual bool operator==( const BasePrimitive2D& rPrimitive ) const;
 

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textbreakuphelper.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textbreakuphelper.cxx?rev=1236110&r1=1236109&r2=1236110&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textbreakuphelper.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textbreakuphelper.cxx Thu Jan 26 09:16:51 2012
@@ -28,35 +28,33 @@
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/i18n/CharacterIteratorMode.hdl>
 #include <com/sun/star/i18n/WordType.hpp>
+#include <com/sun/star/i18n/CharType.hpp>
 
 //////////////////////////////////////////////////////////////////////////////
 
 namespace drawinglayer
 {
-	namespace primitive2d
-	{
-        TextBreakupHelper::TextBreakupHelper(const Primitive2DReference& rxSource)
-        :   mxSource(rxSource),
+    namespace primitive2d
+    {
+        TextBreakupHelper::TextBreakupHelper(const TextSimplePortionPrimitive2D& rSource)
+        :   mrSource(rSource),
             mxResult(),
-            mpSource(dynamic_cast< const TextSimplePortionPrimitive2D* >(rxSource.get())),
             maTextLayouter(),
             maDecTrans(),
             mbNoDXArray(false)
         {
-            if(mpSource)
-            {
-                maDecTrans = mpSource->getTextTransform();
-                mbNoDXArray = mpSource->getDXArray().empty();
+            OSL_ENSURE(dynamic_cast< const TextSimplePortionPrimitive2D* >(&mrSource), "TextBreakupHelper with illegal primitive created (!)");
+            maDecTrans = mrSource.getTextTransform();
+            mbNoDXArray = mrSource.getDXArray().empty();
 
-                if(mbNoDXArray)
-                {
-                    // init TextLayouter when no dxarray
-				    maTextLayouter.setFontAttribute(
-                        mpSource->getFontAttribute(), 
-                        maDecTrans.getScale().getX(), 
-                        maDecTrans.getScale().getY(),
-                        mpSource->getLocale());
-                }
+            if(mbNoDXArray)
+            {
+                // init TextLayouter when no dxarray
+                maTextLayouter.setFontAttribute(
+                    mrSource.getFontAttribute(), 
+                    maDecTrans.getScale().getX(), 
+                    maDecTrans.getScale().getY(),
+                    mrSource.getLocale());
             }
         }
 
@@ -64,70 +62,70 @@ namespace drawinglayer
         {
         }
 
-        void TextBreakupHelper::breakupPortion(Primitive2DVector& rTempResult, sal_uInt32 nIndex, sal_uInt32 nLength)
+        void TextBreakupHelper::breakupPortion(Primitive2DVector& rTempResult, sal_uInt32 nIndex, sal_uInt32 nLength, bool bWordLineMode)
         {
-            if(mpSource && nLength && !(nIndex == mpSource->getTextPosition() && nLength == mpSource->getTextLength()))
+            if(nLength && !(nIndex == mrSource.getTextPosition() && nLength == mrSource.getTextLength()))
             {
- 				// prepare values for new portion
-				basegfx::B2DHomMatrix aNewTransform;
-				::std::vector< double > aNewDXArray;
-				const bool bNewStartIsNotOldStart(nIndex > mpSource->getTextPosition());
-
-				if(!mbNoDXArray)
-				{
-					// prepare new DXArray for the single word
-					aNewDXArray = ::std::vector< double >(
-						mpSource->getDXArray().begin() + (nIndex - mpSource->getTextPosition()), 
-						mpSource->getDXArray().begin() + ((nIndex + nLength) - mpSource->getTextPosition()));
-				}
-
-				if(bNewStartIsNotOldStart)
-				{
-					// needs to be moved to a new start position
-					double fOffset(0.0);
-							
-					if(mbNoDXArray)
-					{
-						// evaluate using TextLayouter
-						fOffset = maTextLayouter.getTextWidth(mpSource->getText(), mpSource->getTextPosition(), nIndex);
-					}
-					else
-					{
-						// get from DXArray
-						const sal_uInt32 nIndex2(static_cast< sal_uInt32 >(nIndex - mpSource->getTextPosition()));
-						fOffset = mpSource->getDXArray()[nIndex2 - 1];
-					}
+                // prepare values for new portion
+                basegfx::B2DHomMatrix aNewTransform;
+                ::std::vector< double > aNewDXArray;
+                const bool bNewStartIsNotOldStart(nIndex > mrSource.getTextPosition());
+
+                if(!mbNoDXArray)
+                {
+                    // prepare new DXArray for the single word
+                    aNewDXArray = ::std::vector< double >(
+                        mrSource.getDXArray().begin() + (nIndex - mrSource.getTextPosition()), 
+                        mrSource.getDXArray().begin() + ((nIndex + nLength) - mrSource.getTextPosition()));
+                }
+
+                if(bNewStartIsNotOldStart)
+                {
+                    // needs to be moved to a new start position
+                    double fOffset(0.0);
+
+                    if(mbNoDXArray)
+                    {
+                        // evaluate using TextLayouter
+                        fOffset = maTextLayouter.getTextWidth(mrSource.getText(), mrSource.getTextPosition(), nIndex);
+                    }
+                    else
+                    {
+                        // get from DXArray
+                        const sal_uInt32 nIndex2(static_cast< sal_uInt32 >(nIndex - mrSource.getTextPosition()));
+                        fOffset = mrSource.getDXArray()[nIndex2 - 1];
+                    }
 
                     // need offset without FontScale for building the new transformation. The
                     // new transformation will be multiplied with the current text transformation
                     // so FontScale would be double
-					double fOffsetNoScale(fOffset);
+                    double fOffsetNoScale(fOffset);
                     const double fFontScaleX(maDecTrans.getScale().getX());
-                            
+
                     if(!basegfx::fTools::equal(fFontScaleX, 1.0) 
                         && !basegfx::fTools::equalZero(fFontScaleX))
                     {
                         fOffsetNoScale /= fFontScaleX;
                     }
 
-					// apply needed offset to transformation
+                    // apply needed offset to transformation
                     aNewTransform.translate(fOffsetNoScale, 0.0);
 
-					if(!mbNoDXArray)
-					{
-						// DXArray values need to be corrected with the offset, too. Here,
+                    if(!mbNoDXArray)
+                    {
+                        // DXArray values need to be corrected with the offset, too. Here,
                         // take the scaled offset since the DXArray is scaled
-						const sal_uInt32 nArraySize(aNewDXArray.size());
+                        const sal_uInt32 nArraySize(aNewDXArray.size());
 
-						for(sal_uInt32 a(0); a < nArraySize; a++)
-						{
-							aNewDXArray[a] -= fOffset;
-						}
-					}
-				}
+                        for(sal_uInt32 a(0); a < nArraySize; a++)
+                        {
+                            aNewDXArray[a] -= fOffset;
+                        }
+                    }
+                }
 
-				// add text transformation to new transformation
-				aNewTransform = maDecTrans.getB2DHomMatrix() * aNewTransform;
+                // add text transformation to new transformation
+                aNewTransform = maDecTrans.getB2DHomMatrix() * aNewTransform;
 
                 // callback to allow evtl. changes
                 const bool bCreate(allowChange(rTempResult.size(), aNewTransform, nIndex, nLength));
@@ -136,21 +134,21 @@ namespace drawinglayer
                 {
                     // check if we have a decorated primitive as source
                     const TextDecoratedPortionPrimitive2D* pTextDecoratedPortionPrimitive2D = 
-                        dynamic_cast< const TextDecoratedPortionPrimitive2D* >(mpSource);
+                        dynamic_cast< const TextDecoratedPortionPrimitive2D* >(&mrSource);
 
                     if(pTextDecoratedPortionPrimitive2D)
                     {
                         // create a TextDecoratedPortionPrimitive2D
-	                    rTempResult.push_back(
+                        rTempResult.push_back(
                             new TextDecoratedPortionPrimitive2D(
                                 aNewTransform,
-                                mpSource->getText(),
-				                nIndex,
-				                nLength,
+                                mrSource.getText(),
+                                nIndex,
+                                nLength,
                                 aNewDXArray,
-                                mpSource->getFontAttribute(),
-                                mpSource->getLocale(),
-                                mpSource->getFontColor(),
+                                mrSource.getFontAttribute(),
+                                mrSource.getLocale(),
+                                mrSource.getFontColor(),
                             
                                 pTextDecoratedPortionPrimitive2D->getOverlineColor(),
                                 pTextDecoratedPortionPrimitive2D->getTextlineColor(),
@@ -158,7 +156,10 @@ namespace drawinglayer
                                 pTextDecoratedPortionPrimitive2D->getFontUnderline(),
                                 pTextDecoratedPortionPrimitive2D->getUnderlineAbove(),
                                 pTextDecoratedPortionPrimitive2D->getTextStrikeout(),
-                                pTextDecoratedPortionPrimitive2D->getWordLineMode(),
+
+                                // reset WordLineMode when BreakupUnit_word is executed; else copy original
+                                bWordLineMode ? false : pTextDecoratedPortionPrimitive2D->getWordLineMode(),
+
                                 pTextDecoratedPortionPrimitive2D->getTextEmphasisMark(),
                                 pTextDecoratedPortionPrimitive2D->getEmphasisMarkAbove(),
                                 pTextDecoratedPortionPrimitive2D->getEmphasisMarkBelow(),
@@ -168,16 +169,16 @@ namespace drawinglayer
                     else
                     {
                         // create a SimpleTextPrimitive
-	                    rTempResult.push_back(
+                        rTempResult.push_back(
                             new TextSimplePortionPrimitive2D(
                                 aNewTransform,
-                                mpSource->getText(),
-				                nIndex,
-				                nLength,
+                                mrSource.getText(),
+                                nIndex,
+                                nLength,
                                 aNewDXArray,
-                                mpSource->getFontAttribute(),
-                                mpSource->getLocale(),
-                                mpSource->getFontColor()));
+                                mrSource.getFontAttribute(),
+                                mrSource.getLocale(),
+                                mrSource.getFontColor()));
                     }
                 }
             }
@@ -190,7 +191,7 @@ namespace drawinglayer
 
         void TextBreakupHelper::breakup(BreakupUnit aBreakupUnit)
         {
-            if(mpSource && mpSource->getTextLength())
+            if(mrSource.getTextLength())
             {
                 Primitive2DVector aTempResult;
                 static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBreakIterator;
@@ -203,10 +204,10 @@ namespace drawinglayer
 
                 if(xBreakIterator.is())
                 {
-                    const rtl::OUString& rTxt = mpSource->getText();
-                    const sal_Int32 nTextLength(mpSource->getTextLength());
-                    const ::com::sun::star::lang::Locale& rLocale = mpSource->getLocale();
-                    const sal_Int32 nTextPosition(mpSource->getTextPosition());
+                    const rtl::OUString& rTxt = mrSource.getText();
+                    const sal_Int32 nTextLength(mrSource.getTextLength());
+                    const ::com::sun::star::lang::Locale& rLocale = mrSource.getLocale();
+                    const sal_Int32 nTextPosition(mrSource.getTextPosition());
                     sal_Int32 nCurrent(nTextPosition);
                     
                     switch(aBreakupUnit)
@@ -221,13 +222,13 @@ namespace drawinglayer
                             {
                                 if(a == nNextCellBreak)
                                 {
-                                    breakupPortion(aTempResult, nCurrent, a - nCurrent);
+                                    breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
                                     nCurrent = a;
                                     nNextCellBreak = xBreakIterator->nextCharacters(rTxt, a, rLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
                                 }
                             }
 
-                            breakupPortion(aTempResult, nCurrent, a - nCurrent);
+                            breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
                             break;
                         }
                         case BreakupUnit_word:
@@ -239,13 +240,31 @@ namespace drawinglayer
                             {
                                 if(a == nNextWordBoundary.endPos)
                                 {
-                                    breakupPortion(aTempResult, nCurrent, a - nCurrent);
+                                    if(a > nCurrent)
+                                    {
+                                        breakupPortion(aTempResult, nCurrent, a - nCurrent, true);
+                                    }
+
                                     nCurrent = a;
+
+                                    // skip spaces (maybe enhanced with a bool later if needed)
+                                    {
+                                        const sal_Int32 nEndOfSpaces(xBreakIterator->endOfCharBlock(rTxt, a, rLocale, ::com::sun::star::i18n::CharType::SPACE_SEPARATOR));
+
+                                        if(nEndOfSpaces > a)
+                                        {
+                                            nCurrent = nEndOfSpaces;
+                                        }
+                                    }
+
                                     nNextWordBoundary = xBreakIterator->getWordBoundary(rTxt, a + 1, rLocale, ::com::sun::star::i18n::WordType::ANY_WORD, sal_True);
                                 }
                             }
 
-                            breakupPortion(aTempResult, nCurrent, a - nCurrent);
+                            if(a > nCurrent)
+                            {
+                                breakupPortion(aTempResult, nCurrent, a - nCurrent, true);
+                            }
                             break;
                         }
                         case BreakupUnit_sentence:
@@ -257,13 +276,13 @@ namespace drawinglayer
                             {
                                 if(a == nNextSentenceBreak)
                                 {
-                                    breakupPortion(aTempResult, nCurrent, a - nCurrent);
+                                    breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
                                     nCurrent = a;
                                     nNextSentenceBreak = xBreakIterator->endOfSentence(rTxt, a + 1, rLocale);
                                 }
                             }
 
-                            breakupPortion(aTempResult, nCurrent, a - nCurrent);
+                            breakupPortion(aTempResult, nCurrent, a - nCurrent, false);
                             break;
                         }
                     }
@@ -275,11 +294,7 @@ namespace drawinglayer
 
         const Primitive2DSequence& TextBreakupHelper::getResult(BreakupUnit aBreakupUnit) const
         {
-            if(mxResult.hasElements())
-            {
-                return mxResult;
-            }
-            else if(mpSource)
+            if(!mxResult.hasElements())
             {
                 const_cast< TextBreakupHelper* >(this)->breakup(aBreakupUnit);
             }
@@ -287,7 +302,7 @@ namespace drawinglayer
             return mxResult;
         }
 
-	} // end of namespace primitive2d
+    } // end of namespace primitive2d
 } // end of namespace drawinglayer
 
 //////////////////////////////////////////////////////////////////////////////

Modified: incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx?rev=1236110&r1=1236109&r2=1236110&view=diff
==============================================================================
--- incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx (original)
+++ incubator/ooo/trunk/main/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx Thu Jan 26 09:16:51 2012
@@ -25,19 +25,16 @@
 #include "precompiled_drawinglayer.hxx"
 
 #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
-#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <drawinglayer/attribute/strokeattribute.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
-#include <comphelper/processfactory.hxx>
-#include <com/sun/star/i18n/WordType.hpp>
 #include <drawinglayer/primitive2d/texteffectprimitive2d.hxx>
 #include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
-#include <com/sun/star/i18n/XBreakIterator.hpp>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
 #include <drawinglayer/primitive2d/textlineprimitive2d.hxx>
 #include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textbreakuphelper.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -165,231 +162,46 @@ namespace drawinglayer
             // TODO: Handle Font Emphasis Above/Below
         }
 
-		void TextDecoratedPortionPrimitive2D::impCorrectTextBoundary(::com::sun::star::i18n::Boundary& rNextWordBoundary) const
-		{
-			// truncate aNextWordBoundary to min/max possible values. This is necessary since the word start may be
-			// before/after getTextPosition() when a long string is the content and getTextPosition()
-			// is right inside a word. Same for end.
-			const sal_Int32 aMinPos(static_cast< sal_Int32 >(getTextPosition()));
-			const sal_Int32 aMaxPos(aMinPos + static_cast< sal_Int32 >(getTextLength()));
-
-			if(rNextWordBoundary.startPos < aMinPos)
-			{
-				rNextWordBoundary.startPos = aMinPos;
-			}
-			else if(rNextWordBoundary.startPos > aMaxPos)
-			{
-				rNextWordBoundary.startPos = aMaxPos;
-			}
-
-			if(rNextWordBoundary.endPos < aMinPos)
-			{
-				rNextWordBoundary.endPos = aMinPos;
-			}
-			else if(rNextWordBoundary.endPos > aMaxPos)
-			{
-				rNextWordBoundary.endPos = aMaxPos;
-			}
-		}
-
-        void TextDecoratedPortionPrimitive2D::impSplitSingleWords(
-            std::vector< Primitive2DReference >& rTarget,
-            basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& rDecTrans) const
+		Primitive2DSequence TextDecoratedPortionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
         {
-            // break iterator support
-            // made static so it only needs to be fetched once, even with many single
-            // constructed VclMetafileProcessor2D. It's still incarnated on demand,
-            // but exists for OOo runtime now by purpose.
-            static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xLocalBreakIterator;
-
-			if(!xLocalBreakIterator.is())
-            {
-                ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF(::comphelper::getProcessServiceFactory());
-                xLocalBreakIterator.set(xMSF->createInstance(rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator")), ::com::sun::star::uno::UNO_QUERY);
-            }
-
-            if(xLocalBreakIterator.is() && getTextLength())
+            if(getWordLineMode())
             {
-                // init word iterator, get first word and truncate to possibilities
-                ::com::sun::star::i18n::Boundary aNextWordBoundary(xLocalBreakIterator->getWordBoundary(
-                    getText(), getTextPosition(), getLocale(), ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True));
+                // support for single word mode; split to single word primitives
+                // using TextBreakupHelper
+                const TextBreakupHelper aTextBreakupHelper(*this);
+                const Primitive2DSequence aBroken(aTextBreakupHelper.getResult(BreakupUnit_word));
 
-                if(aNextWordBoundary.endPos == getTextPosition())
+                if(aBroken.hasElements())
                 {
-                    // backward hit, force next word
-                    aNextWordBoundary = xLocalBreakIterator->getWordBoundary(
-                        getText(), getTextPosition() + 1, getLocale(), ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True);
+                    // was indeed split to several words, use as result
+                    return aBroken;
+                }
+                else
+                {
+                    // no split, was already a single word. Continue to
+                    // decompse local entity
                 }
-
-				impCorrectTextBoundary(aNextWordBoundary);
-
-				// prepare new font attributes WITHOUT outline
-                const attribute::FontAttribute aNewFontAttribute(
-                    getFontAttribute().getFamilyName(),
-                    getFontAttribute().getStyleName(),
-                    getFontAttribute().getWeight(),
-                    getFontAttribute().getSymbol(),
-                    getFontAttribute().getVertical(),
-                    getFontAttribute().getItalic(),
-                    false,             // no outline anymore, handled locally
-                    getFontAttribute().getRTL(),
-                    getFontAttribute().getBiDiStrong());
-
-				if(aNextWordBoundary.startPos == getTextPosition() && aNextWordBoundary.endPos == getTextLength())
-				{
-					// it IS only a single word, handle as one word
-	                impCreateGeometryContent(rTarget, rDecTrans, getText(), getTextPosition(), getTextLength(), getDXArray(), aNewFontAttribute);
-				}
-				else
-				{
-					// prepare TextLayouter
-					const bool bNoDXArray(getDXArray().empty());
-					TextLayouterDevice aTextLayouter;
-
-					if(bNoDXArray)
-					{
-						// ..but only completely when no DXArray
-						aTextLayouter.setFontAttribute(
-                            getFontAttribute(), 
-                            rDecTrans.getScale().getX(), 
-                            rDecTrans.getScale().getY(),
-                            getLocale());
-					}
-
-					// do iterate over single words
-					while(aNextWordBoundary.startPos != aNextWordBoundary.endPos)
-					{
-						// prepare values for new portion
-						const xub_StrLen nNewTextStart(static_cast< xub_StrLen >(aNextWordBoundary.startPos));
-						const xub_StrLen nNewTextEnd(static_cast< xub_StrLen >(aNextWordBoundary.endPos));
-
-						// prepare transform for the single word
-						basegfx::B2DHomMatrix aNewTransform;
-						::std::vector< double > aNewDXArray;
-						const bool bNewStartIsNotOldStart(nNewTextStart > getTextPosition());
-
-						if(!bNoDXArray)
-						{
-							// prepare new DXArray for the single word
-							aNewDXArray = ::std::vector< double >(
-								getDXArray().begin() + static_cast< sal_uInt32 >(nNewTextStart - getTextPosition()), 
-								getDXArray().begin() + static_cast< sal_uInt32 >(nNewTextEnd - getTextPosition()));
-						}
-
-						if(bNewStartIsNotOldStart)
-						{
-							// needs to be moved to a new start position
-							double fOffset(0.0);
-							
-							if(bNoDXArray)
-							{
-								// evaluate using TextLayouter
-								fOffset = aTextLayouter.getTextWidth(getText(), getTextPosition(), nNewTextStart);
-							}
-							else
-							{
-								// get from DXArray
-								const sal_uInt32 nIndex(static_cast< sal_uInt32 >(nNewTextStart - getTextPosition()));
-								fOffset = getDXArray()[nIndex - 1];
-							}
-
-                            // need offset without FontScale for building the new transformation. The
-                            // new transformation will be multiplied with the current text transformation
-                            // so FontScale would be double
-							double fOffsetNoScale(fOffset);
-                            const double fFontScaleX(rDecTrans.getScale().getX());
-                            
-                            if(!basegfx::fTools::equal(fFontScaleX, 1.0) 
-                                && !basegfx::fTools::equalZero(fFontScaleX))
-                            {
-                                fOffsetNoScale /= fFontScaleX;
-                            }
-
-							// apply needed offset to transformation
-                            aNewTransform.translate(fOffsetNoScale, 0.0);
-
-							if(!bNoDXArray)
-							{
-								// DXArray values need to be corrected with the offset, too. Here,
-                                // take the scaled offset since the DXArray is scaled
-								const sal_uInt32 nArraySize(aNewDXArray.size());
-
-								for(sal_uInt32 a(0); a < nArraySize; a++)
-								{
-									aNewDXArray[a] -= fOffset;
-								}
-							}
-						}
-
-						// add text transformation to new transformation
-						aNewTransform *= rDecTrans.getB2DHomMatrix();
-
-						// create geometry content for the single word. Do not forget
-						// to use the new transformation
-						basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose aDecTrans(aNewTransform);
-						
-						impCreateGeometryContent(rTarget, aDecTrans, getText(), nNewTextStart, 
-							nNewTextEnd - nNewTextStart, aNewDXArray, aNewFontAttribute);
-
-                        if(aNextWordBoundary.endPos >= getTextPosition() + getTextLength())
-                        {
-                            // end reached
-                            aNextWordBoundary.startPos = aNextWordBoundary.endPos;
-                        }
-                        else
-                        {
-                            // get new word portion
-                            const sal_Int32 nLastEndPos(aNextWordBoundary.endPos);
-
-                            aNextWordBoundary = xLocalBreakIterator->getWordBoundary(
-                                getText(), aNextWordBoundary.endPos, getLocale(), 
-                                ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True);
-
-                            if(nLastEndPos == aNextWordBoundary.endPos)
-                            {
-                                // backward hit, force next word
-                                aNextWordBoundary = xLocalBreakIterator->getWordBoundary(
-                                    getText(), nLastEndPos + 1, getLocale(), 
-                                    ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True);
-                            }
-
-                            impCorrectTextBoundary(aNextWordBoundary);
-                        }
-					}
-				}
             }
-        }
-
-		Primitive2DSequence TextDecoratedPortionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
-        {
             std::vector< Primitive2DReference > aNewPrimitives;
             basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose aDecTrans(getTextTransform());
             Primitive2DSequence aRetval;
 
             // create basic geometry such as SimpleTextPrimitive, Overline, Underline,
             // Strikeout, etc...
-            if(getWordLineMode())
-            {
-                // support for single word mode
-                impSplitSingleWords(aNewPrimitives, aDecTrans);
-            }
-            else
-            {
-                // prepare new font attributes WITHOUT outline
-                const attribute::FontAttribute aNewFontAttribute(
-                    getFontAttribute().getFamilyName(),
-                    getFontAttribute().getStyleName(),
-                    getFontAttribute().getWeight(),
-                    getFontAttribute().getSymbol(),
-                    getFontAttribute().getVertical(),
-                    getFontAttribute().getItalic(),
-                    false,             // no outline anymore, handled locally
-                    getFontAttribute().getRTL(),
-                    getFontAttribute().getBiDiStrong());
+            // prepare new font attributes WITHOUT outline
+            const attribute::FontAttribute aNewFontAttribute(
+                getFontAttribute().getFamilyName(),
+                getFontAttribute().getStyleName(),
+                getFontAttribute().getWeight(),
+                getFontAttribute().getSymbol(),
+                getFontAttribute().getVertical(),
+                getFontAttribute().getItalic(),
+                false,             // no outline anymore, handled locally
+                getFontAttribute().getRTL(),
+                getFontAttribute().getBiDiStrong());
 
-				// handle as one word
-                impCreateGeometryContent(aNewPrimitives, aDecTrans, getText(), getTextPosition(), getTextLength(), getDXArray(), aNewFontAttribute);
-            }
+			// handle as one word
+            impCreateGeometryContent(aNewPrimitives, aDecTrans, getText(), getTextPosition(), getTextLength(), getDXArray(), aNewFontAttribute);
 
             // convert to Primitive2DSequence
             const sal_uInt32 nMemberCount(aNewPrimitives.size());
@@ -542,6 +354,16 @@ namespace drawinglayer
 		{
 		}
 
+        bool TextDecoratedPortionPrimitive2D::decoratedIsNeeded() const
+        {
+            return (TEXT_LINE_NONE != getFontOverline()
+                 || TEXT_LINE_NONE != getFontUnderline()
+                 || TEXT_STRIKEOUT_NONE != getTextStrikeout()
+                 || TEXT_EMPHASISMARK_NONE != getTextEmphasisMark()
+                 || TEXT_RELIEF_NONE != getTextRelief()
+                 || getShadow());
+        }
+
 		bool TextDecoratedPortionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
 		{
 			if(TextSimplePortionPrimitive2D::operator==(rPrimitive))
@@ -570,15 +392,7 @@ namespace drawinglayer
         // inking area, so add them if needed
 		basegfx::B2DRange TextDecoratedPortionPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
 		{
-			const bool bDecoratedIsNeeded(
-                TEXT_LINE_NONE != getFontOverline()
-             || TEXT_LINE_NONE != getFontUnderline()
-             || TEXT_STRIKEOUT_NONE != getTextStrikeout()
-             || TEXT_EMPHASISMARK_NONE != getTextEmphasisMark()
-             || TEXT_RELIEF_NONE != getTextRelief()
-             || getShadow());
-
-            if(bDecoratedIsNeeded)
+            if(decoratedIsNeeded())
             {
                 // decoration is used, fallback to BufferedDecompositionPrimitive2D::getB2DRange which uses
                 // the own local decomposition for computation and thus creates all necessary

Modified: incubator/ooo/trunk/main/svgio/source/svgreader/svgcharacternode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/source/svgreader/svgcharacternode.cxx?rev=1236110&r1=1236109&r2=1236110&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/source/svgreader/svgcharacternode.cxx (original)
+++ incubator/ooo/trunk/main/svgio/source/svgreader/svgcharacternode.cxx Thu Jan 26 09:16:51 2012
@@ -177,9 +177,9 @@ namespace svgio
 
         public:
             localTextBreakupHelper(
-                const drawinglayer::primitive2d::Primitive2DReference& rxSource, 
+                const drawinglayer::primitive2d::TextSimplePortionPrimitive2D& rSource, 
                 SvgTextPosition& rSvgTextPosition)
-            :   drawinglayer::primitive2d::TextBreakupHelper(rxSource),
+            :   drawinglayer::primitive2d::TextBreakupHelper(rSource),
                 mrSvgTextPosition(rSvgTextPosition)
             {
             }
@@ -486,17 +486,27 @@ namespace svgio
                 else
                 {
                     // need to apply rotations to each character as given
-                    localTextBreakupHelper alocalTextBreakupHelper(xRef, rSvgTextPosition);
-                    const drawinglayer::primitive2d::Primitive2DSequence aResult(
-                        alocalTextBreakupHelper.getResult(drawinglayer::primitive2d::BreakupUnit_character));
+                    const drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pCandidate = 
+                        dynamic_cast< const drawinglayer::primitive2d::TextSimplePortionPrimitive2D* >(xRef.get());
 
-                    if(aResult.hasElements())
+                    if(pCandidate)
                     {
-                        drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aResult);
-                    }
+                        const localTextBreakupHelper alocalTextBreakupHelper(*pCandidate, rSvgTextPosition);
+                        const drawinglayer::primitive2d::Primitive2DSequence aResult(
+                            alocalTextBreakupHelper.getResult(drawinglayer::primitive2d::BreakupUnit_character));
+
+                        if(aResult.hasElements())
+                        {
+                            drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aResult);
+                        }
 
-                    // also consume for the implied single space
-                    rSvgTextPosition.consumeRotation();
+                        // also consume for the implied single space
+                        rSvgTextPosition.consumeRotation();
+                    }
+                    else
+                    {
+                        OSL_ENSURE(false, "Used primitive is not a text primitive (!)");
+                    }
                 }
             }
         }

Modified: incubator/ooo/trunk/main/svgio/source/svgreader/svgtextpathnode.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svgio/source/svgreader/svgtextpathnode.cxx?rev=1236110&r1=1236109&r2=1236110&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svgio/source/svgreader/svgtextpathnode.cxx (original)
+++ incubator/ooo/trunk/main/svgio/source/svgreader/svgtextpathnode.cxx Thu Jan 26 09:16:51 2012
@@ -67,7 +67,7 @@ namespace svgio
 
         public:
             pathTextBreakupHelper(
-                const drawinglayer::primitive2d::Primitive2DReference& rxSource,
+                const drawinglayer::primitive2d::TextSimplePortionPrimitive2D& rSource,
                 const basegfx::B2DPolygon& rPolygon,
                 const double fBasegfxPathLength,
                 const double fUserToBasegfx,
@@ -135,13 +135,13 @@ namespace svgio
         }
 
         pathTextBreakupHelper::pathTextBreakupHelper(
-            const drawinglayer::primitive2d::Primitive2DReference& rxSource,
+            const drawinglayer::primitive2d::TextSimplePortionPrimitive2D& rSource,
             const basegfx::B2DPolygon& rPolygon,
             const double fBasegfxPathLength,
             const double fUserToBasegfx,
             double fPosition,
             const basegfx::B2DPoint& rTextStart)
-        :   drawinglayer::primitive2d::TextBreakupHelper(rxSource),
+        :   drawinglayer::primitive2d::TextBreakupHelper(rSource),
             mrPolygon(rPolygon),
             mfBasegfxPathLength(fBasegfxPathLength),
             mfUserToBasegfx(fUserToBasegfx),
@@ -169,17 +169,17 @@ namespace svgio
         {
             bool bRetval(false);
 
-            if(mfPosition < mfBasegfxPathLength && nLength && getCastedSource() && mnIndex < mnMaxIndex)
+            if(mfPosition < mfBasegfxPathLength && nLength && mnIndex < mnMaxIndex)
             {
                 const double fSnippetWidth(
                     getTextLayouter().getTextWidth(
-                        getCastedSource()->getText(),
+                        getSource().getText(),
                         nIndex,
                         nLength));
 
                 if(basegfx::fTools::more(fSnippetWidth, 0.0))
                 {
-                    const ::rtl::OUString aText(getCastedSource()->getText());
+                    const ::rtl::OUString aText(getSource().getText());
                     const ::rtl::OUString aTrimmedChars(aText.copy(nIndex, nLength).trim());
                     const double fEndPos(mfPosition + fSnippetWidth);
 
@@ -478,8 +478,8 @@ namespace svgio
 
                                     if(pCandidate)
                                     {
-                                        pathTextBreakupHelper aPathTextBreakupHelper(
-                                            xReference,
+                                        const pathTextBreakupHelper aPathTextBreakupHelper(
+                                            *pCandidate,
                                             aPolygon,
                                             fBasegfxPathLength,
                                             fUserToBasegfx,