1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <svx/sdr/properties/textproperties.hxx>
27cdf0e10cSrcweir #include <svl/itemset.hxx>
28cdf0e10cSrcweir #include <svl/style.hxx>
29cdf0e10cSrcweir #include <svl/itemiter.hxx>
30cdf0e10cSrcweir #include <svl/smplhint.hxx>
31cdf0e10cSrcweir #include <svx/svddef.hxx>
32cdf0e10cSrcweir #include <svx/svdotext.hxx>
33cdf0e10cSrcweir #include <svx/svdoutl.hxx>
34cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx>
35cdf0e10cSrcweir #include <svx/svdmodel.hxx>
36cdf0e10cSrcweir #include <editeng/outlobj.hxx>
37cdf0e10cSrcweir #include <svx/xflclit.hxx>
38cdf0e10cSrcweir #include <editeng/adjitem.hxx>
39cdf0e10cSrcweir #include <svx/svdetc.hxx>
40cdf0e10cSrcweir #include <editeng/editeng.hxx>
41cdf0e10cSrcweir #include <editeng/flditem.hxx>
42cdf0e10cSrcweir #include <svx/xlnwtit.hxx>
43cdf0e10cSrcweir #include <svx/svdpool.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace sdr
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	namespace properties
50cdf0e10cSrcweir 	{
CreateObjectSpecificItemSet(SfxItemPool & rPool)51cdf0e10cSrcweir 		SfxItemSet& TextProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
52cdf0e10cSrcweir 		{
53cdf0e10cSrcweir 			return *(new SfxItemSet(rPool,
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 				// range from SdrAttrObj
56cdf0e10cSrcweir 				SDRATTR_START, SDRATTR_SHADOW_LAST,
57cdf0e10cSrcweir 				SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
58cdf0e10cSrcweir 				SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 				// range from SdrTextObj
61cdf0e10cSrcweir 				EE_ITEMS_START, EE_ITEMS_END,
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 				// end
64cdf0e10cSrcweir 				0, 0));
65cdf0e10cSrcweir 		}
66cdf0e10cSrcweir 
TextProperties(SdrObject & rObj)67cdf0e10cSrcweir 		TextProperties::TextProperties(SdrObject& rObj)
68cdf0e10cSrcweir 		:	AttributeProperties(rObj),
69cdf0e10cSrcweir             maVersion(0)
70cdf0e10cSrcweir 		{
71cdf0e10cSrcweir 		}
72cdf0e10cSrcweir 
TextProperties(const TextProperties & rProps,SdrObject & rObj)73cdf0e10cSrcweir 		TextProperties::TextProperties(const TextProperties& rProps, SdrObject& rObj)
74cdf0e10cSrcweir 		:	AttributeProperties(rProps, rObj),
75cdf0e10cSrcweir             maVersion(rProps.getVersion())
76cdf0e10cSrcweir 		{
77cdf0e10cSrcweir 		}
78cdf0e10cSrcweir 
~TextProperties()79cdf0e10cSrcweir 		TextProperties::~TextProperties()
80cdf0e10cSrcweir 		{
81cdf0e10cSrcweir 		}
82cdf0e10cSrcweir 
Clone(SdrObject & rObj) const83cdf0e10cSrcweir 		BaseProperties& TextProperties::Clone(SdrObject& rObj) const
84cdf0e10cSrcweir 		{
85cdf0e10cSrcweir 			return *(new TextProperties(*this, rObj));
86cdf0e10cSrcweir 		}
87cdf0e10cSrcweir 
ItemSetChanged(const SfxItemSet & rSet)88cdf0e10cSrcweir 		void TextProperties::ItemSetChanged(const SfxItemSet& rSet)
89cdf0e10cSrcweir 		{
90cdf0e10cSrcweir 			SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
91cdf0e10cSrcweir 			sal_Int32 nText = rObj.getTextCount();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir             // #i101556# ItemSet has changed -> new version
94cdf0e10cSrcweir             maVersion++;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir             while( --nText >= 0 )
97cdf0e10cSrcweir 			{
98cdf0e10cSrcweir 				SdrText* pText = rObj.getText( nText );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 				OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 				if(pParaObj)
103cdf0e10cSrcweir 				{
104cdf0e10cSrcweir 					const bool bTextEdit = rObj.IsTextEditActive() && (rObj.getActiveText() == pText);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 					// handle outliner attributes
107cdf0e10cSrcweir 					GetObjectItemSet();
108cdf0e10cSrcweir 					Outliner* pOutliner = rObj.GetTextEditOutliner();
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 					if(!bTextEdit)
111cdf0e10cSrcweir 					{
112cdf0e10cSrcweir 						pOutliner = &rObj.ImpGetDrawOutliner();
113cdf0e10cSrcweir 						pOutliner->SetText(*pParaObj);
114cdf0e10cSrcweir 					}
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 					sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 					for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
119cdf0e10cSrcweir 					{
120cdf0e10cSrcweir 						SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
121cdf0e10cSrcweir 						aSet.Put(rSet);
122cdf0e10cSrcweir 						pOutliner->SetParaAttribs(nPara, aSet);
123cdf0e10cSrcweir 					}
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 					if(!bTextEdit)
126cdf0e10cSrcweir 					{
127cdf0e10cSrcweir 						if(nParaCount)
128cdf0e10cSrcweir 						{
129cdf0e10cSrcweir 							// force ItemSet
130cdf0e10cSrcweir 							GetObjectItemSet();
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 							SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L));
133cdf0e10cSrcweir 							mpItemSet->Put(aNewSet);
134cdf0e10cSrcweir 						}
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 						OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
137cdf0e10cSrcweir 						pOutliner->Clear();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 						rObj.NbcSetOutlinerParaObjectForText(pTemp,pText);
140cdf0e10cSrcweir 					}
141cdf0e10cSrcweir 				}
142cdf0e10cSrcweir 			}
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 			// Extra-Repaint for radical layout changes (#43139#)
145cdf0e10cSrcweir 			if(SFX_ITEM_SET == rSet.GetItemState(SDRATTR_TEXT_CONTOURFRAME))
146cdf0e10cSrcweir 			{
147cdf0e10cSrcweir 				// Here only repaint wanted
148cdf0e10cSrcweir 				rObj.ActionChanged();
149cdf0e10cSrcweir 				//rObj.BroadcastObjectChange();
150cdf0e10cSrcweir 			}
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 			// call parent
153cdf0e10cSrcweir 			AttributeProperties::ItemSetChanged(rSet);
154cdf0e10cSrcweir 		}
155cdf0e10cSrcweir 
ItemChange(const sal_uInt16 nWhich,const SfxPoolItem * pNewItem)156cdf0e10cSrcweir 		void TextProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
157cdf0e10cSrcweir 		{
158cdf0e10cSrcweir 			SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 			// #i25616#
161cdf0e10cSrcweir 			sal_Int32 nOldLineWidth(0L);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 			if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange())
164cdf0e10cSrcweir 			{
165cdf0e10cSrcweir 				nOldLineWidth = ((const XLineWidthItem&)GetItem(XATTR_LINEWIDTH)).GetValue();
166cdf0e10cSrcweir 			}
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 			if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
169cdf0e10cSrcweir 			{
170cdf0e10cSrcweir 				sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue());
171cdf0e10cSrcweir 				rObj.SetVerticalWriting(bVertical);
172cdf0e10cSrcweir 			}
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 			// #95501# reset to default
175cdf0e10cSrcweir 			if(!pNewItem && !nWhich && rObj.HasText() )
176cdf0e10cSrcweir 			{
177cdf0e10cSrcweir 				SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 				sal_Int32 nCount = rObj.getTextCount();
180cdf0e10cSrcweir 				while( nCount-- )
181cdf0e10cSrcweir 				{
182cdf0e10cSrcweir 					SdrText* pText = rObj.getText( nCount );
183cdf0e10cSrcweir 					OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject();
184cdf0e10cSrcweir 					if( pParaObj )
185cdf0e10cSrcweir 					{
186cdf0e10cSrcweir 						rOutliner.SetText(*pParaObj);
187cdf0e10cSrcweir 						sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 						if(nParaCount)
190cdf0e10cSrcweir 						{
191cdf0e10cSrcweir 							ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL);
192cdf0e10cSrcweir 							rOutliner.RemoveAttribs(aSelection, sal_True, 0);
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 							OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
195cdf0e10cSrcweir 							rOutliner.Clear();
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 							rObj.NbcSetOutlinerParaObjectForText( pTemp, pText );
198cdf0e10cSrcweir 						}
199cdf0e10cSrcweir 					}
200cdf0e10cSrcweir 				}
201cdf0e10cSrcweir 			}
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 			// call parent
204cdf0e10cSrcweir 			AttributeProperties::ItemChange( nWhich, pNewItem );
205cdf0e10cSrcweir 
206cdf0e10cSrcweir 			// #i25616#
207cdf0e10cSrcweir 			if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange())
208cdf0e10cSrcweir 			{
209cdf0e10cSrcweir 				const sal_Int32 nNewLineWidth(((const XLineWidthItem&)GetItem(XATTR_LINEWIDTH)).GetValue());
210cdf0e10cSrcweir 				const sal_Int32 nDifference((nNewLineWidth - nOldLineWidth) / 2);
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 				if(nDifference)
213cdf0e10cSrcweir 				{
214cdf0e10cSrcweir 					const sal_Bool bLineVisible(XLINE_NONE != ((const XLineStyleItem&)(GetItem(XATTR_LINESTYLE))).GetValue());
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 					if(bLineVisible)
217cdf0e10cSrcweir 					{
218cdf0e10cSrcweir 						const sal_Int32 nLeftDist(((const SdrTextLeftDistItem&)GetItem(SDRATTR_TEXT_LEFTDIST)).GetValue());
219cdf0e10cSrcweir 						const sal_Int32 nRightDist(((const SdrTextRightDistItem&)GetItem(SDRATTR_TEXT_RIGHTDIST)).GetValue());
220cdf0e10cSrcweir 						const sal_Int32 nUpperDist(((const SdrTextUpperDistItem&)GetItem(SDRATTR_TEXT_UPPERDIST)).GetValue());
221cdf0e10cSrcweir 						const sal_Int32 nLowerDist(((const SdrTextLowerDistItem&)GetItem(SDRATTR_TEXT_LOWERDIST)).GetValue());
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 						SetObjectItemDirect(SdrTextLeftDistItem(nLeftDist + nDifference));
224cdf0e10cSrcweir 						SetObjectItemDirect(SdrTextRightDistItem(nRightDist + nDifference));
225cdf0e10cSrcweir 						SetObjectItemDirect(SdrTextUpperDistItem(nUpperDist + nDifference));
226cdf0e10cSrcweir 						SetObjectItemDirect(SdrTextLowerDistItem(nLowerDist + nDifference));
227cdf0e10cSrcweir 					}
228cdf0e10cSrcweir 				}
229cdf0e10cSrcweir 			}
230cdf0e10cSrcweir 		}
231cdf0e10cSrcweir 
SetStyleSheet(SfxStyleSheet * pNewStyleSheet,sal_Bool bDontRemoveHardAttr)232cdf0e10cSrcweir 		void TextProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
233cdf0e10cSrcweir 		{
234cdf0e10cSrcweir 			SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 			// call parent
237cdf0e10cSrcweir 			AttributeProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
238cdf0e10cSrcweir 
239cdf0e10cSrcweir             // #i101556# StyleSheet has changed -> new version
240cdf0e10cSrcweir             maVersion++;
241cdf0e10cSrcweir 
242cdf0e10cSrcweir             if( rObj.GetModel() /*&& !rObj.IsTextEditActive()*/ && !rObj.IsLinkedText() )
243cdf0e10cSrcweir 			{
244cdf0e10cSrcweir 				SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 				sal_Int32 nText = rObj.getTextCount();
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 				while( --nText >= 0 )
249cdf0e10cSrcweir 				{
250cdf0e10cSrcweir 					SdrText* pText = rObj.getText( nText );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 					OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
253cdf0e10cSrcweir 					if( !pParaObj )
254cdf0e10cSrcweir 						continue;
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 					// apply StyleSheet to all paragraphs
257cdf0e10cSrcweir 					rOutliner.SetText(*pParaObj);
258cdf0e10cSrcweir 					sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 					if(nParaCount)
261cdf0e10cSrcweir 					{
262cdf0e10cSrcweir 						for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
263cdf0e10cSrcweir 						{
264cdf0e10cSrcweir 							SfxItemSet* pTempSet = 0L;
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 							// since setting the stylesheet removes all para attributes
267cdf0e10cSrcweir 							if(bDontRemoveHardAttr)
268cdf0e10cSrcweir 							{
269cdf0e10cSrcweir 								// we need to remember them if we want to keep them
270cdf0e10cSrcweir 								pTempSet = new SfxItemSet(rOutliner.GetParaAttribs(nPara));
271cdf0e10cSrcweir 							}
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 							if(GetStyleSheet())
274cdf0e10cSrcweir 							{
275cdf0e10cSrcweir 								if((OBJ_OUTLINETEXT == rObj.GetTextKind()) && (SdrInventor == rObj.GetObjInventor()))
276cdf0e10cSrcweir 								{
277cdf0e10cSrcweir 									String aNewStyleSheetName(GetStyleSheet()->GetName());
278cdf0e10cSrcweir 									aNewStyleSheetName.Erase(aNewStyleSheetName.Len() - 1, 1);
279cdf0e10cSrcweir 									sal_Int16 nDepth = rOutliner.GetDepth((sal_uInt16)nPara);
280cdf0e10cSrcweir 									aNewStyleSheetName += String::CreateFromInt32( nDepth <= 0 ? 1 : nDepth + 1);
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 									SdrModel* pModel = rObj.GetModel();
283cdf0e10cSrcweir 									SfxStyleSheetBasePool* pStylePool = (pModel != NULL) ? pModel->GetStyleSheetPool() : 0L;
284cdf0e10cSrcweir 									SfxStyleSheet* pNewStyle = (SfxStyleSheet*)pStylePool->Find(aNewStyleSheetName, GetStyleSheet()->GetFamily());
285cdf0e10cSrcweir 									DBG_ASSERT( pNewStyle, "AutoStyleSheetName - Style not found!" );
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 									if(pNewStyle)
288cdf0e10cSrcweir 									{
289cdf0e10cSrcweir 										rOutliner.SetStyleSheet(nPara, pNewStyle);
290cdf0e10cSrcweir 									}
291cdf0e10cSrcweir 								}
292cdf0e10cSrcweir 								else
293cdf0e10cSrcweir 								{
294cdf0e10cSrcweir 									rOutliner.SetStyleSheet(nPara, GetStyleSheet());
295cdf0e10cSrcweir 								}
296cdf0e10cSrcweir 							}
297cdf0e10cSrcweir 							else
298cdf0e10cSrcweir 							{
299cdf0e10cSrcweir 								// remove StyleSheet
300cdf0e10cSrcweir 								rOutliner.SetStyleSheet(nPara, 0L);
301cdf0e10cSrcweir 							}
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 							if(bDontRemoveHardAttr)
304cdf0e10cSrcweir 							{
305cdf0e10cSrcweir 								if(pTempSet)
306cdf0e10cSrcweir 								{
307cdf0e10cSrcweir 									// restore para attributes
308cdf0e10cSrcweir 									rOutliner.SetParaAttribs(nPara, *pTempSet);
309cdf0e10cSrcweir 								}
310cdf0e10cSrcweir 							}
311cdf0e10cSrcweir 							else
312cdf0e10cSrcweir 							{
313cdf0e10cSrcweir 								if(pNewStyleSheet)
314cdf0e10cSrcweir 								{
315cdf0e10cSrcweir 									// remove all hard paragraph attributes
316cdf0e10cSrcweir 									// which occur in StyleSheet, take care of
317cdf0e10cSrcweir 									// parents (!)
318cdf0e10cSrcweir 									SfxItemIter aIter(pNewStyleSheet->GetItemSet());
319cdf0e10cSrcweir 									const SfxPoolItem* pItem = aIter.FirstItem();
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 									while(pItem)
322cdf0e10cSrcweir 									{
323cdf0e10cSrcweir 										if(!IsInvalidItem(pItem))
324cdf0e10cSrcweir 										{
325cdf0e10cSrcweir 											sal_uInt16 nW(pItem->Which());
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 											if(nW >= EE_ITEMS_START && nW <= EE_ITEMS_END)
328cdf0e10cSrcweir 											{
329cdf0e10cSrcweir 												rOutliner.QuickRemoveCharAttribs((sal_uInt16)nPara, nW);
330cdf0e10cSrcweir 											}
331cdf0e10cSrcweir 										}
332cdf0e10cSrcweir 										pItem = aIter.NextItem();
333cdf0e10cSrcweir 									}
334cdf0e10cSrcweir 								}
335cdf0e10cSrcweir 							}
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 							if(pTempSet)
338cdf0e10cSrcweir 							{
339cdf0e10cSrcweir 								delete pTempSet;
340cdf0e10cSrcweir 							}
341cdf0e10cSrcweir 						}
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 						OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
344cdf0e10cSrcweir 						rOutliner.Clear();
345cdf0e10cSrcweir 						rObj.NbcSetOutlinerParaObjectForText(pTemp, pText);
346cdf0e10cSrcweir 					}
347cdf0e10cSrcweir 				}
348cdf0e10cSrcweir 			}
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 			if(rObj.IsTextFrame())
351cdf0e10cSrcweir 			{
352cdf0e10cSrcweir 				rObj.NbcAdjustTextFrameWidthAndHeight();
353cdf0e10cSrcweir 			}
354cdf0e10cSrcweir 		}
355cdf0e10cSrcweir 
ForceDefaultAttributes()356cdf0e10cSrcweir 		void TextProperties::ForceDefaultAttributes()
357cdf0e10cSrcweir 		{
358cdf0e10cSrcweir 			SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 			if( rObj.GetObjInventor() == SdrInventor )
361cdf0e10cSrcweir 			{
362cdf0e10cSrcweir 				const sal_uInt16 nSdrObjKind = rObj.GetObjIdentifier();
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 				if( nSdrObjKind == OBJ_TITLETEXT || nSdrObjKind == OBJ_OUTLINETEXT )
365cdf0e10cSrcweir 					return; // no defaults for presentation objects
366cdf0e10cSrcweir 			}
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 			bool bTextFrame(rObj.IsTextFrame());
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 			// force ItemSet
371cdf0e10cSrcweir 			GetObjectItemSet();
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 			if(bTextFrame)
374cdf0e10cSrcweir 			{
375cdf0e10cSrcweir 				mpItemSet->Put(XLineStyleItem(XLINE_NONE));
376cdf0e10cSrcweir 				mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE)));
377cdf0e10cSrcweir 				mpItemSet->Put(XFillStyleItem(XFILL_NONE));
378cdf0e10cSrcweir 			}
379cdf0e10cSrcweir 			else
380cdf0e10cSrcweir 			{
381cdf0e10cSrcweir                 mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
382cdf0e10cSrcweir 				mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER));
383cdf0e10cSrcweir 				mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
384cdf0e10cSrcweir 			}
385cdf0e10cSrcweir 		}
386cdf0e10cSrcweir 
ForceStyleToHardAttributes()387cdf0e10cSrcweir 		void TextProperties::ForceStyleToHardAttributes()
388cdf0e10cSrcweir 		{
389cdf0e10cSrcweir 			// #i61284# call parent first to get the hard ObjectItemSet
390cdf0e10cSrcweir 			AttributeProperties::ForceStyleToHardAttributes();
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 			// #i61284# push hard ObjectItemSet to OutlinerParaObject attributes
393cdf0e10cSrcweir 			// using existing functionality
394cdf0e10cSrcweir 			GetObjectItemSet(); // force ItemSet
395cdf0e10cSrcweir 			ItemSetChanged(*mpItemSet);
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 			// now the standard TextProperties stuff
398cdf0e10cSrcweir 			SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 			if(rObj.GetModel()
401cdf0e10cSrcweir 				&& !rObj.IsTextEditActive()
402cdf0e10cSrcweir 				&& !rObj.IsLinkedText())
403cdf0e10cSrcweir 			{
404cdf0e10cSrcweir 				Outliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT, rObj.GetModel());
405cdf0e10cSrcweir 				sal_Int32 nText = rObj.getTextCount();
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 				while( --nText >= 0 )
408cdf0e10cSrcweir 				{
409cdf0e10cSrcweir 					SdrText* pText = rObj.getText( nText );
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 					OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
412cdf0e10cSrcweir 					if( !pParaObj )
413cdf0e10cSrcweir 						continue;
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 					pOutliner->SetText(*pParaObj);
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 					sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 					if(nParaCount)
420cdf0e10cSrcweir 					{
421cdf0e10cSrcweir 						sal_Bool bBurnIn(sal_False);
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 						for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
424cdf0e10cSrcweir 						{
425cdf0e10cSrcweir 							SfxStyleSheet* pSheet = pOutliner->GetStyleSheet(nPara);
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 							if(pSheet)
428cdf0e10cSrcweir 							{
429cdf0e10cSrcweir 								SfxItemSet aParaSet(pOutliner->GetParaAttribs(nPara));
430cdf0e10cSrcweir 								SfxItemSet aSet(*aParaSet.GetPool());
431cdf0e10cSrcweir 								aSet.Put(pSheet->GetItemSet());
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 								/** the next code handles a special case for paragraphs that contain a
434cdf0e10cSrcweir 									url field. The color for URL fields is either the system color for
435cdf0e10cSrcweir 									urls or the char color attribute that formats the portion in which the
436cdf0e10cSrcweir 									url field is contained.
437cdf0e10cSrcweir 									When we set a char color attribute to the paragraphs item set from the
438cdf0e10cSrcweir 									styles item set, we would have this char color attribute as an attribute
439cdf0e10cSrcweir 									that is spanned over the complete paragraph after xml import due to some
440cdf0e10cSrcweir 									problems in the xml import (using a XCursor on import so it does not know
441cdf0e10cSrcweir 									the paragraphs and can't set char attributes to paragraphs ).
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 									To avoid this, as soon as we try to set a char color attribute from the style
444cdf0e10cSrcweir 									we
445cdf0e10cSrcweir 									1. check if we have at least one url field in this paragraph
446cdf0e10cSrcweir 									2. if we found at least one url field, we span the char color attribute over
447cdf0e10cSrcweir 									all portions that are not url fields and remove the char color attribute
448cdf0e10cSrcweir 									from the paragraphs item set
449cdf0e10cSrcweir 								*/
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 								sal_Bool bHasURL(sal_False);
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 								if(aSet.GetItemState(EE_CHAR_COLOR) == SFX_ITEM_SET)
454cdf0e10cSrcweir 								{
455cdf0e10cSrcweir 									EditEngine* pEditEngine = const_cast<EditEngine*>(&(pOutliner->GetEditEngine()));
456cdf0e10cSrcweir 									EECharAttribArray aAttribs;
457cdf0e10cSrcweir 									pEditEngine->GetCharAttribs((sal_uInt16)nPara, aAttribs);
458cdf0e10cSrcweir 									sal_uInt16 nAttrib;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 									for(nAttrib = 0; nAttrib < aAttribs.Count(); nAttrib++)
461cdf0e10cSrcweir 									{
462cdf0e10cSrcweir 										struct EECharAttrib aAttrib(aAttribs.GetObject(nAttrib));
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 										if(EE_FEATURE_FIELD == aAttrib.pAttr->Which())
465cdf0e10cSrcweir 										{
466cdf0e10cSrcweir 											if(aAttrib.pAttr)
467cdf0e10cSrcweir 											{
468cdf0e10cSrcweir 												SvxFieldItem* pFieldItem = (SvxFieldItem*)aAttrib.pAttr;
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 												if(pFieldItem)
471cdf0e10cSrcweir 												{
472cdf0e10cSrcweir 													const SvxFieldData* pData = pFieldItem->GetField();
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 													if(pData && pData->ISA(SvxURLField))
475cdf0e10cSrcweir 													{
476cdf0e10cSrcweir 														bHasURL = sal_True;
477cdf0e10cSrcweir 														break;
478cdf0e10cSrcweir 													}
479cdf0e10cSrcweir 												}
480cdf0e10cSrcweir 											}
481cdf0e10cSrcweir 										}
482cdf0e10cSrcweir 									}
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 									if(bHasURL)
485cdf0e10cSrcweir 									{
486cdf0e10cSrcweir 										SfxItemSet aColorSet(*aSet.GetPool(), EE_CHAR_COLOR, EE_CHAR_COLOR );
487cdf0e10cSrcweir 										aColorSet.Put(aSet, sal_False);
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 										ESelection aSel((sal_uInt16)nPara, 0);
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 										for(nAttrib = 0; nAttrib < aAttribs.Count(); nAttrib++)
492cdf0e10cSrcweir 										{
493cdf0e10cSrcweir 											struct EECharAttrib aAttrib(aAttribs.GetObject(nAttrib));
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 											if(EE_FEATURE_FIELD == aAttrib.pAttr->Which())
496cdf0e10cSrcweir 											{
497cdf0e10cSrcweir 												aSel.nEndPos = aAttrib.nStart;
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 												if(aSel.nStartPos != aSel.nEndPos)
500cdf0e10cSrcweir 												{
501cdf0e10cSrcweir 													pEditEngine->QuickSetAttribs(aColorSet, aSel);
502cdf0e10cSrcweir 												}
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 												aSel.nStartPos = aAttrib.nEnd;
505cdf0e10cSrcweir 											}
506cdf0e10cSrcweir 										}
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 										aSel.nEndPos = pEditEngine->GetTextLen((sal_uInt16)nPara);
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 										if(aSel.nStartPos != aSel.nEndPos)
511cdf0e10cSrcweir 										{
512cdf0e10cSrcweir 											pEditEngine->QuickSetAttribs( aColorSet, aSel );
513cdf0e10cSrcweir 										}
514cdf0e10cSrcweir 									}
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 								}
517cdf0e10cSrcweir 
518cdf0e10cSrcweir 								aSet.Put(aParaSet, sal_False);
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 								if(bHasURL)
521cdf0e10cSrcweir 								{
522cdf0e10cSrcweir 									aSet.ClearItem(EE_CHAR_COLOR);
523cdf0e10cSrcweir 								}
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 								pOutliner->SetParaAttribs(nPara, aSet);
526cdf0e10cSrcweir 								bBurnIn = sal_True; // #i51163# Flag was set wrong
527cdf0e10cSrcweir 							}
528cdf0e10cSrcweir 						}
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 						if(bBurnIn)
531cdf0e10cSrcweir 						{
532cdf0e10cSrcweir 							OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
533cdf0e10cSrcweir 							rObj.NbcSetOutlinerParaObjectForText(pTemp,pText);
534cdf0e10cSrcweir 						}
535cdf0e10cSrcweir 					}
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 					pOutliner->Clear();
538cdf0e10cSrcweir 				}
539cdf0e10cSrcweir 				delete pOutliner;
540cdf0e10cSrcweir 			}
541cdf0e10cSrcweir 		}
542cdf0e10cSrcweir 
SetObjectItemNoBroadcast(const SfxPoolItem & rItem)543cdf0e10cSrcweir 		void TextProperties::SetObjectItemNoBroadcast(const SfxPoolItem& rItem)
544cdf0e10cSrcweir 		{
545cdf0e10cSrcweir             GetObjectItemSet();
546cdf0e10cSrcweir 			mpItemSet->Put(rItem);
547cdf0e10cSrcweir 		}
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)550cdf0e10cSrcweir 		void TextProperties::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
551cdf0e10cSrcweir 		{
552cdf0e10cSrcweir 			// call parent
553cdf0e10cSrcweir 			AttributeProperties::Notify(rBC, rHint);
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 			SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
556cdf0e10cSrcweir 			if(rObj.HasText())
557cdf0e10cSrcweir 			{
558cdf0e10cSrcweir 				if(HAS_BASE(SfxStyleSheet, &rBC))
559cdf0e10cSrcweir 				{
560cdf0e10cSrcweir 					SfxSimpleHint* pSimple = PTR_CAST(SfxSimpleHint, &rHint);
561cdf0e10cSrcweir 					sal_uInt32 nId(pSimple ? pSimple->GetId() : 0L);
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 					if(SFX_HINT_DATACHANGED == nId)
564cdf0e10cSrcweir 					{
565cdf0e10cSrcweir 						rObj.SetPortionInfoChecked(sal_False);
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 						sal_Int32 nText = rObj.getTextCount();
568cdf0e10cSrcweir 						while( --nText > 0 )
569cdf0e10cSrcweir 						{
570cdf0e10cSrcweir 							OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
571cdf0e10cSrcweir 							if( pParaObj )
572cdf0e10cSrcweir 								pParaObj->ClearPortionInfo();
573cdf0e10cSrcweir 						}
574cdf0e10cSrcweir 						rObj.SetTextSizeDirty();
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 						if(rObj.IsTextFrame() && rObj.NbcAdjustTextFrameWidthAndHeight())
577cdf0e10cSrcweir 						{
578cdf0e10cSrcweir 							// here only repaint wanted
579cdf0e10cSrcweir 							rObj.ActionChanged();
580cdf0e10cSrcweir 							//rObj.BroadcastObjectChange();
581cdf0e10cSrcweir 						}
582cdf0e10cSrcweir 
583cdf0e10cSrcweir                         // #i101556# content of StyleSheet has changed -> new version
584cdf0e10cSrcweir                         maVersion++;
585cdf0e10cSrcweir 					}
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 					if(SFX_HINT_DYING == nId)
588cdf0e10cSrcweir 					{
589cdf0e10cSrcweir 						rObj.SetPortionInfoChecked(sal_False);
590cdf0e10cSrcweir 						sal_Int32 nText = rObj.getTextCount();
591cdf0e10cSrcweir 						while( --nText > 0 )
592cdf0e10cSrcweir 						{
593cdf0e10cSrcweir 							OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
594cdf0e10cSrcweir 							if( pParaObj )
595cdf0e10cSrcweir 								pParaObj->ClearPortionInfo();
596cdf0e10cSrcweir 						}
597cdf0e10cSrcweir 					}
598cdf0e10cSrcweir 				}
599cdf0e10cSrcweir 				else if(HAS_BASE(SfxStyleSheetBasePool, &rBC))
600cdf0e10cSrcweir 				{
601cdf0e10cSrcweir 					SfxStyleSheetHintExtended* pExtendedHint = PTR_CAST(SfxStyleSheetHintExtended, &rHint);
602cdf0e10cSrcweir 
603cdf0e10cSrcweir 					if(pExtendedHint
604cdf0e10cSrcweir 						&& SFX_STYLESHEET_MODIFIED == pExtendedHint->GetHint())
605cdf0e10cSrcweir 					{
606cdf0e10cSrcweir 						String aOldName(pExtendedHint->GetOldName());
607cdf0e10cSrcweir 						String aNewName(pExtendedHint->GetStyleSheet()->GetName());
608cdf0e10cSrcweir 						SfxStyleFamily eFamily = pExtendedHint->GetStyleSheet()->GetFamily();
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 						if(!aOldName.Equals(aNewName))
611cdf0e10cSrcweir 						{
612cdf0e10cSrcweir 							sal_Int32 nText = rObj.getTextCount();
613cdf0e10cSrcweir 							while( --nText > 0 )
614cdf0e10cSrcweir 							{
615cdf0e10cSrcweir 								OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
616cdf0e10cSrcweir 								if( pParaObj )
617cdf0e10cSrcweir 									pParaObj->ChangeStyleSheetName(eFamily, aOldName, aNewName);
618cdf0e10cSrcweir 							}
619cdf0e10cSrcweir 						}
620cdf0e10cSrcweir 					}
621cdf0e10cSrcweir 				}
622cdf0e10cSrcweir 			}
623cdf0e10cSrcweir 		}
624cdf0e10cSrcweir 
625cdf0e10cSrcweir         // #i101556# Handout version information
getVersion() const626cdf0e10cSrcweir         sal_uInt32 TextProperties::getVersion() const
627cdf0e10cSrcweir         {
628cdf0e10cSrcweir             return maVersion;
629cdf0e10cSrcweir         }
630cdf0e10cSrcweir 	} // end of namespace properties
631cdf0e10cSrcweir } // end of namespace sdr
632cdf0e10cSrcweir 
633cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
634cdf0e10cSrcweir // eof
635