diff options
author | Armin Weiss <aw@openoffice.org> | 2007-10-02 15:55:00 +0000 |
---|---|---|
committer | Armin Weiss <aw@openoffice.org> | 2007-10-02 15:55:00 +0000 |
commit | 941811c2fb8ea4ff64e866863ecb39bbbdc48160 (patch) | |
tree | 5c0dcf2024c32f56c00e365b222167a4b50d273f /drawinglayer | |
parent | 6e633ad0a710a4e4a3c68f87c462b32ccc6d4fe2 (diff) |
#i39532# RTL and BiDi support
Diffstat (limited to 'drawinglayer')
6 files changed, 137 insertions, 44 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx index 0a73de3b6187..0d0775f6a4c6 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: textprimitive2d.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: aw $ $Date: 2007-10-01 09:13:53 $ + * last change: $Author: aw $ $Date: 2007-10-02 16:54:52 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -72,15 +72,17 @@ namespace drawinglayer { private: // core data - String maFamilyName; - String maStyleName; - sal_uInt16 mnWeight; + String maFamilyName; // Font Family Name + String maStyleName; // Font Style Name + sal_uInt16 mnWeight; // Font weight // bitfield - unsigned mbSymbol : 1; - unsigned mbVertical : 1; - unsigned mbItalic : 1; - unsigned mbOutline : 1; + unsigned mbSymbol : 1; // Symbol Font Flag + unsigned mbVertical : 1; // Vertical Text Flag + unsigned mbItalic : 1; // Italic Flag + unsigned mbOutline : 1; // Outline Flag + unsigned mbRTL : 1; // RTL Flag + unsigned mbBiDiStrong : 1; // BiDi Flag // TODO: pair kerning and CJK kerning public: @@ -91,14 +93,18 @@ namespace drawinglayer bool bSymbol = false, bool bVertical = false, bool bItalic = false, - bool bOutline = false) + bool bOutline = false, + bool bRTL = false, + bool bBiDiStrong = false) : maFamilyName(rFamilyName), maStyleName(rStyleName), mnWeight(nWeight), mbSymbol(bSymbol), mbVertical(bVertical), mbItalic(bItalic), - mbOutline(bOutline) + mbOutline(bOutline), + mbRTL(bRTL), + mbBiDiStrong(bBiDiStrong) { } @@ -113,12 +119,14 @@ namespace drawinglayer bool getVertical() const { return mbVertical; } bool getItalic() const { return mbItalic; } bool getOutline() const { return mbOutline; } + bool getRTL() const { return mbRTL; } + bool getBiDiStrong() const { return mbBiDiStrong; } }; // helper methods for vcl font Font getVclFontFromFontAttributes(const FontAttributes& rFontAttributes, const basegfx::B2DVector& rFontSize, double fFontRotation); Font getVclFontFromFontAttributes(const FontAttributes& rFontAttributes, const basegfx::B2DHomMatrix& rTransform); - FontAttributes getFontAttributesFromVclFont(basegfx::B2DVector& rSize, const Font& rFont); + FontAttributes getFontAttributesFromVclFont(basegfx::B2DVector& rSize, const Font& rFont, bool bRTL, bool bBiDiStrong); } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx index e80c28a248ca..df0128b1928b 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx @@ -4,9 +4,9 @@ * * $RCSfile: vclmetafileprocessor2d.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: aw $ $Date: 2007-08-06 14:14:46 $ + * last change: $Author: aw $ $Date: 2007-10-02 16:54:53 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -79,8 +79,13 @@ namespace drawinglayer { private: // local helper(s) - Rectangle impDumpToMetaFile(const primitive2d::Primitive2DSequence& rContent, GDIMetaFile& o_rContentMetafile); - void impConvertFillGradientAttributeToVCLGradient(Gradient& o_rVCLGradient, const attribute::FillGradientAttribute& rFiGrAtt); + Rectangle impDumpToMetaFile( + const primitive2d::Primitive2DSequence& rContent, + GDIMetaFile& o_rContentMetafile); + void impConvertFillGradientAttributeToVCLGradient( + Gradient& o_rVCLGradient, + const attribute::FillGradientAttribute& rFiGrAtt, + bool bIsTransparenceGradient); void impStartSvtGraphicFill(SvtGraphicFill* pSvtGraphicFill); void impEndSvtGraphicFill(SvtGraphicFill* pSvtGraphicFill); SvtGraphicStroke* impTryToCreateSvtGraphicStroke( diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx index 278023d67f56..c2217c8af279 100644 --- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: textdecoratedprimitive2d.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: aw $ $Date: 2007-10-01 09:14:08 $ + * last change: $Author: aw $ $Date: 2007-10-02 16:55:00 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -129,7 +129,7 @@ namespace drawinglayer // is needed basegfx::B2DHomMatrix aUnrotatedTransform(rDecTrans.getB2DHomMatrix()); aUnrotatedTransform.rotate(-rDecTrans.getRotate()); - aTextLayouter.setFontAttributes(getFontAttributes(), aUnrotatedTransform ); + aTextLayouter.setFontAttributes(getFontAttributes(), aUnrotatedTransform); // get text width double fTextWidth(0.0); @@ -515,7 +515,9 @@ namespace drawinglayer getFontAttributes().getSymbol(), getFontAttributes().getVertical(), getFontAttributes().getItalic(), - false); // no outline anymore, handled locally + false, // no outline anymore, handled locally + getFontAttributes().getRTL(), + getFontAttributes().getBiDiStrong()); if(aNextWordBoundary.startPos == getTextPosition() && aNextWordBoundary.endPos == getTextLength()) { @@ -600,7 +602,9 @@ namespace drawinglayer getFontAttributes().getSymbol(), getFontAttributes().getVertical(), getFontAttributes().getItalic(), - false); // no outline anymore, handled locally + false, // no outline anymore, handled locally + getFontAttributes().getRTL(), + getFontAttributes().getBiDiStrong()); // handle as one word impCreateGeometryContent(aNewPrimitives, aDecTrans, getText(), getTextPosition(), getTextLength(), getDXArray(), aNewFontAttributes); diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx b/drawinglayer/source/primitive2d/textprimitive2d.cxx index c659b5e7bc59..d11a75ac5116 100644 --- a/drawinglayer/source/primitive2d/textprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: textprimitive2d.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: aw $ $Date: 2007-10-01 09:14:08 $ + * last change: $Author: aw $ $Date: 2007-10-02 16:55:00 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -71,7 +71,9 @@ namespace drawinglayer && getSymbol() == rCompare.getSymbol() && getVertical() == rCompare.getVertical() && getItalic() == rCompare.getItalic() - && getOutline() == rCompare.getOutline()); + && getOutline() == rCompare.getOutline() + && getRTL() == rCompare.getRTL() + && getBiDiStrong() == rCompare.getBiDiStrong()); } } // end of namespace primitive2d } // end of namespace drawinglayer @@ -122,7 +124,7 @@ namespace drawinglayer return aRetval; } - FontAttributes getFontAttributesFromVclFont(basegfx::B2DVector& rSize, const Font& rFont) + FontAttributes getFontAttributesFromVclFont(basegfx::B2DVector& rSize, const Font& rFont, bool bRTL, bool bBiDiStrong) { FontAttributes aRetval( rFont.GetName(), @@ -131,7 +133,9 @@ namespace drawinglayer RTL_TEXTENCODING_SYMBOL == rFont.GetCharSet(), rFont.IsVertical(), ITALIC_NONE != rFont.GetItalic(), - rFont.IsOutline()); + rFont.IsOutline(), + bRTL, + bBiDiStrong); // TODO: eKerning const sal_Int32 nWidth(rFont.GetSize().getWidth()); diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index b99c3670354c..5f01e6eff401 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclmetafileprocessor2d.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: aw $ $Date: 2007-09-27 15:59:41 $ + * last change: $Author: aw $ $Date: 2007-10-02 16:55:00 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -190,11 +190,17 @@ namespace drawinglayer { namespace processor2d { - Rectangle VclMetafileProcessor2D::impDumpToMetaFile(const primitive2d::Primitive2DSequence& rContent, GDIMetaFile& o_rContentMetafile) + Rectangle VclMetafileProcessor2D::impDumpToMetaFile( + const primitive2d::Primitive2DSequence& rContent, + GDIMetaFile& o_rContentMetafile) { // Prepare VDev, MetaFile and connections OutputDevice* pLastOutputDevice = mpOutputDevice; - const basegfx::B2DRange aPrimitiveRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rContent, getViewInformation2D())); + basegfx::B2DRange aPrimitiveRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rContent, getViewInformation2D())); + + // transform primitive range with current transformation (e.g shadow offset) + aPrimitiveRange.transform(maCurrentTransformation); + const Rectangle aPrimitiveRectangle( basegfx::fround(aPrimitiveRange.getMinX()), basegfx::fround(aPrimitiveRange.getMinY()), basegfx::fround(aPrimitiveRange.getMaxX()), basegfx::fround(aPrimitiveRange.getMaxY())); @@ -226,10 +232,24 @@ namespace drawinglayer return aPrimitiveRectangle; } - void VclMetafileProcessor2D::impConvertFillGradientAttributeToVCLGradient(Gradient& o_rVCLGradient, const attribute::FillGradientAttribute& rFiGrAtt) + void VclMetafileProcessor2D::impConvertFillGradientAttributeToVCLGradient( + Gradient& o_rVCLGradient, + const attribute::FillGradientAttribute& rFiGrAtt, + bool bIsTransparenceGradient) { - o_rVCLGradient.SetStartColor(Color(maBColorModifierStack.getModifiedColor(rFiGrAtt.getStartColor()))); - o_rVCLGradient.SetEndColor(Color(maBColorModifierStack.getModifiedColor(rFiGrAtt.getEndColor()))); + if(bIsTransparenceGradient) + { + // it's about alpha channel intensities (black/white), do not use color modifier + o_rVCLGradient.SetStartColor(Color(rFiGrAtt.getStartColor())); + o_rVCLGradient.SetEndColor(Color(rFiGrAtt.getEndColor())); + } + else + { + // use color modifier to influence start/end color of gradient + o_rVCLGradient.SetStartColor(Color(maBColorModifierStack.getModifiedColor(rFiGrAtt.getStartColor()))); + o_rVCLGradient.SetEndColor(Color(maBColorModifierStack.getModifiedColor(rFiGrAtt.getEndColor()))); + } + o_rVCLGradient.SetAngle(static_cast< sal_uInt16 >(rFiGrAtt.getAngle() * (1.0 / F_PI1800))); o_rVCLGradient.SetBorder(static_cast< sal_uInt16 >(rFiGrAtt.getBorder() * 100.0)); o_rVCLGradient.SetOfsX(static_cast< sal_uInt16 >(rFiGrAtt.getOffsetX() * 100.0)); @@ -1146,10 +1166,16 @@ namespace drawinglayer // it is safest to use the VCL OutputDevice::DrawGradient method which creates those. // re-create a VCL-gradient from FillGradientPrimitive2D and the needed tools PolyPolygon Gradient aVCLGradient; - impConvertFillGradientAttributeToVCLGradient(aVCLGradient, rGradientCandidate.getFillGradient()); + impConvertFillGradientAttributeToVCLGradient(aVCLGradient, rGradientCandidate.getFillGradient(), false); basegfx::B2DPolyPolygon aLocalPolyPolygon(rGradientCandidate.getB2DPolyPolygon()); aLocalPolyPolygon.transform(maCurrentTransformation); - const PolyPolygon aToolsPolyPolygon(aLocalPolyPolygon); + + // #i82145# ATM VCL printing of gradients using curved shapes does not work, + // i submitted the bug with the given ID to THB. When that task is fixed it is + // necessary to again remove this subdivision since it decreases possible + // printing quality (not even resolution-dependent for now). THB will tell + // me when that task is fixed in the master + const PolyPolygon aToolsPolyPolygon(basegfx::tools::adaptiveSubdivideByAngle(aLocalPolyPolygon)); // XPATHFILL_SEQ_BEGIN/XPATHFILL_SEQ_END support SvtGraphicFill* pSvtGraphicFill = 0; @@ -1324,7 +1350,10 @@ namespace drawinglayer pPoPoColor = dynamic_cast< const primitive2d::PolyPolygonColorPrimitive2D* >(xReference.get()); } - if(pPoPoColor) + // PolyPolygonGradientPrimitive2D, PolyPolygonHatchPrimitive2D and + // PolyPolygonBitmapPrimitive2D are derived from PolyPolygonColorPrimitive2D. + // Check also for correct ID to exclude derived implementations + if(pPoPoColor && PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D == pPoPoColor->getPrimitiveID()) { // single transparent PolyPolygon identified, use directly const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(pPoPoColor->getBColor())); @@ -1397,7 +1426,8 @@ namespace drawinglayer // render it to VCL mpOutputDevice->DrawTransparent( - aContentMetafile, aPrimitiveRectangle.TopLeft(), aPrimitiveRectangle.GetSize(), aVCLGradient); + aContentMetafile, aPrimitiveRectangle.TopLeft(), + aPrimitiveRectangle.GetSize(), aVCLGradient); } } @@ -1428,7 +1458,8 @@ namespace drawinglayer pFiGradient = dynamic_cast< const primitive2d::FillGradientPrimitive2D* >(xReference.get()); } - if(pFiGradient) + // Check also for correct ID to exclude derived implementations + if(pFiGradient && PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D == pFiGradient->getPrimitiveID()) { // various content, create content-metafile GDIMetaFile aContentMetafile; @@ -1436,11 +1467,12 @@ namespace drawinglayer // re-create a VCL-gradient from FillGradientPrimitive2D Gradient aVCLGradient; - impConvertFillGradientAttributeToVCLGradient(aVCLGradient, pFiGradient->getFillGradient()); + impConvertFillGradientAttributeToVCLGradient(aVCLGradient, pFiGradient->getFillGradient(), true); // render it to VCL mpOutputDevice->DrawTransparent( - aContentMetafile, aPrimitiveRectangle.TopLeft(), aPrimitiveRectangle.GetSize(), aVCLGradient); + aContentMetafile, aPrimitiveRectangle.TopLeft(), + aPrimitiveRectangle.GetSize(), aVCLGradient); } else { diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 743d37b6348f..08fd30c1d82d 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -4,9 +4,9 @@ * * $RCSfile: vclprocessor2d.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: aw $ $Date: 2007-10-01 09:14:08 $ + * last change: $Author: aw $ $Date: 2007-10-02 16:55:00 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -137,6 +137,14 @@ #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx> #endif +#ifndef _SVTOOLS_CTLOPTIONS_HXX +#include <svtools/ctloptions.hxx> +#endif + +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif + ////////////////////////////////////////////////////////////////////////////// using namespace com::sun::star; @@ -283,8 +291,6 @@ namespace drawinglayer aFont.SetShadow( true ); } - mpOutputDevice->SetFont(aFont); - // create transformed integer DXArray in view coordinate system ::std::vector< sal_Int32 > aTransformedDXArray; @@ -304,8 +310,18 @@ namespace drawinglayer const basegfx::BColor aRGBFontColor(maBColorModifierStack.getModifiedColor(rTextCandidate.getFontColor())); const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0)); const Point aStartPoint(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())); + const sal_uInt32 nOldLayoutMode(mpOutputDevice->GetLayoutMode()); + if(rTextCandidate.getFontAttributes().getRTL()) + { + sal_uInt32 nRTLLayoutMode(nOldLayoutMode & ~(TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG)); + nRTLLayoutMode |= TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_TEXTORIGIN_LEFT; + mpOutputDevice->SetLayoutMode(nRTLLayoutMode); + } + + mpOutputDevice->SetFont(aFont); mpOutputDevice->SetTextColor(Color(aRGBFontColor)); + mpOutputDevice->DrawTextArray( aStartPoint, rTextCandidate.getText(), @@ -313,6 +329,11 @@ namespace drawinglayer rTextCandidate.getTextPosition(), rTextCandidate.getTextLength()); + if(rTextCandidate.getFontAttributes().getRTL()) + { + mpOutputDevice->SetLayoutMode(nOldLayoutMode); + } + bPrimitiveAccepted = true; } } @@ -910,6 +931,25 @@ namespace drawinglayer maBColorModifierStack(), maCurrentTransformation() { + // set digit language, derived from SvtCTLOptions to have the correct + // number display for arabic/hindi numerals + const SvtCTLOptions aSvtCTLOptions; + LanguageType eLang(LANGUAGE_SYSTEM); + + if(SvtCTLOptions::NUMERALS_HINDI == aSvtCTLOptions.GetCTLTextNumerals()) + { + eLang = LANGUAGE_ARABIC; + } + else if(SvtCTLOptions::NUMERALS_ARABIC == aSvtCTLOptions.GetCTLTextNumerals()) + { + eLang = LANGUAGE_ENGLISH; + } + else + { + eLang = (LanguageType)Application::GetSettings().GetLanguage(); + } + + rOutDev.SetDigitLanguage(eLang); } VclProcessor2D::~VclProcessor2D() |