diff options
55 files changed, 881 insertions, 399 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 9e3e322a3ac4..d9d784f56b41 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -89,18 +89,19 @@ #define PRIMITIVE2D_ID_TEXTHIERARCHYLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 38) #define PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 39) #define PRIMITIVE2D_ID_TEXTHIERARCHYBLOCKPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 40) -#define PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 41) -#define PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 42) -#define PRIMITIVE2D_ID_TEXTEFFECTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 43) -#define PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 44) -#define PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 45) -#define PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 46) -#define PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 47) -#define PRIMITIVE2D_ID_CHARTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 48) -#define PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 49) -#define PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 50) -#define PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 51) -#define PRIMITIVE2D_ID_HITTESTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 51) +#define PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 41) +#define PRIMITIVE2D_ID_POLYGONWAVEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 42) +#define PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 43) +#define PRIMITIVE2D_ID_TEXTEFFECTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 44) +#define PRIMITIVE2D_ID_TEXTHIERARCHYBULLETPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 45) +#define PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 46) +#define PRIMITIVE2D_ID_EXECUTEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 47) +#define PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 48) +#define PRIMITIVE2D_ID_CHARTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 49) +#define PRIMITIVE2D_ID_STRUCTURETAGRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 50) +#define PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 51) +#define PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 52) +#define PRIMITIVE2D_ID_HITTESTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 53) ////////////////////////////////////////////////////////////////////////////// diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx index 4a7b300ecfb1..69023873760a 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx @@ -198,6 +198,9 @@ namespace drawinglayer // compare operator virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; + // get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + // provide unique ID DeclPrimitrive2DIDBlock() }; diff --git a/drawinglayer/inc/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx index dd707c0f7d71..1160704c0fa3 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx @@ -164,6 +164,31 @@ namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// +namespace drawinglayer +{ + namespace primitive2d + { + // #i97628# + // Primitive to encapsulate text from an active text edit; some + // renderers need to suppress this output due to painting the + // edited text in e.g. an OutlinerEditView. It's derived from + // GroupPrimitive2D, so the implicit decomposition will use the + // content. To suppress, this primitive needs to be parsed by + // the renderer without taking any action + class TextHierarchyEditPrimitive2D : public GroupPrimitive2D + { + private: + public: + TextHierarchyEditPrimitive2D(const Primitive2DSequence& rChildren); + + // provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTHIERARCHYPRIMITIVE2D_HXX ////////////////////////////////////////////////////////////////////////////// diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index 82c7f4824af4..e29b413190ab 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -96,7 +96,7 @@ namespace drawinglayer // common VCL rendering support void RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); - void RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate); + void RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased); void RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); void RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate); void RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate); diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx index 14352c4a8595..4faa85fe898c 100644 --- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx @@ -186,7 +186,7 @@ namespace drawinglayer if(bWaveLine) { eLineJoin = basegfx::B2DLINEJOIN_ROUND; - fLineHeight *= 0.5; + fLineHeight *= 0.25; } // prepare Line and Stroke Attributes @@ -215,7 +215,7 @@ namespace drawinglayer if(bWaveLine) { - double fWaveWidth(4.0 * fLineHeight); + double fWaveWidth(10.6 * fLineHeight); if(FONT_UNDERLINE_SMALLWAVE == eLineStyle) { @@ -227,7 +227,7 @@ namespace drawinglayer fWaveWidth *= 2.0; } - aNewPrimitive = Primitive2DReference(new PolygonWavePrimitive2D(aLine, aLineAttribute, aStrokeAttribute, fWaveWidth, 0.5 * fWaveWidth)); + aNewPrimitive = Primitive2DReference(new PolygonWavePrimitive2D(aLine, aLineAttribute, aStrokeAttribute, fWaveWidth, fWaveWidth * 0.5)); } else { @@ -241,7 +241,13 @@ namespace drawinglayer { // double line, create 2nd primitive with offset using TransformPrimitive based on // already created NewPrimitive - const double fLineDist((bWaveLine ? 3.0 : 2.0) * fLineHeight); + double fLineDist(2.3 * fLineHeight); + + if(bWaveLine) + { + fLineDist = 6.3 * fLineHeight; + } + basegfx::B2DHomMatrix aTransform; // move base point of text to 0.0 and de-rotate @@ -482,6 +488,16 @@ namespace drawinglayer // 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)); + + if(aNextWordBoundary.endPos == getTextPosition() && getTextLength() > 0) + { + // #i96474# + // a word before was found (this can happen when search starts on a whitespace and a word + // in front of it exists), force to look one position further + aNextWordBoundary = xLocalBreakIterator->getWordBoundary( + getText(), getTextPosition() + 1, getLocale(), ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, sal_True); + } + impCorrectTextBoundary(aNextWordBoundary); // prepare new font attributes WITHOUT outline @@ -791,6 +807,33 @@ namespace drawinglayer return false; } + // #i96475# + // Added missing implementation. Decorations may (will) stick out of the text's + // inking area, so add them if needed + basegfx::B2DRange TextDecoratedPortionPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const + { + const bool bDecoratedIsNeeded( + FONT_UNDERLINE_NONE != getFontOverline() + || FONT_UNDERLINE_NONE != getFontUnderline() + || FONT_STRIKEOUT_NONE != getFontStrikeout() + || FONT_EMPHASISMARK_NONE != getFontEmphasisMark() + || FONT_RELIEF_NONE != getFontRelief() + || getShadow()); + + if(bDecoratedIsNeeded) + { + // decoration is used, fallback to BasePrimitive2D::getB2DRange which uses + // the own local decomposition for computation and thus creates all necessary + // geometric objects + return BasePrimitive2D::getB2DRange(rViewInformation); + } + else + { + // no relevant decoration used, fallback to TextSimplePortionPrimitive2D::getB2DRange + return TextSimplePortionPrimitive2D::getB2DRange(rViewInformation); + } + } + // provide unique ID ImplPrimitrive2DIDBlock(TextDecoratedPortionPrimitive2D, PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D) diff --git a/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx b/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx index 7148a004a595..72249e673c1b 100644 --- a/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx @@ -146,4 +146,21 @@ namespace drawinglayer } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + TextHierarchyEditPrimitive2D::TextHierarchyEditPrimitive2D(const Primitive2DSequence& rChildren) + : GroupPrimitive2D(rChildren) + { + } + + // provide unique ID + ImplPrimitrive2DIDBlock(TextHierarchyEditPrimitive2D, PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// // eof diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index bc7e659a8996..dc5589200c15 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -73,6 +73,7 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> #include <helperchartrenderer.hxx> +#include <drawinglayer/primitive2d/hittestprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// // for PDFExtOutDevData Graphic support @@ -983,7 +984,7 @@ namespace drawinglayer SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke(rHairlinePrimitive.getB2DPolygon(), &aLineColor, 0, 0, 0, 0); impStartSvtGraphicStroke(pSvtGraphicStroke); - RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate)); + RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate), false); impEndSvtGraphicStroke(pSvtGraphicStroke); break; } @@ -1652,6 +1653,27 @@ namespace drawinglayer break; } + case PRIMITIVE2D_ID_HITTESTPRIMITIVE2D : + { + // #i99123# + // invisible primitive; to rebuilt the old MetaFile creation, it is necessary to + // not ignore them (as it was thought), but to add a MetaFile entry for them. + basegfx::B2DRange aInvisibleRange(rCandidate.getB2DRange(getViewInformation2D())); + + if(!aInvisibleRange.isEmpty()) + { + aInvisibleRange.transform(maCurrentTransformation); + const Rectangle aRectLogic( + (sal_Int32)floor(aInvisibleRange.getMinX()), (sal_Int32)floor(aInvisibleRange.getMinY()), + (sal_Int32)ceil(aInvisibleRange.getMaxX()), (sal_Int32)ceil(aInvisibleRange.getMaxY())); + + mpOutputDevice->SetFillColor(); + mpOutputDevice->SetLineColor(); + mpOutputDevice->DrawRect(aRectLogic); + } + + break; + } default : { // process recursively diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 70cb4dcb4b43..b1d508795cac 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -65,6 +65,7 @@ #include <tools/diagnose_ex.h> #include <com/sun/star/awt/PosSize.hpp> #include <cstdio> +#include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -139,13 +140,13 @@ namespace drawinglayer case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D : { // directdraw of text simple portion; added test possibility to check text decompose - static bool bHandleSimpleTextDirectly(true); + static bool bForceSimpleTextDecomposition(false); // Adapt evtl. used special DrawMode const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); adaptTextToFillDrawMode(); - if(bHandleSimpleTextDirectly) + if(!bForceSimpleTextDecomposition && getOptionsDrawinglayer().IsRenderSimpleTextDirect()) { RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate)); } @@ -162,13 +163,13 @@ namespace drawinglayer case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D : { // directdraw of text simple portion; added test possibility to check text decompose - static bool bHandleComplexTextDirectly(false); + static bool bForceComplexTextDecomposition(false); // Adapt evtl. used special DrawMode const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); adaptTextToFillDrawMode(); - if(bHandleComplexTextDirectly) + if(!bForceComplexTextDecomposition && getOptionsDrawinglayer().IsRenderDecoratedTextDirect()) { RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate)); } @@ -185,7 +186,7 @@ namespace drawinglayer case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D : { // direct draw of hairline - RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate)); + RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate), true); break; } case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D : @@ -224,8 +225,23 @@ namespace drawinglayer } case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D : { + // #i98289# + const bool bForceLineSnap(getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete()); + const sal_uInt16 nOldAntiAliase(mpOutputDevice->GetAntialiasing()); + + if(bForceLineSnap) + { + mpOutputDevice->SetAntialiasing(nOldAntiAliase | ANTIALIASING_PIXELSNAPHAIRLINE); + } + // direct draw of MetaFile RenderMetafilePrimitive2D(static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate)); + + if(bForceLineSnap) + { + mpOutputDevice->SetAntialiasing(nOldAntiAliase); + } + break; } case PRIMITIVE2D_ID_MASKPRIMITIVE2D : @@ -479,6 +495,43 @@ namespace drawinglayer } break; } + case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D : + { + // #i98404# Handle directly, especially when AA is active + const primitive2d::BackgroundColorPrimitive2D& rPrimitive = static_cast< const primitive2d::BackgroundColorPrimitive2D& >(rCandidate); + const sal_uInt16 nOriginalAA(mpOutputDevice->GetAntialiasing()); + + // switch AA off in all cases + mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW); + + // create color for fill + const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor())); + mpOutputDevice->SetFillColor(Color(aPolygonColor)); + mpOutputDevice->SetLineColor(); + + // create rectangle for fill + const basegfx::B2DRange& aViewport(getViewInformation2D().getDiscreteViewport()); + const Rectangle aRectangle( + (sal_Int32)floor(aViewport.getMinX()), (sal_Int32)floor(aViewport.getMinY()), + (sal_Int32)ceil(aViewport.getMaxX()), (sal_Int32)ceil(aViewport.getMaxY())); + mpOutputDevice->DrawRect(aRectangle); + + // restore AA setting + mpOutputDevice->SetAntialiasing(nOriginalAA); + + break; + } + case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D : + { + // #i97628# + // This primitive means that the content is derived from an active text edit, + // not from model data itself. Some renderers need to suppress this content, e.g. + // the pixel renderer used for displaying the edit view (like this one). It's + // not to be suppressed by the MetaFile renderers, so that the edited text is + // part of the MetaFile, e.g. needed for presentation previews. + // Action: Ignore here, do nothing. + break; + } default : { // process recursively diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index be30e9fe6e77..b8a21767b839 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -66,6 +66,7 @@ #include <vcl/svapp.hxx> #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> #include <tools/diagnose_ex.h> +#include <vcl/metric.hxx> ////////////////////////////////////////////////////////////////////////////// // control support @@ -158,9 +159,42 @@ namespace drawinglayer if(basegfx::fTools::more(aScale.getX(), 0.0) && basegfx::fTools::more(aScale.getY(), 0.0)) { - // prepare everything that is not sheared and mirrored + // #i96581# Get the font forced without FontStretching (use FontHeight as FontWidth) Font aFont(primitive2d::getVclFontFromFontAttributes( - rTextCandidate.getFontAttributes(), aScale.getX(), aScale.getY(), fRotate, *mpOutputDevice)); + rTextCandidate.getFontAttributes(), + aScale.getY(), + aScale.getY(), + fRotate, + *mpOutputDevice)); + + if(!basegfx::fTools::equal(aScale.getX(), aScale.getY())) + { + // #i96581# font stretching is needed; examine how big the difference between X and Y scaling is + const double fPercent(fabs(1.0 - (aScale.getX() / aScale.getY()))); + static double fMaximumAcceptedPercent(0.05); + static bool bForceAdaption(false); + + if(bForceAdaption || fPercent > fMaximumAcceptedPercent) + { + // #i96581# Need to adapt to a FontStretching bigger than acceptable maximum. + // Get font's real width using FontMetric and adapt font to stretched + // font + const FontMetric aFontMetric(mpOutputDevice->GetFontMetric(aFont)); + const double fRealFontWidth(aFontMetric.GetWidth()); + + aFont = primitive2d::getVclFontFromFontAttributes( + rTextCandidate.getFontAttributes(), + fRealFontWidth, + aScale.getY(), + fRotate, + *mpOutputDevice); + } + else + { + // #i96581# less than allowed maximum (probably SC's generated MapModes). React + // pragmatically by ignoring the stretching up to this point + } + } // handle additional font attributes const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP = @@ -317,7 +351,7 @@ namespace drawinglayer } // direct draw of hairline - void VclProcessor2D::RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate) + void VclProcessor2D::RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased) { const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); mpOutputDevice->SetLineColor(Color(aHairlineColor)); @@ -325,6 +359,17 @@ namespace drawinglayer basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon()); aLocalPolygon.transform(maCurrentTransformation); + + if(bPixelBased && getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete()) + { + // #i98289# + // when a Hairline is painted and AntiAliasing is on the option SnapHorVerLinesToDiscrete + // allows to suppress AntiAliasing for pure horizontal or vertical lines. This is done since + // not-AntiAliased such lines look more pleasing to the eye (e.g. 2D chart content). This + // NEEDS to be done in discrete coordinates, so only useful for pixel based rendering. + aLocalPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aLocalPolygon); + } + mpOutputDevice->DrawPolyLine(aLocalPolygon, 0.0); } @@ -623,6 +668,8 @@ namespace drawinglayer // units e.g. when creating a new MetaFile, but since much huger value ranges are used // there typically will be okay for this compromize. Rectangle aDestRectView( + // !!CAUTION!! Here, ceil and floor are exchanged BY PURPOSE, do NOT copy when + // looking for a standard conversion to rectangle (!) (sal_Int32)ceil(aOutlineRange.getMinX()), (sal_Int32)ceil(aOutlineRange.getMinY()), (sal_Int32)floor(aOutlineRange.getMaxX()), (sal_Int32)floor(aOutlineRange.getMaxY())); diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index de0159bb9f28..5379ddaea0f5 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -1106,6 +1106,46 @@ Dymamic border coloring means that when the mouse is hovered over a control, and </info> <value>true</value> </prop> + <prop oor:name="SnapHorVerLinesToDiscrete" oor:type="xs:boolean"> + <info> + <author>AW</author> + <desc> + This switch allows to enhance visualisation of graphics which use Horizontal or Vertical Hairlines + combined with AntiAliased mode (e.g. in 2D charts). When not used, those lines will be AntiAliased + as everything else. Since this is not pleasing for the eye, this option allows to force those lines + to snap to discrete points (pixels) when activated and thus avoids AntiAliasing of pure Horizontal or + Vertical Hairlines. + </desc> + <label>Determines if Horizontal and Vertical HairLines in AntiAliased mode are snapped to discrete pixles to enhance visualisation</label> + </info> + <value>true</value> + </prop> + <prop oor:name="RenderDecoratedTextDirect" oor:type="xs:boolean"> + <info> + <author>AW</author> + <desc> + This switch determines if the decorations of decorated text portions (e.g. underline, strike through) + are rendered using VCL direct rendering or if the primitive is decomposed into simple text and the + corresponding geometrical representations of the decorations. Default is true since VCL's usage + of the diverse System's hinting possibilities for decorations is useful. + </desc> + <label>Determines if decorated texts are decomposed at render time or directly rendered using VCL</label> + </info> + <value>true</value> + </prop> + <prop oor:name="RenderSimpleTextDirect" oor:type="xs:boolean"> + <info> + <author>AW</author> + <desc> + This switch determines if simple text is directly rendered using VCL or not. If not, the simple text + is decomposed into PolyPolygons which will be painted then. Default is true, since VCL will use the + hinting for font rendering on the diverse supported systems, which gives better quality than rendering + the text as Polygons. + </desc> + <label>Determines if simple texts are decomposed at render time or directly rendered using VCL</label> + </info> + <value>true</value> + </prop> <prop oor:name="SolidDragCreate" oor:type="xs:boolean"> <info> <author>AW</author> diff --git a/svx/inc/svx/outliner.hxx b/svx/inc/svx/outliner.hxx index 9fc20b815494..f2a64e16acb6 100644 --- a/svx/inc/svx/outliner.hxx +++ b/svx/inc/svx/outliner.hxx @@ -89,6 +89,7 @@ class SvxForbiddenCharactersTable; #include <vos/ref.hxx> #include <svx/svxfont.hxx> #include <svx/eedata.hxx> +#include <svx/paragraphdata.hxx> class SvxFieldData; ////////////////////////////////////////////////////////////////////////////// @@ -122,25 +123,6 @@ namespace basegfx { class B2DPolyPolygon; } // #define OLUNDO_MOVEPARAGRAPHS EDITUNDO_USER+7 #define OLUNDO_CHECKPARA EDITUNDO_USER+8 -// MT 07/00: Only for internal use, oder some kind like hPara for the few -// functions where you need it outside ( eg. moving paragraphs... ) - -class ParagraphData -{ - friend class Paragraph; - friend class OutlinerParaObject; -protected: - sal_Int16 nDepth; - sal_Int16 mnNumberingStartValue; - sal_Bool mbParaIsNumberingRestart; - -public: - ParagraphData( const ParagraphData& ); - ParagraphData(); - - ParagraphData& operator=( const ParagraphData& ); -}; - class Paragraph : protected ParagraphData { private: diff --git a/svx/inc/svx/outlobj.hxx b/svx/inc/svx/outlobj.hxx index 32c59a051e3b..9a8efeaaddc1 100644 --- a/svx/inc/svx/outlobj.hxx +++ b/svx/inc/svx/outlobj.hxx @@ -31,61 +31,66 @@ #ifndef _OUTLOBJ_HXX #define _OUTLOBJ_HXX +////////////////////////////////////////////////////////////////////////////// + #include <tools/solar.h> #include <tools/string.hxx> #include <rsc/rscsfx.hxx> -#include <svtools/itemset.hxx> +#include <svx/paragraphdata.hxx> #include "svx/svxdllapi.h" -#include <svx/eeitem.hxx> - -class Outliner; class EditTextObject; -class SvStream; -class SfxItemPool; -class SfxStyleSheetPool; -class ParagraphData; +class ImplOutlinerParaObject; + +////////////////////////////////////////////////////////////////////////////// class SVX_DLLPUBLIC OutlinerParaObject { - friend class Outliner; +private: + ImplOutlinerParaObject* mpImplOutlinerParaObject; - EditTextObject* pText; - ParagraphData* pParagraphDataArr; - sal_uInt32 nCount; - BOOL bIsEditDoc; - OutlinerParaObject( USHORT nParaCount ); + void ImplMakeUnique(); public: - OutlinerParaObject( const OutlinerParaObject& ); - OutlinerParaObject( const EditTextObject& rTObj ); - ~OutlinerParaObject(); + // constructors/destructor + OutlinerParaObject( + const EditTextObject& rEditTextObject, + const ParagraphDataVector& rParagraphDataVector = ParagraphDataVector(), + bool bIsEditDoc = true); + OutlinerParaObject(const OutlinerParaObject& rCandidate); + ~OutlinerParaObject(); - OutlinerParaObject* Clone() const; + // assignment operator + OutlinerParaObject& operator=(const OutlinerParaObject& rCandidate); - USHORT GetOutlinerMode() const; - void SetOutlinerMode( USHORT n ); + // compare operator + bool operator==(const OutlinerParaObject& rCandidate) const; + bool operator!=(const OutlinerParaObject& rCandidate) const { return !operator==(rCandidate); } - BOOL IsVertical() const; - void SetVertical( BOOL bVertical ); + // outliner mode access + sal_uInt16 GetOutlinerMode() const; + void SetOutlinerMode(sal_uInt16 nNew); - sal_uInt32 Count() const { return nCount; } - sal_Int16 GetDepth( USHORT nPara ) const; - const EditTextObject& GetTextObject() const { return *pText; } - void ClearPortionInfo(); - BOOL IsEditDoc() const { return bIsEditDoc; } - void Store( SvStream& ) const; - static OutlinerParaObject* Create( SvStream&, SfxItemPool* pTextObjectPool = 0 ); + // vertical access + bool IsVertical() const; + void SetVertical(bool bNew); - BOOL ChangeStyleSheets( const XubString& rOldName, SfxStyleFamily eOldFamily, - const XubString& rNewName, SfxStyleFamily eNewFamily ); - void ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName ); - void SetStyleSheets( USHORT nLevel, const XubString rNewName, const SfxStyleFamily& rNewFamily ); + // data read access + sal_uInt32 Count() const; + sal_Int16 GetDepth(sal_uInt16 nPara) const; + const EditTextObject& GetTextObject() const; + bool IsEditDoc() const; + const ParagraphData& GetParagraphData(sal_uInt32 nIndex) const; - BOOL RemoveCharAttribs( USHORT nWhich = 0 ); - BOOL RemoveParaAttribs( USHORT nWhich = 0 ); + // portion info support + void ClearPortionInfo(); - void MergeParaAttribs( const SfxItemSet& rAttribs, USHORT nStart = EE_CHAR_START, USHORT nEnd = EE_CHAR_END ); + // StyleSheet support + bool ChangeStyleSheets(const XubString& rOldName, SfxStyleFamily eOldFamily, const XubString& rNewName, SfxStyleFamily eNewFamily); + void ChangeStyleSheetName(SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName); + void SetStyleSheets(sal_uInt16 nLevel, const XubString rNewName, const SfxStyleFamily& rNewFamily); }; +////////////////////////////////////////////////////////////////////////////// + #endif diff --git a/svx/inc/svx/paragraphdata.hxx b/svx/inc/svx/paragraphdata.hxx new file mode 100644 index 000000000000..ddd98a15e176 --- /dev/null +++ b/svx/inc/svx/paragraphdata.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: outlobj.hxx,v $ + * $Revision: 1.5.78.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _PARAGRAPH_DATA_HXX +#define _PARAGRAPH_DATA_HXX + +#include <tools/solar.h> +#include <vector> + +////////////////////////////////////////////////////////////////////////////// +// MT 07/00: Only for internal use, oder some kind like hPara for the few +// functions where you need it outside ( eg. moving paragraphs... ) +// +// AW: Unfortunately NOT only local (formally in outliner.hxx), but also +// used in outlobj.hxx. Moved to own header + +class ParagraphData +{ + friend class Paragraph; + friend class OutlinerParaObject; + +protected: + sal_Int16 nDepth; + sal_Int16 mnNumberingStartValue; + sal_Bool mbParaIsNumberingRestart; + +public: + ParagraphData( const ParagraphData& ); + ParagraphData(); + + ParagraphData& operator=( const ParagraphData& ); + + // compare operator + bool operator==(const ParagraphData& rCandidate) const; + + // data read access + sal_Int16 getDepth() const { return nDepth; } +}; + +////////////////////////////////////////////////////////////////////////////// + +typedef ::std::vector< ParagraphData > ParagraphDataVector; + +////////////////////////////////////////////////////////////////////////////// + +#endif // _PARAGRAPH_DATA_HXX + +// eof diff --git a/svx/inc/svx/sdr/attribute/sdrtextattribute.hxx b/svx/inc/svx/sdr/attribute/sdrtextattribute.hxx index 712f01b69334..9033135e6caa 100644 --- a/svx/inc/svx/sdr/attribute/sdrtextattribute.hxx +++ b/svx/inc/svx/sdr/attribute/sdrtextattribute.hxx @@ -34,6 +34,7 @@ #include <svx/xenum.hxx> #include <sal/types.h> +#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// // predefines @@ -53,7 +54,7 @@ namespace drawinglayer class SdrTextAttribute { const SdrText& mrSdrText; - const OutlinerParaObject* mpOutlinerParaObject; + const OutlinerParaObject maOutlinerParaObject; XFormTextStyle meFormTextStyle; sal_Int32 maTextLeftDistance; @@ -67,28 +68,35 @@ namespace drawinglayer unsigned mbHideContour : 1; unsigned mbBlink : 1; unsigned mbScroll : 1; + unsigned mbInEditMode : 1; public: SdrTextAttribute( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObjectPtr, XFormTextStyle eFormTextStyle, sal_Int32 aTextLeftDistance, sal_Int32 aTextUpperDistance, sal_Int32 aTextRightDistance, sal_Int32 aTextLowerDistance, - bool bContour, bool bFitToSize, - bool bHideContour, bool bBlink, - bool bScroll); + bool bContour, + bool bFitToSize, + bool bHideContour, + bool bBlink, + bool bScroll, + bool bInEditMode); bool operator==(const SdrTextAttribute& rCandidate) const; // data access const SdrText& getSdrText() const { return mrSdrText; } + const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; } bool isContour() const { return mbContour; } bool isFontwork() const { return (XFT_NONE != meFormTextStyle); } bool isFitToSize() const { return mbFitToSize; } bool isHideContour() const { return mbHideContour; } bool isBlink() const { return mbBlink; } bool isScroll() const { return mbScroll; } + bool isInEditMode() const { return mbInEditMode; } XFormTextStyle getFormTextStyle() const { return meFormTextStyle; } sal_Int32 getTextLeftDistance() const { return maTextLeftDistance; } sal_Int32 getTextUpperDistance() const { return maTextUpperDistance; } diff --git a/svx/inc/svx/sdr/primitive2d/sdrprimitivetools.hxx b/svx/inc/svx/sdr/primitive2d/sdrprimitivetools.hxx index 37edea1a5878..2d419e9cd45d 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrprimitivetools.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrprimitivetools.hxx @@ -33,12 +33,14 @@ #define INCLUDED_SDR_PRIMITIVE2D_PRIMITIVETOOLS_HXX #include <vcl/bitmapex.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// // predefines namespace basegfx { class BColor; + class B2DHomMatrix; } ////////////////////////////////////////////////////////////////////////////// @@ -54,6 +56,9 @@ namespace drawinglayer // create a 7x7 gluepoint symbol in given colors as BitmapEx BitmapEx createDefaultGluepoint_7x7(const basegfx::BColor& rBColorA, const basegfx::BColor& rBColorB); + // #i99123# + Primitive2DReference createFallbackHitTestPrimitive(const basegfx::B2DHomMatrix& rMatrix); + } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx index 10b35c4dd027..8579b87e9470 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx @@ -36,6 +36,8 @@ #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <com/sun/star/drawing/XDrawPage.hpp> +#include <boost/shared_ptr.hpp> +#include <svx/outlobj.hxx> ////////////////////////////////////////////////////////////////////////////// // predefines @@ -54,6 +56,11 @@ namespace drawinglayer // something equal const SdrText& mrSdrText; // text model data + // #i97628# + // The text content; now as OutlinerParaObject* and in exclusive, local, cloned + // form as needed in a primitive + const OutlinerParaObject maOutlinerParaObject; + // remeber last VisualizingPage for which a decomposition was made. If the new target // is not given or different, the decomposition needs to be potentially removed // for supporting e.g. page number change on MasterPage objects or the different @@ -77,10 +84,13 @@ namespace drawinglayer void setLastSpellCheck(bool bNew) { mbLastSpellCheck = bNew; } public: - SdrTextPrimitive2D(const SdrText& rSdrText); + SdrTextPrimitive2D( + const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObjectPtr); // get data const SdrText& getSdrText() const { return mrSdrText; } + const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; } // compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; @@ -114,6 +124,7 @@ namespace drawinglayer public: SdrContourTextPrimitive2D( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObjectPtr, const ::basegfx::B2DPolyPolygon& rUnitPolyPolygon, const ::basegfx::B2DHomMatrix& rObjectTransform); @@ -151,6 +162,7 @@ namespace drawinglayer public: SdrPathTextPrimitive2D( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObjectPtr, const ::basegfx::B2DPolyPolygon& rPathPolyPolygon); // get data @@ -191,6 +203,7 @@ namespace drawinglayer public: SdrBlockTextPrimitive2D( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObjectPtr, const ::basegfx::B2DHomMatrix& rTextRangeTransform, bool bUnlimitedPage, bool bCellText, @@ -232,6 +245,7 @@ namespace drawinglayer public: SdrStretchTextPrimitive2D( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObjectPtr, const ::basegfx::B2DHomMatrix& rTextRangeTransform); // get data diff --git a/svx/inc/svx/svdpool.hxx b/svx/inc/svx/svdpool.hxx index 12ce8d669f4d..d6cf4f8543b6 100644 --- a/svx/inc/svx/svdpool.hxx +++ b/svx/inc/svx/svdpool.hxx @@ -45,7 +45,9 @@ class SVX_DLLPUBLIC SdrItemPool : public XOutdevItemPool public: SdrItemPool(SfxItemPool* pMaster = 0L, sal_Bool bLoadRefCounts = sal_True); SdrItemPool(const SdrItemPool& rPool); +protected: virtual ~SdrItemPool(); +public: virtual SfxItemPool* Clone() const; virtual SfxItemPresentation GetPresentation(const SfxPoolItem& rItem, diff --git a/svx/inc/svx/xpool.hxx b/svx/inc/svx/xpool.hxx index 6492f4dd6c6a..c8e944801941 100644 --- a/svx/inc/svx/xpool.hxx +++ b/svx/inc/svx/xpool.hxx @@ -56,7 +56,8 @@ public: XOutdevItemPool(const XOutdevItemPool& rPool); virtual SfxItemPool* Clone() const; - ~XOutdevItemPool(); +protected: + virtual ~XOutdevItemPool(); }; #endif // _XPOOL_HXX diff --git a/svx/prj/d.lst b/svx/prj/d.lst index e55f2a585838..3b70b59970fb 100644 --- a/svx/prj/d.lst +++ b/svx/prj/d.lst @@ -412,6 +412,7 @@ mkdir: %_DEST%\inc%_EXT%\svx ..\source\items\boxobj.hxx %_DEST%\inc%_EXT%\svx\boxobj.hxx ..\inc\svx\itemtype.hxx %_DEST%\inc%_EXT%\svx\itemtype.hxx ..\inc\svx\outliner.hxx %_DEST%\inc%_EXT%\svx\outliner.hxx +..\inc\svx\paragraphdata.hxx %_DEST%\inc%_EXT%\svx\paragraphdata.hxx ..\inc\svx\outlobj.hxx %_DEST%\inc%_EXT%\svx\outlobj.hxx ..\inc\svx\editdata.hxx %_DEST%\inc%_EXT%\svx\editdata.hxx ..\inc\svx\editeng.hxx %_DEST%\inc%_EXT%\svx\editeng.hxx diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.cxx b/svx/source/accessibility/AccessibleEmptyEditSource.cxx index cd111db1a654..072d6347f3f4 100644 --- a/svx/source/accessibility/AccessibleEmptyEditSource.cxx +++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx @@ -41,6 +41,7 @@ #include <svx/outliner.hxx> #include <svx/svdmodel.hxx> #include <svx/svdobj.hxx> +#include <svx/svdpool.hxx> //------------------------------------------------------------------------ // @@ -112,9 +113,10 @@ namespace accessibility String GetText( const ESelection& /*rSel*/ ) const { return String(); } SfxItemSet GetAttribs( const ESelection& /*rSel*/, BOOL /*bOnlyHardAttrib*/ = 0 ) const { - String aDummyStr(RTL_CONSTASCII_USTRINGPARAM("Dummy")); - SfxItemPool aPool(aDummyStr,0,0,NULL); - return SfxItemSet(aPool); + // AW: Very dangerous: The former implementation used a SfxItemPool created on the + // fly which of course was deleted again ASAP. Thus, the returned SfxItemSet was using + // a deleted Pool by design. + return SfxItemSet(SdrObject::GetGlobalDrawObjectItemPool()); } SfxItemSet GetParaAttribs( USHORT /*nPara*/ ) const { return GetAttribs(ESelection()); } void SetParaAttribs( USHORT /*nPara*/, const SfxItemSet& /*rSet*/ ) {} diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx index 9895f3c6e3b0..fbba42ba8d01 100644 --- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx @@ -177,7 +177,7 @@ SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( const SdrObjCustom // Copy text content OutlinerParaObject* pParaObj = pCustoObj->GetOutlinerParaObject(); if( pParaObj ) - pTextObj->NbcSetOutlinerParaObject( pParaObj->Clone() ); + pTextObj->NbcSetOutlinerParaObject( new OutlinerParaObject(*pParaObj) ); // copy all attributes SfxItemSet aTargetItemSet( pCustoObj->GetMergedItemSet() ); diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx index 090d3eb1da53..162d25937c5f 100644 --- a/svx/source/dialog/imapwnd.cxx +++ b/svx/source/dialog/imapwnd.cxx @@ -141,7 +141,7 @@ IMapWindow::~IMapWindow() for( String* pStr = aTargetList.First(); pStr; pStr = aTargetList.Next() ) delete pStr; - delete pIMapPool; + SfxItemPool::Free(pIMapPool); delete[] pItemInfo; } @@ -287,7 +287,7 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj ) Point aPoint; Rectangle aClipRect( aPoint, GetGraphicSize() ); SdrObject* pSdrObj = NULL; - IMapObject* pCloneIMapObj = NULL; + IMapObjectPtr pCloneIMapObj; switch( pIMapObj->GetType() ) { @@ -300,7 +300,7 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj ) aDrawRect.Intersection( aClipRect ); pSdrObj = (SdrObject*) new SdrRectObj( aDrawRect ); - pCloneIMapObj = (IMapObject*) new IMapRectangleObject( *pIMapRectObj ); + pCloneIMapObj.reset((IMapObject*) new IMapRectangleObject( *pIMapRectObj )); } break; @@ -316,7 +316,7 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj ) aCircle.Intersection( aClipRect ); pSdrObj = (SdrObject*) new SdrCircObj( OBJ_CIRC, aCircle, 0, 36000 ); - pCloneIMapObj = (IMapObject*) new IMapCircleObject( *pIMapCircleObj ); + pCloneIMapObj.reset((IMapObject*) new IMapCircleObject( *pIMapCircleObj )); } break; @@ -348,7 +348,7 @@ SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj ) pSdrObj = (SdrObject*)new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aPolygon)); } - pCloneIMapObj = (IMapObject*) new IMapPolygonObject( *pIMapPolyObj ); + pCloneIMapObj.reset((IMapObject*) new IMapPolygonObject( *pIMapPolyObj )); } break; @@ -416,9 +416,9 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj ) { SdrRectObj* pRectObj = (SdrRectObj*) &rObj; IMapRectangleObject* pObj = new IMapRectangleObject( pRectObj->GetLogicRect(), - String(), String(), String(), String(), String(), TRUE, FALSE ); + String(), String(), String(), String(), String(), TRUE, FALSE ); - pRectObj->InsertUserData( new IMapUserData( pObj ) ); + pRectObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) ); } break; @@ -431,7 +431,7 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj ) IMapPolygonObject* pObj = new IMapPolygonObject( Polygon(aPoly), String(), String(), String(), String(), String(), TRUE, FALSE ); pObj->SetExtraEllipse( aPoly.GetBoundRect() ); - pCircObj->InsertUserData( new IMapUserData( pObj ) ); + pCircObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) ); } break; @@ -447,7 +447,7 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj ) { Polygon aPoly(rXPolyPoly.getB2DPolygon(0L)); IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, String(), String(), String(), String(), String(), TRUE, FALSE ); - pPathObj->InsertUserData( new IMapUserData( pObj ) ); + pPathObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) ); } } break; @@ -473,10 +473,10 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj ) String aAltText; String aDesc; String aTarget; - IMapObject* pIMapObj = pUserData->GetObject(); + IMapObjectPtr pIMapObj = pUserData->GetObject(); BOOL bActive = TRUE; - if ( pIMapObj ) + if ( pIMapObj.get() ) { aURL = pIMapObj->GetURL(); aAltText = pIMapObj->GetAltText(); @@ -489,8 +489,8 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj ) { case( OBJ_RECT ): { - pUserData->ReplaceObject( new IMapRectangleObject( ( (const SdrRectObj&) rObj ).GetLogicRect(), - aURL, aAltText, aDesc, aTarget, String(), bActive, FALSE ) ); + pUserData->ReplaceObject( IMapObjectPtr(new IMapRectangleObject( ( (const SdrRectObj&) rObj ).GetLogicRect(), + aURL, aAltText, aDesc, aTarget, String(), bActive, FALSE ) ) ); } break; @@ -505,7 +505,7 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj ) // wurde von uns nur temporaer angelegt delete pPathObj; - pUserData->ReplaceObject( pObj ); + pUserData->ReplaceObject( IMapObjectPtr(pObj) ); } break; @@ -521,7 +521,7 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj ) { Polygon aPoly(rPathObj.GetPathPoly().getB2DPolygon(0L)); IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, String(), bActive, FALSE ); - pUserData->ReplaceObject( pObj ); + pUserData->ReplaceObject( IMapObjectPtr(pObj) ); } } break; @@ -606,7 +606,7 @@ IMapObject* IMapWindow::GetIMapObj( const SdrObject* pSdrObj ) const IMapUserData* pUserData = (IMapUserData*) pSdrObj->GetUserData( 0 ); if ( pUserData ) - pIMapObj = pUserData->GetObject(); + pIMapObj = pUserData->GetObject().get(); } return pIMapObj; diff --git a/svx/source/dialog/imapwnd.hxx b/svx/source/dialog/imapwnd.hxx index d1ac67245ce4..0b8ecd942215 100644 --- a/svx/source/dialog/imapwnd.hxx +++ b/svx/source/dialog/imapwnd.hxx @@ -83,31 +83,34 @@ const UINT32 IMapInventor = UINT32('I') * 0x00000001+ UINT32('P') * 0x01000000; +typedef boost::shared_ptr< IMapObject > IMapObjectPtr; + class IMapUserData : public SdrObjUserData { - IMapObject* pObj; + // #i98386# use boost::shared_ptr here due to cloning possibilities + IMapObjectPtr mpObj; public: IMapUserData() : SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ), - pObj ( NULL ) {} + mpObj ( ) {} - IMapUserData( IMapObject* pIMapObj ) : + IMapUserData( const IMapObjectPtr& rIMapObj ) : SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ), - pObj ( pIMapObj ) {} + mpObj ( rIMapObj ) {} IMapUserData( const IMapUserData& rIMapUserData ) : SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ), - pObj ( rIMapUserData.pObj ) {} + mpObj ( rIMapUserData.mpObj ) {} - ~IMapUserData() { delete pObj; } + ~IMapUserData() { } virtual SdrObjUserData* Clone( SdrObject * ) const { return new IMapUserData( *this ); } - void SetObject( IMapObject* pIMapObj ) { pObj = pIMapObj; } - IMapObject* GetObject() const { return pObj; } - void ReplaceObject( IMapObject* pNewIMapObject ) { delete pObj; pObj = pNewIMapObject; } + void SetObject( const IMapObjectPtr& rIMapObj ) { mpObj = rIMapObj; } + const IMapObjectPtr GetObject() const { return mpObj; } + void ReplaceObject( const IMapObjectPtr& pNewIMapObject ) { mpObj = pNewIMapObject; } }; diff --git a/svx/source/editeng/editdoc.cxx b/svx/source/editeng/editdoc.cxx index d5f5cbff507f..c90de8eb5ce0 100644 --- a/svx/source/editeng/editdoc.cxx +++ b/svx/source/editeng/editdoc.cxx @@ -1245,7 +1245,7 @@ EditDoc::~EditDoc() { ImplDestroyContents(); if ( bOwnerOfPool ) - delete pItemPool; + SfxItemPool::Free(pItemPool); } void EditDoc::ImplDestroyContents() diff --git a/svx/source/editeng/editdoc.hxx b/svx/source/editeng/editdoc.hxx index 3b4d5cdb5515..dd9662d366e5 100644 --- a/svx/source/editeng/editdoc.hxx +++ b/svx/source/editeng/editdoc.hxx @@ -784,7 +784,9 @@ class EditEngineItemPool : public SfxItemPool { public: EditEngineItemPool( BOOL bPersistenRefCounts ); - ~EditEngineItemPool(); +protected: + virtual ~EditEngineItemPool(); +public: virtual SvStream& Store( SvStream& rStream ) const; }; diff --git a/svx/source/editeng/editobj.cxx b/svx/source/editeng/editobj.cxx index 759c39b79c00..d0170e507060 100644 --- a/svx/source/editeng/editobj.cxx +++ b/svx/source/editeng/editobj.cxx @@ -566,8 +566,42 @@ bool EditTextObject::operator==( const EditTextObject& rCompare ) const return static_cast< const BinTextObject* >( this )->operator==( static_cast< const BinTextObject& >( rCompare ) ); } +// from SfxItemPoolUser +void BinTextObject::ObjectInDestruction(const SfxItemPool& rSfxItemPool) +{ + if(!bOwnerOfPool && pPool && pPool == &rSfxItemPool) + { + // The pool we are based on gets destructed; get owner of pool by creating own one. + // No need to call RemoveSfxItemPoolUser(), this is done from the pool's destructor + // Base new pool on EditEnginePool; it would also be possible to clone the used + // pool if needed, but only text attributes should be used. + SfxItemPool* pNewPool = EditEngine::CreatePool(); + + if(pPool) + { + pNewPool->SetDefaultMetric(pPool->GetMetric(DEF_METRIC)); + } + + for(sal_uInt16 n(0); n < aContents.Count(); n++) + { + // clone ContentInfos for new pool + ContentInfo* pOrg = aContents.GetObject(n); + DBG_ASSERT(pOrg, "NULL-Pointer in ContentList!"); + + ContentInfo* pNew = new ContentInfo(*pOrg, *pNewPool); + aContents.Replace(pNew, n); + delete pOrg; + } + + // set local variables + pPool = pNewPool; + bOwnerOfPool = TRUE; + } +} + BinTextObject::BinTextObject( SfxItemPool* pP ) : - EditTextObject( EE_FORMAT_BIN ) + EditTextObject( EE_FORMAT_BIN ), + SfxItemPoolUser() { nVersion = 0; nMetric = 0xFFFF; @@ -584,13 +618,20 @@ BinTextObject::BinTextObject( SfxItemPool* pP ) : pPool = EditEngine::CreatePool(); bOwnerOfPool = TRUE; } + + if(!bOwnerOfPool && pPool) + { + pPool->AddSfxItemPoolUser(*this); + } + bVertical = FALSE; bStoreUnicodeStrings = FALSE; nScriptType = 0; } BinTextObject::BinTextObject( const BinTextObject& r ) : - EditTextObject( r ) + EditTextObject( r ), + SfxItemPoolUser() { nVersion = r.nVersion; nMetric = r.nMetric; @@ -613,6 +654,11 @@ BinTextObject::BinTextObject( const BinTextObject& r ) : } + if(!bOwnerOfPool && pPool) + { + pPool->AddSfxItemPoolUser(*this); + } + if ( bOwnerOfPool && pPool && r.pPool ) pPool->SetDefaultMetric( r.pPool->GetMetric( DEF_METRIC ) ); @@ -627,6 +673,11 @@ BinTextObject::BinTextObject( const BinTextObject& r ) : __EXPORT BinTextObject::~BinTextObject() { + if(!bOwnerOfPool && pPool) + { + pPool->RemoveSfxItemPoolUser(*this); + } + ClearPortionInfo(); DeleteContents(); if ( bOwnerOfPool ) @@ -634,7 +685,7 @@ __EXPORT BinTextObject::~BinTextObject() // Nicht mehr, wegen 1xDefItems. // siehe auch ~EditDoc(). // pPool->ReleaseDefaults( TRUE /* bDelete */ ); - delete pPool; + SfxItemPool::Free(pPool); } } diff --git a/svx/source/editeng/editobj2.hxx b/svx/source/editeng/editobj2.hxx index 943e394f7ee7..51a044575dd2 100644 --- a/svx/source/editeng/editobj2.hxx +++ b/svx/source/editeng/editobj2.hxx @@ -195,7 +195,7 @@ SV_DECL_PTRARR( ContentInfoList, ContentInfoPtr, 1, 4 ) // MT 05/00: Sollte mal direkt EditTextObjekt werden => keine virtuellen Methoden mehr. -class BinTextObject : public EditTextObject +class BinTextObject : public EditTextObject, public SfxItemPoolUser { using EditTextObject::operator==; @@ -303,6 +303,8 @@ public: bool operator==( const BinTextObject& rCompare ) const; + // from SfxItemPoolUser + virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool); }; #endif // _EDITOBJ2_HXX diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index 73665766a3a4..08643e025e19 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -670,15 +670,15 @@ namespace svx //------------------------------------------------------------------------ void FmTextControlShell::executeAttributeDialog( AttributeSet _eSet, SfxRequest& _rReq ) { - ::std::auto_ptr< SfxItemPool > pPool( EditEngine::CreatePool() ); - pPool->FreezeIdRanges(); - SfxItemSet aPureItems( *pPool ); - const SvxFontListItem* pFontList = PTR_CAST( SvxFontListItem, m_pViewFrame->GetObjectShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) ); DBG_ASSERT( pFontList, "FmTextControlShell::executeAttributeDialog: no font list item!" ); if ( !pFontList ) return; + SfxItemPool* pPool = EditEngine::CreatePool(); + pPool->FreezeIdRanges(); + SfxItemSet aPureItems( *pPool ); + // put the current states of the items into the set SfxAllItemSet aCurrentItems( aPureItems ); transferFeatureStatesToItemSet( m_aControlFeatures, aCurrentItems ); @@ -774,6 +774,8 @@ namespace svx } _rReq.Done( rModifiedItems ); } + + SfxItemPool::Free(pPool); } //------------------------------------------------------------------------ diff --git a/svx/source/outliner/makefile.mk b/svx/source/outliner/makefile.mk index 5a1e287d6eff..deef3530499c 100644 --- a/svx/source/outliner/makefile.mk +++ b/svx/source/outliner/makefile.mk @@ -34,6 +34,7 @@ PRJ=..$/.. PRJNAME=svx TARGET=outliner AUTOSEG=true +ENABLE_EXCEPTIONS=TRUE PROJECTPCH4DLL=TRUE PROJECTPCH=outl_pch diff --git a/svx/source/outliner/outliner.cxx b/svx/source/outliner/outliner.cxx index 2d72442a9e9f..6178f1f3e717 100644 --- a/svx/source/outliner/outliner.cxx +++ b/svx/source/outliner/outliner.cxx @@ -378,14 +378,19 @@ OutlinerParaObject* Outliner::CreateParaObject( USHORT nStartPara, USHORT nCount if( !nCount ) return NULL; - OutlinerParaObject* pPObj = new OutlinerParaObject( nCount ); - pPObj->pText = pEditEngine->CreateTextObject( nStartPara, nCount ); - pPObj->SetOutlinerMode( GetMode() ); - pPObj->bIsEditDoc = ( ImplGetOutlinerMode() == OUTLINERMODE_TEXTOBJECT ) ? TRUE : FALSE; + EditTextObject* pText = pEditEngine->CreateTextObject( nStartPara, nCount ); + const bool bIsEditDoc(OUTLINERMODE_TEXTOBJECT == ImplGetOutlinerMode()); + ParagraphDataVector aParagraphDataVector(nCount); + const sal_uInt16 nLastPara(nStartPara + nCount - 1); - USHORT nLastPara = nStartPara + nCount - 1; - for ( USHORT nPara = nStartPara; nPara <= nLastPara; nPara++ ) - pPObj->pParagraphDataArr[ nPara-nStartPara] = *GetParagraph( nPara ); + for(sal_uInt16 nPara(nStartPara); nPara <= nLastPara; nPara++) + { + aParagraphDataVector[nPara-nStartPara] = *GetParagraph(nPara); + } + + OutlinerParaObject* pPObj = new OutlinerParaObject(*pText, aParagraphDataVector, bIsEditDoc); + pPObj->SetOutlinerMode(GetMode()); + delete pText; return pPObj; } @@ -573,8 +578,8 @@ void Outliner::SetText( const OutlinerParaObject& rPObj ) Init( rPObj.GetOutlinerMode() ); ImplBlockInsertionCallbacks( TRUE ); - pEditEngine->SetText( *(rPObj.pText) ); - if( rPObj.nCount != pEditEngine->GetParagraphCount() ) + pEditEngine->SetText(rPObj.GetTextObject()); + if( rPObj.Count() != pEditEngine->GetParagraphCount() ) { int nop=0;nop++; } @@ -582,9 +587,9 @@ void Outliner::SetText( const OutlinerParaObject& rPObj ) bFirstParaIsEmpty = FALSE; pParaList->Clear( TRUE ); - for( USHORT nCurPara = 0; nCurPara < rPObj.nCount; nCurPara++ ) + for( USHORT nCurPara = 0; nCurPara < rPObj.Count(); nCurPara++ ) { - Paragraph* pPara = new Paragraph( rPObj.pParagraphDataArr[ nCurPara ] ); + Paragraph* pPara = new Paragraph( rPObj.GetParagraphData(nCurPara)); ImplCheckDepth( pPara->nDepth ); pParaList->Insert( pPara, LIST_APPEND ); @@ -614,19 +619,19 @@ void Outliner::AddText( const OutlinerParaObject& rPObj ) if( bFirstParaIsEmpty ) { pParaList->Clear( TRUE ); - pEditEngine->SetText( *(rPObj.pText) ); + pEditEngine->SetText(rPObj.GetTextObject()); nPara = 0; } else { nPara = pParaList->GetParagraphCount(); - pEditEngine->InsertParagraph( EE_PARA_APPEND, *(rPObj.pText) ); + pEditEngine->InsertParagraph( EE_PARA_APPEND, rPObj.GetTextObject() ); } bFirstParaIsEmpty = FALSE; - for( USHORT n = 0; n < rPObj.nCount; n++ ) + for( USHORT n = 0; n < rPObj.Count(); n++ ) { - pPara = new Paragraph( rPObj.pParagraphDataArr[ n ] ); + pPara = new Paragraph( rPObj.GetParagraphData(n) ); pParaList->Insert( pPara, LIST_APPEND ); USHORT nP = sal::static_int_cast< USHORT >(nPara+n); DBG_ASSERT(pParaList->GetAbsPos(pPara)==nP,"AddText:Out of sync"); diff --git a/svx/source/outliner/outlobj.cxx b/svx/source/outliner/outlobj.cxx index ace1dd2c8b73..5aba25caddaa 100644 --- a/svx/source/outliner/outlobj.cxx +++ b/svx/source/outliner/outlobj.cxx @@ -38,234 +38,218 @@ #include <svx/outlobj.hxx> #include <outleeng.hxx> #include <svx/editobj.hxx> +#include <vcl/bitmap.hxx> +#include <tools/stream.hxx> +////////////////////////////////////////////////////////////////////////////// -#include <vcl/bitmap.hxx> +class ImplOutlinerParaObject +{ +public: + // data members + EditTextObject* mpEditTextObject; + ParagraphDataVector maParagraphDataVector; + bool mbIsEditDoc; + // refcounter + sal_uInt32 mnRefCount; -#include <tools/stream.hxx> + // constuctor + ImplOutlinerParaObject(EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc) + : mpEditTextObject(pEditTextObject), + maParagraphDataVector(rParagraphDataVector), + mbIsEditDoc(bIsEditDoc), + mnRefCount(0) + { + } -DBG_NAME(OutlinerParaObject) + // destructor + ~ImplOutlinerParaObject() + { + delete mpEditTextObject; + } -OutlinerParaObject::OutlinerParaObject( USHORT nParaCount ) -{ - DBG_CTOR(OutlinerParaObject,0); + bool operator==(const ImplOutlinerParaObject& rCandidate) const + { + return (*mpEditTextObject == *rCandidate.mpEditTextObject + && maParagraphDataVector == rCandidate.maParagraphDataVector + && mbIsEditDoc == rCandidate.mbIsEditDoc); + } +}; - bIsEditDoc = TRUE; - pParagraphDataArr = new ParagraphData[ nParaCount ]; - nCount = nParaCount; -} +////////////////////////////////////////////////////////////////////////////// -OutlinerParaObject::OutlinerParaObject( const OutlinerParaObject& rObj ) +void OutlinerParaObject::ImplMakeUnique() { - DBG_CTOR(OutlinerParaObject,0); - - bIsEditDoc = rObj.bIsEditDoc; - nCount = rObj.nCount; - pParagraphDataArr = new ParagraphData[ nCount ]; - for( sal_uInt32 i = 0; i < nCount; i++ ) - pParagraphDataArr[i] = rObj.pParagraphDataArr[i]; - pText = rObj.pText->Clone(); + if(mpImplOutlinerParaObject->mnRefCount) + { + ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject( + mpImplOutlinerParaObject->mpEditTextObject->Clone(), + mpImplOutlinerParaObject->maParagraphDataVector, + mpImplOutlinerParaObject->mbIsEditDoc); + mpImplOutlinerParaObject->mnRefCount--; + mpImplOutlinerParaObject = pNew; + } } -OutlinerParaObject::OutlinerParaObject( const EditTextObject& rEditObj ) +OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc) +: mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc)) { - DBG_CTOR(OutlinerParaObject,0); +} - bIsEditDoc = TRUE; - pText = rEditObj.Clone(); - nCount = pText->GetParagraphCount(); - pParagraphDataArr = new ParagraphData[ nCount ]; +OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate) +: mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject) +{ + mpImplOutlinerParaObject->mnRefCount++; } OutlinerParaObject::~OutlinerParaObject() { - DBG_DTOR(OutlinerParaObject,0); - - delete pText; - delete[] pParagraphDataArr; + if(mpImplOutlinerParaObject->mnRefCount) + { + mpImplOutlinerParaObject->mnRefCount--; + } + else + { + delete mpImplOutlinerParaObject; + } } -sal_Int16 OutlinerParaObject::GetDepth( USHORT nPara ) const +OutlinerParaObject& OutlinerParaObject::operator=(const OutlinerParaObject& rCandidate) { - if( pParagraphDataArr && (nPara < nCount ) ) - return pParagraphDataArr[nPara].nDepth; - else - return -1; + if(rCandidate.mpImplOutlinerParaObject != mpImplOutlinerParaObject) + { + if(mpImplOutlinerParaObject->mnRefCount) + { + mpImplOutlinerParaObject->mnRefCount--; + } + else + { + delete mpImplOutlinerParaObject; + } + + mpImplOutlinerParaObject = rCandidate.mpImplOutlinerParaObject; + mpImplOutlinerParaObject->mnRefCount++; + } + + return *this; } -void OutlinerParaObject::ClearPortionInfo() +bool OutlinerParaObject::operator==(const OutlinerParaObject& rCandidate) const { - DBG_CHKTHIS(OutlinerParaObject,0); - pText->ClearPortionInfo(); + if(rCandidate.mpImplOutlinerParaObject == mpImplOutlinerParaObject) + { + return true; + } + + return (*rCandidate.mpImplOutlinerParaObject == *mpImplOutlinerParaObject); } -OutlinerParaObject* OutlinerParaObject::Clone() const +sal_uInt16 OutlinerParaObject::GetOutlinerMode() const { - DBG_CHKTHIS(OutlinerParaObject,0); - OutlinerParaObject* pObj = new OutlinerParaObject(*this); - return pObj; + return mpImplOutlinerParaObject->mpEditTextObject->GetUserType(); } -void OutlinerParaObject::ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName ) +void OutlinerParaObject::SetOutlinerMode(sal_uInt16 nNew) { - DBG_CHKTHIS(OutlinerParaObject,0); - pText->ChangeStyleSheetName( eFamily, rOldName, rNewName ); + if(mpImplOutlinerParaObject->mpEditTextObject->GetUserType() != nNew) + { + ImplMakeUnique(); + mpImplOutlinerParaObject->mpEditTextObject->SetUserType(nNew); + } } -BOOL OutlinerParaObject::ChangeStyleSheets( const XubString& rOldName, SfxStyleFamily eOldFamily, const XubString& rNewName, SfxStyleFamily eNewFamily ) +bool OutlinerParaObject::IsVertical() const { - DBG_CHKTHIS(OutlinerParaObject,0); - return pText->ChangeStyleSheets( rOldName, eOldFamily, rNewName, eNewFamily ); + return mpImplOutlinerParaObject->mpEditTextObject->IsVertical(); } -void OutlinerParaObject::SetStyleSheets( USHORT nLevel, const XubString rNewName, const SfxStyleFamily& rNewFamily ) +void OutlinerParaObject::SetVertical(bool bNew) { - for ( USHORT n = sal::static_int_cast< USHORT >( Count() ); n; ) + if((bool)mpImplOutlinerParaObject->mpEditTextObject->IsVertical() != bNew) { - if ( GetDepth( --n ) == nLevel ) - pText->SetStyleSheet( n, rNewName, rNewFamily ); + ImplMakeUnique(); + mpImplOutlinerParaObject->mpEditTextObject->SetVertical(bNew); } } -void OutlinerParaObject::Store(SvStream& rStream ) const +sal_uInt32 OutlinerParaObject::Count() const { - rStream << nCount; - rStream << static_cast<sal_uInt32>(0x42345678); - pText->Store( rStream ); - - for( USHORT nPos=0; nPos < nCount; nPos++ ) - rStream << pParagraphDataArr[ nPos ].nDepth; - - rStream << bIsEditDoc; + return mpImplOutlinerParaObject->maParagraphDataVector.size(); } -OutlinerParaObject* OutlinerParaObject::Create( SvStream& rStream, SfxItemPool* pTextObjectPool ) +sal_Int16 OutlinerParaObject::GetDepth(sal_uInt16 nPara) const { - OutlinerParaObject* pPObj = NULL; - USHORT nVersion = 0; - - sal_uInt32 nCount; - rStream >> nCount; - - sal_uInt32 nSyncRef; - rStream >> nSyncRef; - if( nSyncRef == 0x12345678 ) - nVersion = 1; - else if( nSyncRef == 0x22345678 ) - nVersion = 2; - else if( nSyncRef == 0x32345678 ) - nVersion = 3; - else if ( nSyncRef == 0x42345678 ) - nVersion = 4; - - if ( nVersion ) + if(nPara < mpImplOutlinerParaObject->maParagraphDataVector.size()) { - pPObj = new OutlinerParaObject( (USHORT)nCount ); - if( nVersion <= 3 ) - { - EditTextObject* pAllText = 0; - USHORT nCurPara = 0; - while ( nCount ) - { - EditTextObject* pText = EditTextObject::Create( rStream, NULL ); - DBG_ASSERT(pText,"CreateEditTextObject failed"); - sal_uInt32 nSync = 0; - rStream >> nSync; - DBG_ASSERT(nSync==nSyncRef,"Stream out of sync"); - USHORT nDepth; - rStream >> nDepth; - Paragraph* pPara = new Paragraph( nDepth ); - if( nVersion == 1 ) - { - // Bullet ueberlesen - USHORT nFlags; - rStream >> nFlags; - - if ( nFlags & 0x0001 ) // Bitmap - { - Bitmap aBmp; - rStream >> aBmp; - } - else - { - Color aColor; - rStream >> aColor; - rStream.SeekRel( 16 ); - String aName; - rStream.ReadByteString(aName); - rStream.SeekRel( 12 ); - } - long nDummy; - rStream >> nDummy; - rStream >> nDummy; - } - pPara->bVisible = TRUE; - if( !pAllText ) - pAllText = pText; - else - { - pAllText->Insert( *pText, 0xffff ); - delete pText; - } - pPObj->pParagraphDataArr[ nCurPara ] = *pPara; - delete pPara; - nCount--; - nCurPara++; - if( nCount ) - { - sal_uInt32 _nSync = 0; - rStream >> _nSync; - DBG_ASSERT(_nSync==nSyncRef,"Stream out of sync"); - } - } - if( nVersion == 3 ) - rStream >> pPObj->bIsEditDoc; - pPObj->pText = pAllText; - } - else // nVersion >= 4 - { - pPObj->pText = EditTextObject::Create( rStream, pTextObjectPool ); - for( USHORT nCur=0; nCur < nCount; nCur++ ) - rStream >> pPObj->pParagraphDataArr[ nCur ].nDepth; - rStream >> pPObj->bIsEditDoc; - } + return mpImplOutlinerParaObject->maParagraphDataVector[nPara].getDepth(); + } + else + { + return -1; } - return pPObj; } -USHORT OutlinerParaObject::GetOutlinerMode() const +const EditTextObject& OutlinerParaObject::GetTextObject() const { - return pText->GetUserType(); + return *mpImplOutlinerParaObject->mpEditTextObject; } -void OutlinerParaObject::SetOutlinerMode( USHORT n ) +bool OutlinerParaObject::IsEditDoc() const { - pText->SetUserType( n ); + return mpImplOutlinerParaObject->mbIsEditDoc; } -BOOL OutlinerParaObject::RemoveCharAttribs( USHORT nWhich ) +const ParagraphData& OutlinerParaObject::GetParagraphData(sal_uInt32 nIndex) const { - return pText->RemoveCharAttribs( nWhich ); + if(nIndex < mpImplOutlinerParaObject->maParagraphDataVector.size()) + { + return mpImplOutlinerParaObject->maParagraphDataVector[nIndex]; + } + else + { + OSL_ENSURE(false, "OutlinerParaObject::GetParagraphData: Access out of range (!)"); + static ParagraphData aEmptyParagraphData; + return aEmptyParagraphData; + } } -BOOL OutlinerParaObject::RemoveParaAttribs( USHORT nWhich ) +void OutlinerParaObject::ClearPortionInfo() { - return pText->RemoveParaAttribs( nWhich ); + ImplMakeUnique(); + mpImplOutlinerParaObject->mpEditTextObject->ClearPortionInfo(); } -void OutlinerParaObject::MergeParaAttribs( const SfxItemSet& rAttribs, USHORT nStart, USHORT nEnd ) +bool OutlinerParaObject::ChangeStyleSheets(const XubString& rOldName, SfxStyleFamily eOldFamily, const XubString& rNewName, SfxStyleFamily eNewFamily) { - pText->MergeParaAttribs( rAttribs, nStart, nEnd ); + ImplMakeUnique(); + return mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily); } -void OutlinerParaObject::SetVertical( BOOL bVertical ) +void OutlinerParaObject::ChangeStyleSheetName(SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName) { - pText->SetVertical( bVertical ); + ImplMakeUnique(); + mpImplOutlinerParaObject->mpEditTextObject->ChangeStyleSheetName(eFamily, rOldName, rNewName); } -BOOL OutlinerParaObject::IsVertical() const +void OutlinerParaObject::SetStyleSheets(sal_uInt16 nLevel, const XubString rNewName, const SfxStyleFamily& rNewFamily) { - return pText->IsVertical(); + const sal_uInt32 nCount(mpImplOutlinerParaObject->maParagraphDataVector.size()); + + if(nCount) + { + ImplMakeUnique(); + sal_uInt16 nDecrementer(sal::static_int_cast< sal_uInt16 >(nCount)); + + for(;nDecrementer;) + { + if(GetDepth(--nDecrementer) == nLevel) + { + mpImplOutlinerParaObject->mpEditTextObject->SetStyleSheet(nDecrementer, rNewName, rNewFamily); + } + } + } } +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/svx/source/outliner/paralist.cxx b/svx/source/outliner/paralist.cxx index 0efd519ac76a..3bc52fd8e460 100644 --- a/svx/source/outliner/paralist.cxx +++ b/svx/source/outliner/paralist.cxx @@ -59,6 +59,13 @@ ParagraphData& ParagraphData::operator=( const ParagraphData& r) return *this; } +bool ParagraphData::operator==(const ParagraphData& rCandidate) const +{ + return (nDepth == rCandidate.nDepth + && mnNumberingStartValue == rCandidate.mnNumberingStartValue + && mbParaIsNumberingRestart == rCandidate.mbParaIsNumberingRestart); +} + Paragraph::Paragraph( sal_Int16 nDDepth ) : aBulSize( -1, -1) { diff --git a/svx/source/sdr/attribute/sdrtextattribute.cxx b/svx/source/sdr/attribute/sdrtextattribute.cxx index 00185c8a88ff..394f68041d7a 100644 --- a/svx/source/sdr/attribute/sdrtextattribute.cxx +++ b/svx/source/sdr/attribute/sdrtextattribute.cxx @@ -44,6 +44,7 @@ namespace drawinglayer { SdrTextAttribute::SdrTextAttribute( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObject, XFormTextStyle eFormTextStyle, sal_Int32 aTextLeftDistance, sal_Int32 aTextUpperDistance, @@ -53,9 +54,10 @@ namespace drawinglayer bool bFitToSize, bool bHideContour, bool bBlink, - bool bScroll) + bool bScroll, + bool bInEditMode) : mrSdrText(rSdrText), - mpOutlinerParaObject(rSdrText.GetOutlinerParaObject()), + maOutlinerParaObject(rOutlinerParaObject), meFormTextStyle(eFormTextStyle), maTextLeftDistance(aTextLeftDistance), maTextUpperDistance(aTextUpperDistance), @@ -65,15 +67,14 @@ namespace drawinglayer mbFitToSize(bFitToSize), mbHideContour(bHideContour), mbBlink(bBlink), - mbScroll(bScroll) + mbScroll(bScroll), + mbInEditMode(bInEditMode) { } bool SdrTextAttribute::operator==(const SdrTextAttribute& rCandidate) const { - const bool bOutlinerParaObjectSameAddress(mpOutlinerParaObject == rCandidate.mpOutlinerParaObject); - - return (bOutlinerParaObjectSameAddress + return (getOutlinerParaObject() == rCandidate.getOutlinerParaObject() && getFormTextStyle() == rCandidate.getFormTextStyle() && getTextLeftDistance() == rCandidate.getTextLeftDistance() && getTextUpperDistance() == rCandidate.getTextUpperDistance() @@ -83,7 +84,8 @@ namespace drawinglayer && isFitToSize() == rCandidate.isFitToSize() && isHideContour() == rCandidate.isHideContour() && isBlink() == rCandidate.isBlink() - && isScroll() == rCandidate.isScroll()); + && isScroll() == rCandidate.isScroll() + && isInEditMode() == rCandidate.isInEditMode()); } void SdrTextAttribute::getBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx index 5aee1950bd04..0f82674d10a5 100644 --- a/svx/source/sdr/contact/objectcontactofpageview.cxx +++ b/svx/source/sdr/contact/objectcontactofpageview.cxx @@ -185,12 +185,24 @@ namespace sdr // update current ViewInformation2D at the ObjectContact const double fCurrentTime(getPrimitiveAnimator().GetTime()); OutputDevice& rTargetOutDev = GetPageWindow().GetPaintWindow().GetTargetOutputDevice(); - const GDIMetaFile* pMetaFile = rTargetOutDev.GetConnectMetaFile(); - const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause()); basegfx::B2DRange aViewRange; // create ViewRange - if(!bOutputToRecordingMetaFile) + if(isOutputToRecordingMetaFile()) + { + if(isOutputToPDFFile()) + { + // #i98402# if it's a PDF export, set the ClipRegion as ViewRange. This is + // mainly because SW does not use DrawingLayer Page-Oriented and if not doing this, + // all existing objects will be collected as primitives and processed. + const Rectangle aLogicClipRectangle(rDisplayInfo.GetRedrawArea().GetBoundRect()); + + aViewRange = basegfx::B2DRange( + aLogicClipRectangle.Left(), aLogicClipRectangle.Top(), + aLogicClipRectangle.Right(), aLogicClipRectangle.Bottom()); + } + } + else { // use visible pixels, but transform to world coordinates const Size aOutputSizePixel(rTargetOutDev.GetOutputSizePixel()); diff --git a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx index b129aaea137a..c48d110faaf2 100644 --- a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx @@ -38,6 +38,7 @@ #include <svx/sdr/attribute/sdrallattribute.hxx> #include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx> #include <svtools/itemset.hxx> +#include <svx/sdr/primitive2d/sdrprimitivetools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -111,6 +112,18 @@ namespace sdr delete pAttribute; } + + if(!xRetval.hasElements()) + { + // #i99123# + // Object is invisible. Create a fallback primitive for HitTest + basegfx::B2DHomMatrix aObjectMatrix; + basegfx::B2DPolyPolygon aObjectPolyPolygon; + GetRectObj().TRGetBaseGeometry(aObjectMatrix, aObjectPolyPolygon); + const drawinglayer::primitive2d::Primitive2DReference xReference( + drawinglayer::primitive2d::createFallbackHitTestPrimitive(aObjectMatrix)); + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); + } } return xRetval; diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx index 0923a223a924..dffd81dab0b9 100644 --- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx +++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx @@ -475,7 +475,7 @@ namespace drawinglayer attribute::SdrTextAttribute* createNewSdrTextAttribute(const SfxItemSet& rSet, const SdrText& rText) { - attribute::SdrTextAttribute* pRetval(0L); + attribute::SdrTextAttribute* pRetval(0); const SdrTextObj& rTextObj = rText.GetObject(); if(rText.GetOutlinerParaObject() && rText.GetModel()) @@ -492,24 +492,40 @@ namespace drawinglayer bInEditMode = rTextObj.IsInEditMode(); } - if(!bInEditMode) + OutlinerParaObject aOutlinerParaObject(*rText.GetOutlinerParaObject()); + + if(bInEditMode) { - const SdrFitToSizeType eFit = rTextObj.GetFitToSize(); - const SdrTextAniKind eAniKind(rTextObj.GetTextAniKind()); - - pRetval = new attribute::SdrTextAttribute( - rText, - ((const XFormTextStyleItem&)rSet.Get(XATTR_FORMTXTSTYLE)).GetValue(), - rTextObj.GetTextLeftDistance(), - rTextObj.GetTextUpperDistance(), - rTextObj.GetTextRightDistance(), - rTextObj.GetTextLowerDistance(), - ((const SdrTextContourFrameItem&)rSet.Get(SDRATTR_TEXT_CONTOURFRAME)).GetValue(), - (SDRTEXTFIT_PROPORTIONAL == eFit || SDRTEXTFIT_ALLLINES == eFit), - ((const XFormTextHideFormItem&)rSet.Get(XATTR_FORMTXTHIDEFORM)).GetValue(), - SDRTEXTANI_BLINK == eAniKind, - SDRTEXTANI_SCROLL == eAniKind || SDRTEXTANI_ALTERNATE == eAniKind || SDRTEXTANI_SLIDE == eAniKind); + OutlinerParaObject* pTempObj = rTextObj.GetEditOutlinerParaObject(); + + if(pTempObj) + { + aOutlinerParaObject = *pTempObj; + delete pTempObj; + } + else + { + bInEditMode = false; + } } + + const SdrFitToSizeType eFit = rTextObj.GetFitToSize(); + const SdrTextAniKind eAniKind(rTextObj.GetTextAniKind()); + + pRetval = new attribute::SdrTextAttribute( + rText, + aOutlinerParaObject, + ((const XFormTextStyleItem&)rSet.Get(XATTR_FORMTXTSTYLE)).GetValue(), + rTextObj.GetTextLeftDistance(), + rTextObj.GetTextUpperDistance(), + rTextObj.GetTextRightDistance(), + rTextObj.GetTextLowerDistance(), + ((const SdrTextContourFrameItem&)rSet.Get(SDRATTR_TEXT_CONTOURFRAME)).GetValue(), + (SDRTEXTFIT_PROPORTIONAL == eFit || SDRTEXTFIT_ALLLINES == eFit), + ((const XFormTextHideFormItem&)rSet.Get(XATTR_FORMTXTHIDEFORM)).GetValue(), + SDRTEXTANI_BLINK == eAniKind, + SDRTEXTANI_SCROLL == eAniKind || SDRTEXTANI_ALTERNATE == eAniKind || SDRTEXTANI_SLIDE == eAniKind, + bInEditMode); } return pRetval; diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx index f203cee5fa79..4a27eb73de8e 100644 --- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -54,6 +54,7 @@ #include <drawinglayer/primitive2d/maskprimitive2d.hxx> #include <basegfx/tools/canvastools.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> +#include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -205,12 +206,12 @@ namespace drawinglayer aScaledUnitPolyPolygon.transform(aScaleTransform); // create with unit polygon - pNew = new SdrContourTextPrimitive2D(rText.getSdrText(), aScaledUnitPolyPolygon, rObjectTransform); + pNew = new SdrContourTextPrimitive2D(rText.getSdrText(), rText.getOutlinerParaObject(), aScaledUnitPolyPolygon, rObjectTransform); } else { // create with unit polygon - pNew = new SdrContourTextPrimitive2D(rText.getSdrText(), rUnitPolyPolygon, rObjectTransform); + pNew = new SdrContourTextPrimitive2D(rText.getSdrText(), rText.getOutlinerParaObject(), rUnitPolyPolygon, rObjectTransform); } } else if(rText.isFontwork() && !rText.isScroll()) @@ -218,7 +219,7 @@ namespace drawinglayer // text on path, use scaled polygon. Not allowed when text scrolling is used. ::basegfx::B2DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon); aScaledPolyPolygon.transform(rObjectTransform); - pNew = new SdrPathTextPrimitive2D(rText.getSdrText(), aScaledPolyPolygon); + pNew = new SdrPathTextPrimitive2D(rText.getSdrText(), rText.getOutlinerParaObject(), aScaledPolyPolygon); } else { @@ -266,12 +267,12 @@ namespace drawinglayer if(rText.isFitToSize()) { // streched text in range - pNew = new SdrStretchTextPrimitive2D(rText.getSdrText(), aAnchorTransform); + pNew = new SdrStretchTextPrimitive2D(rText.getSdrText(), rText.getOutlinerParaObject(), aAnchorTransform); } else // text in range { // build new primitive - pNew = new SdrBlockTextPrimitive2D(rText.getSdrText(), aAnchorTransform, rText.isScroll(), bCellText, bWordWrap); + pNew = new SdrBlockTextPrimitive2D(rText.getSdrText(), rText.getOutlinerParaObject(), aAnchorTransform, rText.isScroll(), bCellText, bWordWrap); } } @@ -397,8 +398,22 @@ namespace drawinglayer } else { - // add to decomposition - return Primitive2DReference(pNew); + if(rText.isInEditMode()) + { + // #i97628# + // encapsulate with TextHierarchyEditPrimitive2D to allow renderers + // to suppress actively edited content if needed + const Primitive2DReference xRefA(pNew); + const Primitive2DSequence aContent(&xRefA, 1L); + + // create and add TextHierarchyEditPrimitive2D primitive + return Primitive2DReference(new TextHierarchyEditPrimitive2D(aContent)); + } + else + { + // add to decomposition + return Primitive2DReference(pNew); + } } } diff --git a/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx index 6726d7671a23..7f9b47afb2d4 100644 --- a/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx @@ -125,7 +125,8 @@ namespace drawinglayer } // create primitive and get text range - pBlockText = new SdrBlockTextPrimitive2D(pTextAttribute->getSdrText(), aTextMatrix, pTextAttribute->isScroll(), false, false); + pBlockText = new SdrBlockTextPrimitive2D(pTextAttribute->getSdrText(), pTextAttribute->getOutlinerParaObject(), + aTextMatrix, pTextAttribute->isScroll(), false, false); aTextRange = pBlockText->getB2DRange(aViewInformation); } diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx index e0c0068a7efa..6c665cbef4c9 100644 --- a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx +++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx @@ -33,6 +33,10 @@ #include <svx/sdr/primitive2d/sdrprimitivetools.hxx> #include <vcl/bmpacc.hxx> #include <osl/mutex.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/hittestprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// // helper methods @@ -175,6 +179,20 @@ namespace drawinglayer return *pRetVal; } + + // #i99123# + Primitive2DReference createFallbackHitTestPrimitive(const basegfx::B2DHomMatrix& rMatrix) + { + // create PolygonHairlinePrimitive2D + basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aUnitOutline.transform(rMatrix); + const basegfx::BColor aBlack(0.0, 0.0, 0.0); + const Primitive2DReference xReference(new PolygonHairlinePrimitive2D(aUnitOutline, aBlack)); + + // create HitTestPrimitive2D with it + const Primitive2DSequence xSequence(&xReference, 1); + return Primitive2DReference(new HitTestPrimitive2D(xSequence)); + } } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx index a8d8f12b5aff..113cd226d8ba 100644 --- a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx @@ -63,33 +63,30 @@ namespace drawinglayer return xRetval; } - SdrTextPrimitive2D::SdrTextPrimitive2D(const SdrText& rSdrText) + SdrTextPrimitive2D::SdrTextPrimitive2D( + const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObject) : BasePrimitive2D(), mrSdrText(rSdrText), + maOutlinerParaObject(rOutlinerParaObject), mxLastVisualizingPage(), mbLastSpellCheck(false), mbContainsPageField(false) { - if(mrSdrText.GetOutlinerParaObject()) - { - const EditTextObject& rETO = mrSdrText.GetOutlinerParaObject()->GetTextObject(); - mbContainsPageField = rETO.HasField(SvxPageField::StaticType()) - || rETO.HasField(SvxHeaderField::StaticType()) - || rETO.HasField(SvxFooterField::StaticType()) - || rETO.HasField(SvxDateTimeField::StaticType()); - } + const EditTextObject& rETO = maOutlinerParaObject.GetTextObject(); + mbContainsPageField = rETO.HasField(SvxPageField::StaticType()) + || rETO.HasField(SvxHeaderField::StaticType()) + || rETO.HasField(SvxFooterField::StaticType()) + || rETO.HasField(SvxDateTimeField::StaticType()); } bool SdrTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { if(BasePrimitive2D::operator==(rPrimitive)) { - // since OutlinerParaObject has no compare operator, i do not clone it for this class and - // use the address in the SdrText for comparison if it did change const SdrTextPrimitive2D& rCompare = (SdrTextPrimitive2D&)rPrimitive; - const bool bOutlinerParaSameAddress(getSdrText().GetOutlinerParaObject() == rCompare.getSdrText().GetOutlinerParaObject()); - return bOutlinerParaSameAddress; + return (getOutlinerParaObject() == rCompare.getOutlinerParaObject()); } return false; @@ -154,9 +151,10 @@ namespace drawinglayer SdrContourTextPrimitive2D::SdrContourTextPrimitive2D( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObject, const ::basegfx::B2DPolyPolygon& rUnitPolyPolygon, const ::basegfx::B2DHomMatrix& rObjectTransform) - : SdrTextPrimitive2D(rSdrText), + : SdrTextPrimitive2D(rSdrText, rOutlinerParaObject), maUnitPolyPolygon(rUnitPolyPolygon), maObjectTransform(rObjectTransform) { @@ -177,7 +175,7 @@ namespace drawinglayer SdrTextPrimitive2D* SdrContourTextPrimitive2D::createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const { - return new SdrContourTextPrimitive2D(getSdrText(), maUnitPolyPolygon, rTransform * maObjectTransform); + return new SdrContourTextPrimitive2D(getSdrText(), getOutlinerParaObject(), maUnitPolyPolygon, rTransform * maObjectTransform); } // provide unique ID @@ -208,8 +206,9 @@ namespace drawinglayer SdrPathTextPrimitive2D::SdrPathTextPrimitive2D( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObject, const ::basegfx::B2DPolyPolygon& rPathPolyPolygon) - : SdrTextPrimitive2D(rSdrText), + : SdrTextPrimitive2D(rSdrText, rOutlinerParaObject), maPathPolyPolygon(rPathPolyPolygon) { } @@ -230,7 +229,7 @@ namespace drawinglayer { ::basegfx::B2DPolyPolygon aNewPolyPolygon(maPathPolyPolygon); aNewPolyPolygon.transform(rTransform); - return new SdrPathTextPrimitive2D(getSdrText(), aNewPolyPolygon); + return new SdrPathTextPrimitive2D(getSdrText(), getOutlinerParaObject(), aNewPolyPolygon); } // provide unique ID @@ -261,11 +260,12 @@ namespace drawinglayer SdrBlockTextPrimitive2D::SdrBlockTextPrimitive2D( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObject, const ::basegfx::B2DHomMatrix& rTextRangeTransform, bool bUnlimitedPage, bool bCellText, bool bWordWrap) - : SdrTextPrimitive2D(rSdrText), + : SdrTextPrimitive2D(rSdrText, rOutlinerParaObject), maTextRangeTransform(rTextRangeTransform), mbUnlimitedPage(bUnlimitedPage), mbCellText(bCellText), @@ -290,7 +290,7 @@ namespace drawinglayer SdrTextPrimitive2D* SdrBlockTextPrimitive2D::createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const { - return new SdrBlockTextPrimitive2D(getSdrText(), rTransform * getTextRangeTransform(), getUnlimitedPage(), getCellText(), getWordWrap()); + return new SdrBlockTextPrimitive2D(getSdrText(), getOutlinerParaObject(), rTransform * getTextRangeTransform(), getUnlimitedPage(), getCellText(), getWordWrap()); } // provide unique ID @@ -321,8 +321,9 @@ namespace drawinglayer SdrStretchTextPrimitive2D::SdrStretchTextPrimitive2D( const SdrText& rSdrText, + const OutlinerParaObject& rOutlinerParaObject, const ::basegfx::B2DHomMatrix& rTextRangeTransform) - : SdrTextPrimitive2D(rSdrText), + : SdrTextPrimitive2D(rSdrText, rOutlinerParaObject), maTextRangeTransform(rTextRangeTransform) { } @@ -341,7 +342,7 @@ namespace drawinglayer SdrTextPrimitive2D* SdrStretchTextPrimitive2D::createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const { - return new SdrStretchTextPrimitive2D(getSdrText(), rTransform * maTextRangeTransform); + return new SdrStretchTextPrimitive2D(getSdrText(), getOutlinerParaObject(), rTransform * maTextRangeTransform); } // provide unique ID diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx index 86ce2fa9205c..68b1679dff49 100644 --- a/svx/source/svdraw/svdedtv2.cxx +++ b/svx/source/svdraw/svdedtv2.cxx @@ -1430,7 +1430,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, if(pLast && pSrcPath->GetOutlinerParaObject()) { - pLast->SetOutlinerParaObject(pSrcPath->GetOutlinerParaObject()->Clone()); + pLast->SetOutlinerParaObject(new OutlinerParaObject(*pSrcPath->GetOutlinerParaObject())); } } else if(pCustomShape) @@ -1469,7 +1469,7 @@ void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, OutlinerParaObject* pParaObj = pCustomShape->GetOutlinerParaObject(); if(pParaObj) { - pTextObj->NbcSetOutlinerParaObject(pParaObj->Clone()); + pTextObj->NbcSetOutlinerParaObject(new OutlinerParaObject(*pParaObj)); } // copy all attributes diff --git a/svx/source/svdraw/svdfppt.cxx b/svx/source/svdraw/svdfppt.cxx index 32bc5ecca46f..86d6093c8b15 100644 --- a/svx/source/svdraw/svdfppt.cxx +++ b/svx/source/svdraw/svdfppt.cxx @@ -7551,7 +7551,7 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, sal_uInt32* pTab { SdrText* pSdrText = pTable->getText( nTableIndex ); if ( pSdrText ) - pSdrText->SetOutlinerParaObject( pParaObject->Clone() ); + pSdrText->SetOutlinerParaObject(new OutlinerParaObject(*pParaObject) ); } } } diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index 194949474336..60761a2d3557 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -93,6 +93,8 @@ // #95114# #include <vcl/svapp.hxx> #include <svx/sdr/properties/properties.hxx> +#include <svx/eeitem.hxx> +#include <svtools/itemset.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -346,11 +348,11 @@ SdrModel::~SdrModel() { // Pools loeschen, falls es meine sind SfxItemPool* pOutlPool=pItemPool->GetSecondaryPool(); - delete pItemPool; + SfxItemPool::Free(pItemPool); // Der OutlinerPool muss nach dem ItemPool plattgemacht werden, da der // ItemPool SetItems enthaelt die ihrerseits Items des OutlinerPools // referenzieren (Joe) - delete pOutlPool; + SfxItemPool::Free(pOutlPool); } if( mpForbiddenCharactersTable ) diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 3f748e53ff47..70dda490a540 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -2461,7 +2461,7 @@ void SdrObjCustomShape::SetVerticalWriting( sal_Bool bVertical ) if( pOutlinerParaObject ) { - if(pOutlinerParaObject->IsVertical() != bVertical) + if(pOutlinerParaObject->IsVertical() != (bool)bVertical) { // get item settings const SfxItemSet& rSet = GetObjectItemSet(); diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 475ffbb8ea98..6ec9c607188b 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -613,8 +613,8 @@ void SdrObject::FreeGlobalDrawObjectItemPool() if(mpGlobalItemPool) { SfxItemPool* pGlobalOutlPool = mpGlobalItemPool->GetSecondaryPool(); - delete mpGlobalItemPool; - delete pGlobalOutlPool; + SfxItemPool::Free(mpGlobalItemPool); + SfxItemPool::Free(pGlobalOutlPool); } } diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 9e38a0994bad..9abf3950d694 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1341,7 +1341,7 @@ void SdrTextObj::operator=(const SdrObject& rObj) } else { - pNewOutlinerParaObject = pTextObj->getActiveText()->GetOutlinerParaObject()->Clone(); + pNewOutlinerParaObject = new OutlinerParaObject(*pTextObj->getActiveText()->GetOutlinerParaObject()); } } @@ -1717,7 +1717,7 @@ void SdrTextObj::SetVerticalWriting(sal_Bool bVertical) pOutlinerParaObject = GetOutlinerParaObject(); } - if( pOutlinerParaObject && (pOutlinerParaObject->IsVertical() != bVertical) ) + if( pOutlinerParaObject && (pOutlinerParaObject->IsVertical() != (bool)bVertical) ) { // get item settings const SfxItemSet& rSet = GetObjectItemSet(); diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index be1d19f96f4e..316cec90337f 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -662,7 +662,7 @@ bool SdrTextObj::impDecomposeContourTextPrimitive( rOutliner.SetPaperSize(aNullSize); rOutliner.SetPolygon(aPolyPolygon); rOutliner.SetUpdateMode(true); - rOutliner.SetText(*rSdrContourTextPrimitive.getSdrText().GetOutlinerParaObject()); + rOutliner.SetText(rSdrContourTextPrimitive.getOutlinerParaObject()); // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage())); @@ -729,9 +729,7 @@ bool SdrTextObj::impDecomposeBlockTextPrimitive( // add one to rage sizes to get back to the old Rectangle and outliner measurements const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1L)); const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1L)); - const OutlinerParaObject* pOutlinerParaObject = rSdrBlockTextPrimitive.getSdrText().GetOutlinerParaObject(); - OSL_ENSURE(pOutlinerParaObject, "impDecomposeBlockTextPrimitive used with no OutlinerParaObject (!)"); - const bool bVerticalWritintg(pOutlinerParaObject->IsVertical()); + const bool bVerticalWritintg(rSdrBlockTextPrimitive.getOutlinerParaObject().IsVertical()); const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight)); if(bIsCell) @@ -743,7 +741,7 @@ bool SdrTextObj::impDecomposeBlockTextPrimitive( rOutliner.SetPaperSize(aAnchorTextSize); rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0)); rOutliner.SetUpdateMode(TRUE); - rOutliner.SetText(*pOutlinerParaObject); + rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject()); rOutliner.SetUpdateMode(TRUE); rOutliner.SetControlWord(nOriginalControlWord); } @@ -766,7 +764,7 @@ bool SdrTextObj::impDecomposeBlockTextPrimitive( rOutliner.SetPaperSize(aNullSize); rOutliner.SetUpdateMode(true); - rOutliner.SetText(*pOutlinerParaObject); + rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject()); rOutliner.SetControlWord(nOriginalControlWord); } @@ -894,7 +892,7 @@ bool SdrTextObj::impDecomposeStretchTextPrimitive( rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000)); rOutliner.SetPaperSize(aNullSize); rOutliner.SetUpdateMode(true); - rOutliner.SetText(*rSdrStretchTextPrimitive.getSdrText().GetOutlinerParaObject()); + rOutliner.SetText(rSdrStretchTextPrimitive.getOutlinerParaObject()); // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage())); diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx index dd30d6ec5dba..cbf80e23c91d 100644 --- a/svx/source/svdraw/svdtext.cxx +++ b/svx/source/svdraw/svdtext.cxx @@ -39,6 +39,8 @@ #include "svx/svdoutl.hxx" #include "svx/svdmodel.hxx" #include "svx/fhgtitem.hxx" +#include <svx/eeitem.hxx> +#include <svtools/itemset.hxx> SdrText::SdrText( SdrTextObj& rObject, OutlinerParaObject* pOutlinerParaObject /* = 0 */ ) : mpOutlinerParaObject( pOutlinerParaObject ) diff --git a/svx/source/svdraw/svdtxhdl.cxx b/svx/source/svdraw/svdtxhdl.cxx index 8446b3dd6ea6..e78b85ff10d0 100644 --- a/svx/source/svdraw/svdtxhdl.cxx +++ b/svx/source/svdraw/svdtxhdl.cxx @@ -57,6 +57,7 @@ #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <svtools/itemset.hxx> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index 976f48c82194..eb52bfb62c9e 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -348,7 +348,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, FASTBOOL bStyleSheet1, FASTBO { pTextUndo = pObj->GetOutlinerParaObject(); if(pTextUndo) - pTextUndo = pTextUndo->Clone(); + pTextUndo = new OutlinerParaObject(*pTextUndo); } } } @@ -409,7 +409,7 @@ void SdrUndoAttrObj::Undo() pTextRedo = pObj->GetOutlinerParaObject(); if(pTextRedo) - pTextRedo = pTextRedo->Clone(); + pTextRedo = new OutlinerParaObject(*pTextRedo); } } @@ -470,7 +470,7 @@ void SdrUndoAttrObj::Undo() if(pTextUndo) { - pObj->SetOutlinerParaObject(pTextUndo->Clone()); + pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextUndo)); } } @@ -540,7 +540,7 @@ void SdrUndoAttrObj::Redo() // #i8508# if(pTextRedo) { - pObj->SetOutlinerParaObject(pTextRedo->Clone()); + pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextRedo)); } } @@ -1096,7 +1096,7 @@ SdrUndoObjSetText::SdrUndoObjSetText(SdrObject& rNewObj, sal_Int32 nText) { SdrText* pText = static_cast< SdrTextObj*>( &rNewObj )->getText(mnText); if( pText && pText->GetOutlinerParaObject() ) - pOldText = pText->GetOutlinerParaObject()->Clone(); + pOldText = new OutlinerParaObject(*pText->GetOutlinerParaObject()); bEmptyPresObj = rNewObj.IsEmptyPresObj(); } @@ -1115,7 +1115,7 @@ void SdrUndoObjSetText::AfterSetText() { SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText); if( pText && pText->GetOutlinerParaObject() ) - pNewText = pText->GetOutlinerParaObject()->Clone(); + pNewText = new OutlinerParaObject(*pText->GetOutlinerParaObject()); bNewTextAvailable=TRUE; } } @@ -1132,7 +1132,7 @@ void SdrUndoObjSetText::Undo() // Text fuer Undo kopieren, denn SetOutlinerParaObject() ist Eigentumsuebereignung OutlinerParaObject* pText1 = pOldText; if(pText1) - pText1 = pText1->Clone(); + pText1 = new OutlinerParaObject(*pText1); SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText); if( pText ) @@ -1148,7 +1148,7 @@ void SdrUndoObjSetText::Redo() OutlinerParaObject* pText1 = pNewText; if(pText1) - pText1 = pText1->Clone(); + pText1 = new OutlinerParaObject(*pText1); SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText); if( pText ) @@ -1192,7 +1192,7 @@ void SdrUndoObjSetText::SdrRepeat(SdrView& rView) rView.AddUndo(new SdrUndoObjSetText(*pTextObj,0)); OutlinerParaObject* pText1=pNewText; if (pText1!=NULL) - pText1=pText1->Clone(); + pText1 = new OutlinerParaObject(*pText1); pTextObj->SetOutlinerParaObject(pText1); } } diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 3063f782ae64..e7096dcc2df0 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -409,7 +409,7 @@ void Cell::replaceContentAndFormating( const CellRef& xSourceCell ) if( xSourceCell.is() && mpProperties ) { mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() ); - SetOutlinerParaObject( xSourceCell->GetOutlinerParaObject()->Clone() ); + SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) ); SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() ); SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() ); @@ -509,10 +509,7 @@ const SfxItemSet& Cell::GetObjectItemSet() else { DBG_ERROR("Cell::GetObjectItemSet(), called without properties!"); - static UniString aEmptyStr; - static SfxItemPool aEmptyPool(aEmptyStr,0,0,0); - static SfxItemSet aSet(aEmptyPool); - return aSet; + return GetObject().GetObjectItemSet(); } } diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx index 9f872fded787..f72ca2fd8927 100644 --- a/svx/source/table/tableundo.cxx +++ b/svx/source/table/tableundo.cxx @@ -132,7 +132,7 @@ void CellUndo::setDataToCell( const Data& rData ) mxCell->mpProperties = 0; if( rData.mpOutlinerParaObject ) - mxCell->SetOutlinerParaObject( rData.mpOutlinerParaObject->Clone() ); + mxCell->SetOutlinerParaObject( new OutlinerParaObject(*rData.mpOutlinerParaObject) ); else mxCell->RemoveOutlinerParaObject(); @@ -155,7 +155,7 @@ void CellUndo::getDataFromCell( Data& rData ) rData.mpProperties = mxCell->CloneProperties( *mxObjRef.get(), *mxCell.get()); if( mxCell->GetOutlinerParaObject() ) - rData.mpOutlinerParaObject = mxCell->GetOutlinerParaObject()->Clone(); + rData.mpOutlinerParaObject = new OutlinerParaObject(*mxCell->GetOutlinerParaObject()); else rData.mpOutlinerParaObject = 0; diff --git a/svx/source/unodraw/unopool.cxx b/svx/source/unodraw/unopool.cxx index f7a2134c520e..1abf930eb3ed 100644 --- a/svx/source/unodraw/unopool.cxx +++ b/svx/source/unodraw/unopool.cxx @@ -73,7 +73,7 @@ SvxUnoDrawPool::SvxUnoDrawPool( SdrModel* pModel ) throw() SvxUnoDrawPool::~SvxUnoDrawPool() throw() { - delete mpDefaultsPool; + SfxItemPool::Free(mpDefaultsPool); } void SvxUnoDrawPool::init() diff --git a/svx/source/unoedit/unotext.cxx b/svx/source/unoedit/unotext.cxx index 797d266b4e44..777e75d89b4a 100644 --- a/svx/source/unoedit/unotext.cxx +++ b/svx/source/unoedit/unotext.cxx @@ -2496,9 +2496,10 @@ String SvxDummyTextSource::GetText( const ESelection& ) const SfxItemSet SvxDummyTextSource::GetAttribs( const ESelection&, BOOL ) const { - String aDummyStr(RTL_CONSTASCII_USTRINGPARAM("Dummy")); - SfxItemPool aPool(aDummyStr,0,0,NULL); - return SfxItemSet(aPool); + // AW: Very dangerous: The former implementation used a SfxItemPool created on the + // fly which of course was deleted again ASAP. Thus, the returned SfxItemSet was using + // a deleted Pool by design. + return SfxItemSet(SdrObject::GetGlobalDrawObjectItemPool()); } SfxItemSet SvxDummyTextSource::GetParaAttribs( sal_uInt16 ) const diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx index 7b28349cac43..b304ea9a62a1 100644 --- a/svx/source/xoutdev/xtable.cxx +++ b/svx/source/xoutdev/xtable.cxx @@ -120,7 +120,7 @@ XPropertyTable::~XPropertyTable() // Eigener Pool wird geloescht if( bOwnPool && pXPool ) { - delete pXPool; + SfxItemPool::Free(pXPool); } } @@ -352,7 +352,7 @@ XPropertyList::~XPropertyList() if( bOwnPool && pXPool ) { - delete pXPool; + SfxItemPool::Free(pXPool); } } |