diff options
Diffstat (limited to 'svx')
45 files changed, 607 insertions, 376 deletions
diff --git a/svx/inc/svx/outliner.hxx b/svx/inc/svx/outliner.hxx index 6ec0054dcd..33818ccabc 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 5fdbcb61dc..f99a95aedb 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 0000000000..c998cc6291 --- /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 21cd2a26c7..6193488113 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 2312325eaa..f8d8fb3880 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; +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 e277dea965..e7903997de 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 65fa8444e5..75059d7796 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 a74f73f754..58cf4bea94 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 e55f2a5858..3b70b59970 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 1a417997b3..e19d5040b9 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 e0f2f56394..42979df0c8 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 53b2332eae..b805287785 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 19a39f0132..31d108dfe0 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 8bd094ae98..45493a700f 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 0d2e6288dc..301883042a 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 42f2fafaf0..a9d3bca341 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 5a023ac931..c61a198f47 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 13f2b0cb69..e53a3966c6 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 5a1e287d6e..deef353049 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 3e4a0ed868..988a73dab7 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 5097e944d6..554ea34004 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) + { + } + + // destructor + ~ImplOutlinerParaObject() + { + delete mpEditTextObject; + } + + bool operator==(const ImplOutlinerParaObject& rCandidate) const + { + return (*mpEditTextObject == *rCandidate.mpEditTextObject + && maParagraphDataVector == rCandidate.maParagraphDataVector + && mbIsEditDoc == rCandidate.mbIsEditDoc); + } +}; -DBG_NAME(OutlinerParaObject) +////////////////////////////////////////////////////////////////////////////// -OutlinerParaObject::OutlinerParaObject( USHORT nParaCount ) +void OutlinerParaObject::ImplMakeUnique() { - DBG_CTOR(OutlinerParaObject,0); - - bIsEditDoc = TRUE; - pParagraphDataArr = new ParagraphData[ nParaCount ]; - nCount = nParaCount; + if(mpImplOutlinerParaObject->mnRefCount) + { + ImplOutlinerParaObject* pNew = new ImplOutlinerParaObject( + mpImplOutlinerParaObject->mpEditTextObject->Clone(), + mpImplOutlinerParaObject->maParagraphDataVector, + mpImplOutlinerParaObject->mbIsEditDoc); + mpImplOutlinerParaObject->mnRefCount--; + mpImplOutlinerParaObject = pNew; + } } -OutlinerParaObject::OutlinerParaObject( const OutlinerParaObject& rObj ) +OutlinerParaObject::OutlinerParaObject(const EditTextObject& rEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc) +: mpImplOutlinerParaObject(new ImplOutlinerParaObject(rEditTextObject.Clone(), rParagraphDataVector, bIsEditDoc)) { - 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(); } -OutlinerParaObject::OutlinerParaObject( const EditTextObject& rEditObj ) +OutlinerParaObject::OutlinerParaObject(const OutlinerParaObject& rCandidate) +: mpImplOutlinerParaObject(rCandidate.mpImplOutlinerParaObject) { - DBG_CTOR(OutlinerParaObject,0); - - bIsEditDoc = TRUE; - pText = rEditObj.Clone(); - nCount = pText->GetParagraphCount(); - pParagraphDataArr = new ParagraphData[ nCount ]; + 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 5f87148176..e5493a24dc 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 7ed0fffb4a..591fcb026a 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 fa42ffc532..18db96f142 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 648e7efca0..0c6d3177b9 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 56e4550b3e..3cb131929c 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()) @@ -491,25 +491,41 @@ 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 2f768d4c54..39157f5b7f 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 6fd3e51d58..2eba93c5c0 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 8eca658c3c..1066a988ca 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 9553ff52ab..919ac76e39 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 fd86d0d861..73b4aa24b3 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 c7df32f05a..72ed6b1a3f 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 601ae1cf26..becf94e01e 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 823c1e032b..d866b4f600 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 1f934bf361..7aa383576f 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 11332376f6..043b38957c 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 ad667fa500..5d1fb9b3d1 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 afaf763540..2d513942af 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 b9d8edc855..d64dcad177 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 9fed4c8c9a..a148269343 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 40e1456ffd..5571f2cedd 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 a6c5ff1e3b..f4d6e89aec 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 3cfd6d26f8..78a0f885f9 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 e927aa33f9..aed1e631b2 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 dd457697c9..882a4a0a98 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); } } |