1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdotext.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <vcl/field.hxx>
39 #include <bf_svx/svdoattr.hxx>
43 #include <bf_svx/svdtrans.hxx> // GeoStat
46 #ifndef _DATETIME_HXX //autogen
47 #include <tools/datetime.hxx>
50 #ifndef _SVX_XTXASIT_HXX //autogen
51 #include <bf_svx/xtxasit.hxx>
54 #ifndef _SVX_TEXTIT0_HXX //autogen
55 #include <bf_svx/xtextit0.hxx>
61 //************************************************************
62 // Vorausdeklarationen
63 //************************************************************
65 class OutlinerParaObject
;
69 class ImpSdrObjTextLink
;
71 //************************************************************
73 //************************************************************
75 #define SDRUSERDATA_OBJTEXTLINK (1)
77 //************************************************************
78 // Hilfsklasse SdrTextObjGeoData
79 //************************************************************
81 class SdrTextObjGeoData
: public SdrObjGeoData
88 //************************************************************
89 // Hilfsklasse ImpSdrObjTextLinkUserData
90 //************************************************************
92 class ImpSdrObjTextLinkUserData
: public SdrObjUserData
94 friend class SdrTextObj
;
95 friend class ImpSdrObjTextLink
;
98 String aFileName
; // Name des referenzierten Dokuments
99 String aFilterName
; // ggf. ein Filter
100 DateTime aFileDate0
; // Unnoetiges neuladen vermeiden
101 ImpSdrObjTextLink
* pLink
;
102 rtl_TextEncoding eCharSet
;
106 ImpSdrObjTextLinkUserData(SdrTextObj
* pObj1
);
107 virtual ~ImpSdrObjTextLinkUserData();
109 virtual SdrObjUserData
* Clone(SdrObject
* pObj1
) const;
110 virtual void WriteData(SvStream
& rOut
);
111 virtual void ReadData(SvStream
& rIn
);
112 virtual void AfterRead();
115 //************************************************************
117 //************************************************************
119 class SdrTextObj
: public SdrAttrObj
121 friend class ImpTextPortionHandler
;
122 friend class ImpSdrObjTextLink
;
123 friend class ImpSdrObjTextLinkUserData
;
124 friend class SdrPowerPointImport
; // fuer PowerPointImport
125 friend class SdrExchangeView
; // fuer ImpGetDrawOutliner
126 friend class SdrView
; // fuer ImpGetDrawOutliner
127 friend class SdrObjEditView
; // fuer TextEdit
128 friend class SdrMeasureObj
; // fuer ImpGetDrawOutliner
129 friend class SvxMSDffManager
; // fuer ImpGetDrawOutliner
132 // Das aRect ist gleichzeig auch das Rect vom RectObj und CircObj.
133 // Bei bTextFrame=TRUE wird der Text in dieses Rect hineinformatiert.
134 // Bei bTextFrame=FALSE wird der Text am Mittelpunkt des Rect zentriert.
137 // Der GeoStat enthaelt den Drehwinkel und einen Shearwinkel
140 // Im pOutlinerParaObject steckt der Text drin
141 OutlinerParaObject
* pOutlinerParaObject
;
143 // Hier merke ich mir die Ausmasse des Textes (n.i.)
146 // Ein Outliner*, damit
147 // 1. das TextObj nicht von mehreren Views gleichzeitig editiert und
148 // 2. beim Streamen waerend des Editierens ein Flush() ausgefuehrt
150 SdrOutliner
* pEdtOutl
;
152 // Bei Fontwork muss soviel auf's BoundRect draufgerechnet werden
153 // damit es ausreichend gross ist.
154 Rectangle
* pFormTextBoundRect
;
156 // Moegliche Werte fuer eTextKind sind:
157 // OBJ_TEXT normaler Textrahmen
158 // OBJ_TEXTEXT Textfortsetzungsrahmen
159 // OBJ_TITLETEXT TitleText fuer StarDraw-Praesentation
160 // OBJ_OUTLINETEXT OutlineText fuer StarDraw-Praesentation
161 // eTextKind hat nur Bedeutung, wenn bTextFrame=TRUE, da es sich sonst
162 // um ein beschriftetes Grafikobjekt handelt.
163 SdrObjKind eTextKind
;
166 // For text editing in SW Haeder/Footer it is necessary to be
167 // able to set an offset for the text edit to allow text editing at the
168 // position of the virtual object. This offset is used when setting up
169 // and maintaining the OutlinerView.
170 Point maTextEditOffset
;
172 const Point
& GetTextEditOffset() const { return maTextEditOffset
; }
173 void SetTextEditOffset(const Point
& rNew
) { maTextEditOffset
= rNew
; }
176 // Fuer beschriftete Zeichenobjekte ist bTextFrame=FALSE. Der Textblock
177 // wird dann hoizontal und vertikal an aRect zentriert. Bei bTextFrame=
178 // TRUE wird der Text in aRect hineinformatiert. Der eigentliche Textrahmen
179 // ist durch ein SdrRectObj mit bTextFrame=TRUE realisiert.
181 BOOL bPortionInfoChecked
: 1; // Fuer Optimierung von Textobjekten
182 BOOL bNoShear
: 1; // Obj darf nicht gesheart werden (->Graf+Ole+TextFrame)
183 BOOL bNoRotate
: 1; // Obj darf nicht gedreht werden (->Ole)
184 BOOL bNoMirror
: 1; // Obj darf nicht gespiegelt werden (->Ole,TextFrame)
185 BOOL bTextSizeDirty
: 1;
188 BOOL mbInEditMode
: 1; // Is this text obejct in edit mode?
190 // Fuer Objekt mit freier Groesse im Draw (Mengentext). Das Flag wird vom
191 // der App beim Create gesetzt.
192 // Wenn das Objekt dann spaeter in der Breite resized wird, wird
193 // AutoGrowWidth abgeschaltet (Hart auf FALSE attributiert). Das Flag wird
194 // dann ebenfalls auf FALSE gesetzt, sodass sich das Objekt anschliessend
195 // wie ein normales Textobjekt verhaelt.
196 // Resize in der Breite kann sein:
197 // - Interaktives Resize in Einfach- oder Mehrfachselektion
198 // - Positions+Groesse Dialog
199 BOOL bDisableAutoWidthOnDragging
: 1;
202 void ImpCheckMasterCachable();
203 // #101029#: Extracted from ImpGetDrawOutliner()
204 void ImpInitDrawOutliner( SdrOutliner
& rOutl
) const;
205 // #101029#: Extracted from Paint()
206 SdrOutliner
& ImpGetDrawOutliner() const;
207 void ImpLinkAnmeldung();
208 void ImpLinkAbmeldung();
209 ImpSdrObjTextLinkUserData
* GetLinkUserData() const;
210 // void ImpCheckItemSetChanges(const SfxItemSet& rAttr);
213 FASTBOOL
ImpCanConvTextToCurve() const { return pOutlinerParaObject
!=NULL
&& pModel
!=NULL
&& !IsOutlText() && !IsFontwork(); }
214 void ImpConvertSetAttrAndLayer(SdrObject
* pObj
, FASTBOOL bNoSetAttr
=FALSE
) const;
215 SdrObject
* ImpConvertMakeObj(const XPolyPolygon
& rXPP
, FASTBOOL bClosed
, FASTBOOL bBezier
, FASTBOOL bNoSetAttr
=FALSE
) const;
216 SdrObject
* ImpConvertAddText(SdrObject
* pObj
, FASTBOOL bBezier
) const;
217 void ImpSetTextStyleSheetListeners();
218 void ImpAddTextToBoundRect();
219 void ImpJustifyRect(Rectangle
& rRect
) const;
220 void ImpCheckShear();
221 void SetTextSizeDirty() { bTextSizeDirty
=TRUE
; }
223 // rAnchorRect ist InOut-Parameter!
225 virtual void SFX_NOTIFY(SfxBroadcaster
& rBC
, const TypeId
& rBCType
, const SfxHint
& rHint
, const TypeId
& rHintType
);
226 virtual void SaveGeoData(SdrObjGeoData
& rGeo
) const;
227 virtual void RestGeoData(const SdrObjGeoData
& rGeo
);
228 FASTBOOL
NbcSetEckenradius(long nRad
);
229 FASTBOOL
NbcSetAutoGrowHeight(FASTBOOL bAuto
);
230 FASTBOOL
NbcSetMinTextFrameHeight(long nHgt
);
231 FASTBOOL
NbcSetMinTextFrameWidth(long nWdt
);
233 // Konstruktoren fuer beschriftete Zeichenobjekte
235 SdrTextObj(const Rectangle
& rNewRect
);
237 // Konstruktoren fuer Textrahmen
238 SdrTextObj(SdrObjKind eNewTextKind
);
239 SdrTextObj(SdrObjKind eNewTextKind
, const Rectangle
& rNewRect
);
241 virtual ~SdrTextObj();
247 BOOL
IsInEditMode() const { return mbInEditMode
; }
249 // via eCharSet kann der CharSet der vorliegenden Datei uebergeben werden.
250 // Bei RTL_TEXTENCODING_DONTKNOW wird der CharSet der aktuellen Plattform verwendet.
251 // Derzeit unterstuetzt wird ASCII und RTF wobei ich die Unterscheidung
252 // selbst treffe. rFilterName ist noch ohne Bedeutung und muss leer gelassen
254 // I.d.R. muss die App nur SetTextLink() rufen - der Rest geschieht von
255 // selbst (SfxLinkManager). Die Methode LoadText() kann ausserdem verwendet
256 // werden, um eine Datei in ein Textobjekt zu laden (ohne Verknuepfung).
257 // TextLinks koennen nicht editiert werden (allenfalls spaeter mal ReadOnly).
258 // Eine Attributierung kann nur am Textrahmen vollzogen werden.
259 FASTBOOL
IsLinkedText() const { return pPlusData
!=NULL
&& GetLinkUserData()!=NULL
; }
261 FASTBOOL
AdjustTextFrameWidthAndHeight(Rectangle
& rR
, FASTBOOL bHgt
=TRUE
, FASTBOOL bWdt
=TRUE
) const;
262 FASTBOOL
NbcAdjustTextFrameWidthAndHeight(FASTBOOL bHgt
=TRUE
, FASTBOOL bWdt
=TRUE
);
263 FASTBOOL
AdjustTextFrameWidthAndHeight(FASTBOOL bHgt
=TRUE
, FASTBOOL bWdt
=TRUE
);
264 FASTBOOL
IsTextFrame() const { return bTextFrame
; }
265 FASTBOOL
IsOutlText() const { return bTextFrame
&& (eTextKind
==OBJ_OUTLINETEXT
|| eTextKind
==OBJ_TITLETEXT
); }
266 BOOL
GetTextKind() const { return eTextKind
; }
267 FASTBOOL
HasText() const { return pEdtOutl
==NULL
? pOutlinerParaObject
!=NULL
: HasEditText(); }
268 FASTBOOL
HasEditText() const;
269 FASTBOOL
IsTextEditActive() const { return pEdtOutl
!=NULL
; }
271 /** returns true only if we are in edit mode and the user actually changed anything */
272 bool IsRealyEdited(){DBG_BF_ASSERT(0, "STRIP"); return false;}//STRIP001 bool IsRealyEdited() const;
274 void SetDisableAutoWidthOnDragging(FASTBOOL bOn
) { bDisableAutoWidthOnDragging
=bOn
; }
275 FASTBOOL
IsDisableAutoWidthOnDragging() { return bDisableAutoWidthOnDragging
; }
277 // FitToSize und Fontwork wird bei GetTextSize() nicht berueksichtigt!
278 virtual const Size
& GetTextSize() const;
280 // Gleichzeitig wird der Text in den Outliner gesetzt (ggf.
281 // der des EditOutliners) und die PaperSize gesetzt.
282 virtual void TakeTextRect( SdrOutliner
& rOutliner
, Rectangle
& rTextRect
, FASTBOOL bNoEditText
=FALSE
,
283 Rectangle
* pAnchorRect
=NULL
, BOOL bLineWidth
=TRUE
) const;
284 virtual void TakeTextAnchorRect(Rectangle
& rAnchorRect
) const;
285 const GeoStat
& GetGeoStat() const { return aGeo
; }
286 inline long GetEckenradius() const;
287 FASTBOOL
IsAutoGrowHeight() const;
288 inline long GetMinTextFrameHeight() const;
289 inline long GetMaxTextFrameHeight() const;
290 FASTBOOL
IsAutoGrowWidth() const;
291 inline long GetMinTextFrameWidth() const;
292 inline long GetMaxTextFrameWidth() const;
293 SdrFitToSizeType
GetFitToSize() const;
295 // Feststellen, ob TextFontwork
296 inline FASTBOOL
IsFontwork() const;
298 // Soll die Fontwork-Kontour versteckt werden?
299 inline FASTBOOL
IsHideContour() const;
301 // Textfluss innerhalb Kontur
302 inline FASTBOOL
IsContourTextFrame() const;
304 // Horizontale Textausrichtung
305 SdrTextHorzAdjust
GetTextHorizontalAdjust() const;
307 // Vertikale Textausrichtung
308 SdrTextVertAdjust
GetTextVerticalAdjust() const;
310 // Textrahmenabstaende
311 inline long GetTextLeftDistance() const;
312 inline long GetTextRightDistance() const;
313 inline long GetTextUpperDistance() const;
314 inline long GetTextLowerDistance() const;
315 inline SdrTextAniKind
GetTextAniKind() const;
316 inline SdrTextAniDirection
GetTextAniDirection() const;
318 virtual void SetPage(SdrPage
* pNewPage
);
319 virtual void SetModel(SdrModel
* pNewModel
);
321 // Wird zur Bestimmung des Textankerbereichs benoetigt
322 virtual void TakeUnrotatedSnapRect(Rectangle
& rRect
) const;
323 virtual SdrObject
* CheckHit(const Point
& rPnt
, USHORT nTol
, const SetOfByte
* pVisiLayer
) const;
324 virtual void operator=(const SdrObject
& rObj
);
325 virtual void TakeContour(XPolyPolygon
& rPoly
) const;
326 virtual void RecalcSnapRect();
327 virtual void NbcSetSnapRect(const Rectangle
& rRect
);
328 virtual void NbcSetLogicRect(const Rectangle
& rRect
);
329 virtual const Rectangle
& GetLogicRect() const;
330 virtual long GetRotateAngle() const;
331 virtual long GetShearAngle(FASTBOOL bVertical
=FALSE
) const;
336 virtual void NbcMove(const Size
& rSiz
);
337 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
338 virtual void NbcRotate(const Point
& rRef
, long nWink
, double sn
, double cs
);
339 virtual void NbcShear(const Point
& rRef
, long nWink
, double tn
, FASTBOOL bVShear
);
341 virtual FASTBOOL
HasTextEdit() const;
342 virtual FASTBOOL
BegTextEdit(SdrOutliner
& rOutl
);
343 virtual void EndTextEdit(SdrOutliner
& rOutl
);
344 virtual SdrObject
* CheckTextEditHit(const Point
& rPnt
, USHORT nTol
, const SetOfByte
* pVisiLayer
) const;
346 FASTBOOL
IsTextAnimated() const { return GetTextAniKind()!=SDRTEXTANI_NONE
; }
348 virtual void NbcSetOutlinerParaObject(OutlinerParaObject
* pTextObject
);
349 virtual OutlinerParaObject
* GetOutlinerParaObject() const;
350 OutlinerParaObject
* GetEditOutlinerParaObject() const;
352 virtual void NbcReformatText();
353 virtual void ReformatText();
354 virtual void RestartAnimation(SdrPageView
* pPageView
) const;
356 virtual FASTBOOL
CalcFieldValue(const SvxFieldItem
& rField
, USHORT nPara
, USHORT nPos
,
357 FASTBOOL bEdit
, Color
*& rpTxtColor
, Color
*& rpFldColor
, String
& rRet
) const;
360 virtual void NbcSetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, FASTBOOL bDontRemoveHardAttr
);
362 // private support routines for ItemSet access. NULL pointer means clear item.
363 virtual void ItemSetChanged(const SfxItemSet
& rSet
);
364 virtual void ItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
= 0);
367 virtual void WriteData(SvStream
& rOut
) const;
368 virtual void ReadData(const SdrObjIOHeader
& rHead
, SvStream
& rIn
);
370 void SetTextEditOutliner(SdrOutliner
* pOutl
) { pEdtOutl
=pOutl
; }
372 /** Setup given Outliner equivalently to SdrTextObj::Paint()
374 To setup an arbitrary Outliner in the same way as the draw
375 outliner on SdrTextObj::Paint(). Among others, the paper size,
376 control word and character stretching are initialized, such
377 that the formatting should match the screen representation.
378 The textual content of the outliner is not touched, i.e. no
379 Init() or Clear() is called on the Outliner.
382 The Outliner to setup.
385 The region to paint the outliner content into. This is useful
386 to e.g. determine the top, left position of text in shapes.
388 void SetupOutlinerFormatting( SdrOutliner
& rOutl
, Rectangle
& rPaintRect
) const;
390 /** Update given Outliner equivalently to SdrTextObj::Paint()
392 Same functionality as in SetupOutlinerFormatting(), except
393 that the outliner content is not cleared.
396 The Outliner to update.
399 The region to paint the outliner content into. This is useful
400 to e.g. determine the top, left position of text in shapes.
402 void UpdateOutlinerFormatting( SdrOutliner
& rOutl
, Rectangle
& rPaintRect
){DBG_BF_ASSERT(0, "STRIP");}//STRIP001 void UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const;
404 // pre- and postprocessing for objects for saving
405 virtual void PreSave();
407 void ForceOutlinerParaObject();
408 BOOL
IsVerticalWriting() const;
409 void SetVerticalWriting( BOOL bVertical
);
411 ////////////////////////////////////////////////////////////////////////////////////////////////////
413 // transformation interface for StarOfficeAPI. This implements support for
414 // homogen 3x3 matrices containing the transformation of the SdrObject. At the
415 // moment it contains a shearX, rotation and translation, but for setting all linear
416 // transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
418 ////////////////////////////////////////////////////////////////////////////////////////////////////
419 // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
420 // with the base geometry and returns TRUE. Otherwise it returns FALSE.
421 virtual BOOL
TRGetBaseGeometry(Matrix3D
& rMat
, XPolyPolygon
& rPolyPolygon
) const;
422 // sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
423 // If it's an SdrPathObj it will use the provided geometry information. The Polygon has
424 // to use (0,0) as upper left and will be scaled to the given size in the matrix.
425 virtual void TRSetBaseGeometry(const Matrix3D
& rMat
, const XPolyPolygon
& rPolyPolygon
);
427 // #103836# iterates over the paragraphs of a given SdrObject and removes all
428 // hard set character attributes with the which ids contained in the
430 void RemoveOutlinerCharacterAttribs( const std::vector
<sal_uInt16
>& rCharWhichIds
);
433 //************************************************************
435 //************************************************************
437 inline long SdrTextObj::GetEckenradius() const
439 return ((SdrEckenradiusItem
&)(GetItemSet().Get(SDRATTR_ECKENRADIUS
))).GetValue();
442 inline long SdrTextObj::GetMinTextFrameHeight() const
444 return ((SdrTextMinFrameHeightItem
&)(GetItemSet().Get(SDRATTR_TEXT_MINFRAMEHEIGHT
))).GetValue();
447 inline long SdrTextObj::GetMaxTextFrameHeight() const
449 return ((SdrTextMaxFrameHeightItem
&)(GetItemSet().Get(SDRATTR_TEXT_MAXFRAMEHEIGHT
))).GetValue();
452 inline long SdrTextObj::GetMinTextFrameWidth() const
454 return ((SdrTextMinFrameWidthItem
&)(GetItemSet().Get(SDRATTR_TEXT_MINFRAMEWIDTH
))).GetValue();
457 inline long SdrTextObj::GetMaxTextFrameWidth() const
459 return ((SdrTextMaxFrameWidthItem
&)(GetItemSet().Get(SDRATTR_TEXT_MAXFRAMEWIDTH
))).GetValue();
462 inline FASTBOOL
SdrTextObj::IsFontwork() const
464 return (bTextFrame
) ? FALSE
// Default ist FALSE
465 : ((XFormTextStyleItem
&)(GetItemSet().Get(XATTR_FORMTXTSTYLE
))).GetValue()!=XFT_NONE
;
468 inline FASTBOOL
SdrTextObj::IsHideContour() const
470 return (bTextFrame
) ? FALSE
// Default ist: Nein, kein HideContour; HideContour nicht bei TextFrames
471 : ((XFormTextHideFormItem
&)(GetItemSet().Get(XATTR_FORMTXTHIDEFORM
))).GetValue();
474 inline FASTBOOL
SdrTextObj::IsContourTextFrame() const
476 return (bTextFrame
) ? FALSE
// ContourFrame nicht bei normalen TextFrames
477 : ((SdrTextContourFrameItem
&)(GetItemSet().Get(SDRATTR_TEXT_CONTOURFRAME
))).GetValue();
480 inline long SdrTextObj::GetTextLeftDistance() const
482 return ((SdrTextLeftDistItem
&)(GetItemSet().Get(SDRATTR_TEXT_LEFTDIST
))).GetValue();
485 inline long SdrTextObj::GetTextRightDistance() const
487 return ((SdrTextRightDistItem
&)(GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST
))).GetValue();
490 inline long SdrTextObj::GetTextUpperDistance() const
492 return ((SdrTextUpperDistItem
&)(GetItemSet().Get(SDRATTR_TEXT_UPPERDIST
))).GetValue();
495 inline long SdrTextObj::GetTextLowerDistance() const
497 return ((SdrTextLowerDistItem
&)(GetItemSet().Get(SDRATTR_TEXT_LOWERDIST
))).GetValue();
500 inline SdrTextAniKind
SdrTextObj::GetTextAniKind() const
502 return ((SdrTextAniKindItem
&)(GetItemSet().Get(SDRATTR_TEXT_ANIKIND
))).GetValue();
505 inline SdrTextAniDirection
SdrTextObj::GetTextAniDirection() const
507 return ((SdrTextAniDirectionItem
&)(GetItemSet().Get(SDRATTR_TEXT_ANIDIRECTION
))).GetValue();
510 ////////////////////////////////////////////////////////////////////////////////////////////////////
512 }//end of namespace binfilter
513 #endif //_SVDOTEXT_HXX