1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <errhdl.hxx> // ASSERT
29cdf0e10cSrcweir #include <atrhndl.hxx>
30cdf0e10cSrcweir #include <svl/itemiter.hxx>
31cdf0e10cSrcweir #include <vcl/outdev.hxx>
32cdf0e10cSrcweir #include <editeng/cmapitem.hxx>
33cdf0e10cSrcweir #include <editeng/colritem.hxx>
34cdf0e10cSrcweir #include <editeng/cntritem.hxx>
35cdf0e10cSrcweir #include <editeng/crsditem.hxx>
36cdf0e10cSrcweir #include <editeng/escpitem.hxx>
37cdf0e10cSrcweir #include <editeng/fontitem.hxx>
38cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
39cdf0e10cSrcweir #include <editeng/kernitem.hxx>
40cdf0e10cSrcweir #include <editeng/charreliefitem.hxx>
41cdf0e10cSrcweir #include <editeng/langitem.hxx>
42cdf0e10cSrcweir #include <editeng/postitem.hxx>
43cdf0e10cSrcweir #include <editeng/shdditem.hxx>
44cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
45cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
46cdf0e10cSrcweir #include <editeng/wrlmitem.hxx>
47cdf0e10cSrcweir #include <editeng/akrnitem.hxx>
48cdf0e10cSrcweir #include <editeng/blnkitem.hxx>
49cdf0e10cSrcweir #include <editeng/charrotateitem.hxx>
50cdf0e10cSrcweir #include <editeng/emphitem.hxx>
51cdf0e10cSrcweir #include <editeng/charscaleitem.hxx>
52cdf0e10cSrcweir #include <editeng/twolinesitem.hxx>
53cdf0e10cSrcweir #include <editeng/charhiddenitem.hxx>
54cdf0e10cSrcweir #include <viewopt.hxx>
55cdf0e10cSrcweir #include <charfmt.hxx>
56cdf0e10cSrcweir #include <fchrfmt.hxx>
57cdf0e10cSrcweir #include <fmtautofmt.hxx>
58cdf0e10cSrcweir #include <editeng/brshitem.hxx>
59cdf0e10cSrcweir #include <fmtinfmt.hxx>
60cdf0e10cSrcweir #include <txtinet.hxx>
61cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
62cdf0e10cSrcweir #include <viewsh.hxx> // ViewShell
63cdf0e10cSrcweir #include <viewopt.hxx> // SwViewOptions
64cdf0e10cSrcweir
65cdf0e10cSrcweir #define STACK_INCREMENT 4
66cdf0e10cSrcweir
67cdf0e10cSrcweir /*************************************************************************
68cdf0e10cSrcweir * Attribute to Stack Mapping
69cdf0e10cSrcweir *
70cdf0e10cSrcweir * Attributes applied to a text are pushed on different stacks. For each
71cdf0e10cSrcweir * stack, the top most attribute on the stack is valid. Because some
72cdf0e10cSrcweir * kinds of attributes have to be pushed to the same stacks we map their
73cdf0e10cSrcweir * ids to stack ids
74cdf0e10cSrcweir * Attention: The first NUM_DEFAULT_VALUES ( defined in swfntcch.hxx == 35 )
75cdf0e10cSrcweir * are stored in the defaultitem-cache, if you add one, you have to increase
76cdf0e10cSrcweir * NUM_DEFAULT_VALUES.
77cdf0e10cSrcweir * Also adjust NUM_ATTRIBUTE_STACKS in atrhndl.hxx.
78cdf0e10cSrcweir *************************************************************************/
79cdf0e10cSrcweir
80cdf0e10cSrcweir const sal_uInt8 StackPos[ static_cast<sal_uInt16>(RES_TXTATR_WITHEND_END) -
81cdf0e10cSrcweir static_cast<sal_uInt16>(RES_CHRATR_BEGIN) + 1 ] =
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 0, // // 0
84cdf0e10cSrcweir 1, // RES_CHRATR_CASEMAP = RES_CHRATR_BEGIN // 1
85cdf0e10cSrcweir 0, // RES_CHRATR_CHARSETCOLOR, // 2
86cdf0e10cSrcweir 2, // RES_CHRATR_COLOR, // 3
87cdf0e10cSrcweir 3, // RES_CHRATR_CONTOUR, // 4
88cdf0e10cSrcweir 4, // RES_CHRATR_CROSSEDOUT, // 5
89cdf0e10cSrcweir 5, // RES_CHRATR_ESCAPEMENT, // 6
90cdf0e10cSrcweir 6, // RES_CHRATR_FONT, // 7
91cdf0e10cSrcweir 7, // RES_CHRATR_FONTSIZE, // 8
92cdf0e10cSrcweir 8, // RES_CHRATR_KERNING, // 9
93cdf0e10cSrcweir 9, // RES_CHRATR_LANGUAGE, // 10
94cdf0e10cSrcweir 10, // RES_CHRATR_POSTURE, // 11
95cdf0e10cSrcweir 0, // RES_CHRATR_PROPORTIONALFONTSIZE, // 12
96cdf0e10cSrcweir 11, // RES_CHRATR_SHADOWED, // 13
97cdf0e10cSrcweir 12, // RES_CHRATR_UNDERLINE, // 14
98cdf0e10cSrcweir 13, // RES_CHRATR_WEIGHT, // 15
99cdf0e10cSrcweir 14, // RES_CHRATR_WORDLINEMODE, // 16
100cdf0e10cSrcweir 15, // RES_CHRATR_AUTOKERN, // 17
101cdf0e10cSrcweir 16, // RES_CHRATR_BLINK, // 18
102cdf0e10cSrcweir 17, // RES_CHRATR_NOHYPHEN, // 19
103cdf0e10cSrcweir 0, // RES_CHRATR_NOLINEBREAK, // 20
104cdf0e10cSrcweir 18, // RES_CHRATR_BACKGROUND, // 21
105cdf0e10cSrcweir 19, // RES_CHRATR_CJK_FONT, // 22
106cdf0e10cSrcweir 20, // RES_CHRATR_CJK_FONTSIZE, // 23
107cdf0e10cSrcweir 21, // RES_CHRATR_CJK_LANGUAGE, // 24
108cdf0e10cSrcweir 22, // RES_CHRATR_CJK_POSTURE, // 25
109cdf0e10cSrcweir 23, // RES_CHRATR_CJK_WEIGHT, // 26
110cdf0e10cSrcweir 24, // RES_CHRATR_CTL_FONT, // 27
111cdf0e10cSrcweir 25, // RES_CHRATR_CTL_FONTSIZE, // 28
112cdf0e10cSrcweir 26, // RES_CHRATR_CTL_LANGUAGE, // 29
113cdf0e10cSrcweir 27, // RES_CHRATR_CTL_POSTURE, // 30
114cdf0e10cSrcweir 28, // RES_CHRATR_CTL_WEIGHT, // 31
115cdf0e10cSrcweir 29, // RES_CHRATR_ROTATE, // 32
116cdf0e10cSrcweir 30, // RES_CHRATR_EMPHASIS_MARK, // 33
117cdf0e10cSrcweir 31, // RES_CHRATR_TWO_LINES, // 34
118cdf0e10cSrcweir 32, // RES_CHRATR_SCALEW, // 35
119cdf0e10cSrcweir 33, // RES_CHRATR_RELIEF, // 36
120cdf0e10cSrcweir 34, // RES_CHRATR_HIDDEN, // 37
121cdf0e10cSrcweir 35, // RES_CHRATR_OVERLINE, // 38
122cdf0e10cSrcweir 0, // RES_CHRATR_DUMMY1, // 39
123cdf0e10cSrcweir 0, // RES_CHRATR_DUMMY2, // 40
124c0286415SOliver-Rainer Wittmann 0, // RES_CHRATR_BIDIRTL // 41
125c0286415SOliver-Rainer Wittmann 0, // RES_CHRATR_IDCTHINT // 42
126c0286415SOliver-Rainer Wittmann 36, // RES_TXTATR_REFMARK, // 43
127c0286415SOliver-Rainer Wittmann 37, // RES_TXTATR_TOXMARK, // 44
128c0286415SOliver-Rainer Wittmann 38, // RES_TXTATR_META, // 45
129c0286415SOliver-Rainer Wittmann 38, // RES_TXTATR_METAFIELD, // 46
130c0286415SOliver-Rainer Wittmann 0, // RES_TXTATR_AUTOFMT, // 47
131c0286415SOliver-Rainer Wittmann 0, // RES_TXTATR_INETFMT // 48
132c0286415SOliver-Rainer Wittmann 0, // RES_TXTATR_CHARFMT, // 49
133c0286415SOliver-Rainer Wittmann 39, // RES_TXTATR_CJK_RUBY, // 50
134c0286415SOliver-Rainer Wittmann 0, // RES_TXTATR_UNKNOWN_CONTAINER, // 51
135*69a74367SOliver-Rainer Wittmann 40, // RES_TXTATR_INPUTFIELD // 52
136cdf0e10cSrcweir };
137cdf0e10cSrcweir
138cdf0e10cSrcweir /*************************************************************************
139cdf0e10cSrcweir * CharFmt::GetItem
140cdf0e10cSrcweir * returns the item set associated with an character/inet/auto style
141cdf0e10cSrcweir *************************************************************************/
142cdf0e10cSrcweir
143cdf0e10cSrcweir namespace CharFmt
144cdf0e10cSrcweir {
145cdf0e10cSrcweir
GetItemSet(const SfxPoolItem & rAttr)146cdf0e10cSrcweir const SfxItemSet* GetItemSet( const SfxPoolItem& rAttr )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir const SfxItemSet* pSet = 0;
149cdf0e10cSrcweir
150cdf0e10cSrcweir if ( RES_TXTATR_AUTOFMT == rAttr.Which() )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir pSet = static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle().get();
153cdf0e10cSrcweir }
154cdf0e10cSrcweir else
155cdf0e10cSrcweir {
156cdf0e10cSrcweir // aus der Vorlage die Attribute holen:
157cdf0e10cSrcweir SwCharFmt* pFmt = RES_TXTATR_INETFMT == rAttr.Which() ?
158cdf0e10cSrcweir ((SwFmtINetFmt&)rAttr).GetTxtINetFmt()->GetCharFmt() :
159cdf0e10cSrcweir ((SwFmtCharFmt&)rAttr).GetCharFmt();
160cdf0e10cSrcweir if( pFmt )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir pSet = &pFmt->GetAttrSet();
163cdf0e10cSrcweir }
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
166cdf0e10cSrcweir return pSet;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir /*************************************************************************
170cdf0e10cSrcweir * CharFmt::GetItem
171cdf0e10cSrcweir * extracts pool item of type nWhich from rAttr
172cdf0e10cSrcweir *************************************************************************/
173cdf0e10cSrcweir
GetItem(const SwTxtAttr & rAttr,sal_uInt16 nWhich)174cdf0e10cSrcweir const SfxPoolItem* GetItem( const SwTxtAttr& rAttr, sal_uInt16 nWhich )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir if ( RES_TXTATR_INETFMT == rAttr.Which() ||
177cdf0e10cSrcweir RES_TXTATR_CHARFMT == rAttr.Which() ||
178cdf0e10cSrcweir RES_TXTATR_AUTOFMT == rAttr.Which() )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir const SfxItemSet* pSet = CharFmt::GetItemSet( rAttr.GetAttr() );
181cdf0e10cSrcweir if ( !pSet ) return 0;
182cdf0e10cSrcweir
183cdf0e10cSrcweir bool bInParent = RES_TXTATR_AUTOFMT != rAttr.Which();
184cdf0e10cSrcweir const SfxPoolItem* pItem;
185cdf0e10cSrcweir sal_Bool bRet = SFX_ITEM_SET == pSet->GetItemState( nWhich, bInParent, &pItem );
186cdf0e10cSrcweir
187cdf0e10cSrcweir return bRet ? pItem : 0;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir
190cdf0e10cSrcweir return ( nWhich == rAttr.Which() ) ? &rAttr.GetAttr() : 0;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir /*************************************************************************
194cdf0e10cSrcweir * CharFmt::IsItemIncluded
195cdf0e10cSrcweir * checks if item is included in character/inet/auto style
196cdf0e10cSrcweir *************************************************************************/
197cdf0e10cSrcweir
IsItemIncluded(const sal_uInt16 nWhich,const SwTxtAttr * pAttr)198cdf0e10cSrcweir sal_Bool IsItemIncluded( const sal_uInt16 nWhich, const SwTxtAttr *pAttr )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir sal_Bool bRet = sal_False;
201cdf0e10cSrcweir
202cdf0e10cSrcweir const SfxItemSet* pItemSet = CharFmt::GetItemSet( pAttr->GetAttr() );
203cdf0e10cSrcweir if ( pItemSet )
204cdf0e10cSrcweir bRet = SFX_ITEM_SET == pItemSet->GetItemState( nWhich, sal_True );
205cdf0e10cSrcweir
206cdf0e10cSrcweir return bRet;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir /*************************************************************************
212cdf0e10cSrcweir * lcl_ChgHyperLinkColor
213cdf0e10cSrcweir * The color of hyperlinks is taken from the associated character attribute,
214cdf0e10cSrcweir * depending on its 'visited' state. There are actually two cases, which
215cdf0e10cSrcweir * should override the colors from the character attribute:
216cdf0e10cSrcweir * 1. We never take the 'visited' color during printing/pdf export/preview
217cdf0e10cSrcweir * 2. The user has choosen to override these colors in the view options
218cdf0e10cSrcweir *************************************************************************/
219cdf0e10cSrcweir
lcl_ChgHyperLinkColor(const SwTxtAttr & rAttr,const SfxPoolItem & rItem,const ViewShell * pShell,Color * pColor)220cdf0e10cSrcweir bool lcl_ChgHyperLinkColor( const SwTxtAttr& rAttr,
221cdf0e10cSrcweir const SfxPoolItem& rItem,
222cdf0e10cSrcweir const ViewShell* pShell,
223cdf0e10cSrcweir Color* pColor )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir if ( !pShell ||
226cdf0e10cSrcweir RES_TXTATR_INETFMT != rAttr.Which() ||
227cdf0e10cSrcweir RES_CHRATR_COLOR != rItem.Which() )
228cdf0e10cSrcweir return false;
229cdf0e10cSrcweir
230cdf0e10cSrcweir // --> FME 2004-09-13 #i15455#
231cdf0e10cSrcweir // 1. case:
232cdf0e10cSrcweir // We do not want to show visited links:
233cdf0e10cSrcweir // (printing, pdf export, page preview)
234cdf0e10cSrcweir //
235cdf0e10cSrcweir if ( pShell->GetOut()->GetOutDevType() == OUTDEV_PRINTER ||
236cdf0e10cSrcweir pShell->GetViewOptions()->IsPDFExport() ||
237cdf0e10cSrcweir pShell->GetViewOptions()->IsPagePreview() )
238cdf0e10cSrcweir {
239cdf0e10cSrcweir if ( ((SwTxtINetFmt&)rAttr).IsVisited() )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir if ( pColor )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir // take color from character format 'unvisited link'
244cdf0e10cSrcweir SwTxtINetFmt& rInetAttr( const_cast<SwTxtINetFmt&>(
245cdf0e10cSrcweir static_cast<const SwTxtINetFmt&>(rAttr)) );
246cdf0e10cSrcweir rInetAttr.SetVisited( false );
247cdf0e10cSrcweir const SwCharFmt* pTmpFmt = ((SwTxtINetFmt&)rAttr).GetCharFmt();
248cdf0e10cSrcweir const SfxPoolItem* pItem;
249cdf0e10cSrcweir pTmpFmt->GetItemState( RES_CHRATR_COLOR, sal_True, &pItem );
250cdf0e10cSrcweir *pColor = ((SvxColorItem*)pItem)->GetValue();
251cdf0e10cSrcweir rInetAttr.SetVisited( true );
252cdf0e10cSrcweir }
253cdf0e10cSrcweir return true;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir
256cdf0e10cSrcweir return false;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir // <--
259cdf0e10cSrcweir
260cdf0e10cSrcweir //
261cdf0e10cSrcweir // 2. case:
262cdf0e10cSrcweir // We do not want to apply the color set in the hyperlink
263cdf0e10cSrcweir // attribute, instead we take the colors from the view options:
264cdf0e10cSrcweir //
265cdf0e10cSrcweir if ( pShell->GetWin() &&
266cdf0e10cSrcweir (
267cdf0e10cSrcweir (((SwTxtINetFmt&)rAttr).IsVisited() && SwViewOption::IsVisitedLinks()) ||
268cdf0e10cSrcweir (!((SwTxtINetFmt&)rAttr).IsVisited() && SwViewOption::IsLinks())
269cdf0e10cSrcweir )
270cdf0e10cSrcweir )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir if ( pColor )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir if ( ((SwTxtINetFmt&)rAttr).IsVisited() )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir // take color from view option 'visited link color'
277cdf0e10cSrcweir *pColor = SwViewOption::GetVisitedLinksColor();
278cdf0e10cSrcweir }
279cdf0e10cSrcweir else
280cdf0e10cSrcweir {
281cdf0e10cSrcweir // take color from view option 'unvisited link color'
282cdf0e10cSrcweir *pColor = SwViewOption::GetLinksColor();
283cdf0e10cSrcweir }
284cdf0e10cSrcweir }
285cdf0e10cSrcweir return true;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir
288cdf0e10cSrcweir return false;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
291cdf0e10cSrcweir /*************************************************************************
292cdf0e10cSrcweir * SwAttrHandler::SwAttrStack::SwAttrStack()
293cdf0e10cSrcweir *************************************************************************/
294cdf0e10cSrcweir
SwAttrStack()295cdf0e10cSrcweir inline SwAttrHandler::SwAttrStack::SwAttrStack()
296cdf0e10cSrcweir : nCount( 0 ), nSize( INITIAL_NUM_ATTR )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir pArray = pInitialArray;
299cdf0e10cSrcweir }
300cdf0e10cSrcweir
301cdf0e10cSrcweir /*************************************************************************
302cdf0e10cSrcweir * SwAttrHandler::SwAttrStack::Insert()
303cdf0e10cSrcweir *************************************************************************/
304cdf0e10cSrcweir
Insert(const SwTxtAttr & rAttr,const sal_uInt16 nPos)305cdf0e10cSrcweir void SwAttrHandler::SwAttrStack::Insert( const SwTxtAttr& rAttr, const sal_uInt16 nPos )
306cdf0e10cSrcweir {
307cdf0e10cSrcweir // do we still have enough space?
308cdf0e10cSrcweir if ( nCount >= nSize )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir // we are still in our initial array
311cdf0e10cSrcweir if ( INITIAL_NUM_ATTR == nSize )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir nSize += STACK_INCREMENT;
314cdf0e10cSrcweir pArray = new SwTxtAttr*[ nSize ];
315cdf0e10cSrcweir // copy from pInitArray to new Array
316cdf0e10cSrcweir memcpy( pArray, pInitialArray,
317cdf0e10cSrcweir INITIAL_NUM_ATTR * sizeof(SwTxtAttr*)
318cdf0e10cSrcweir );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir // we are in new memory
321cdf0e10cSrcweir else
322cdf0e10cSrcweir {
323cdf0e10cSrcweir nSize += STACK_INCREMENT;
324cdf0e10cSrcweir SwTxtAttr** pTmpArray = new SwTxtAttr*[ nSize ];
325cdf0e10cSrcweir // copy from pArray to new Array
326cdf0e10cSrcweir memcpy( pTmpArray, pArray, nCount * sizeof(SwTxtAttr*) );
327cdf0e10cSrcweir // free old array
328cdf0e10cSrcweir delete [] pArray;
329cdf0e10cSrcweir pArray = pTmpArray;
330cdf0e10cSrcweir }
331cdf0e10cSrcweir }
332cdf0e10cSrcweir
333cdf0e10cSrcweir ASSERT( nPos <= nCount, "wrong position for insert operation");
334cdf0e10cSrcweir
335cdf0e10cSrcweir if ( nPos < nCount )
336cdf0e10cSrcweir memmove( pArray + nPos + 1, pArray + nPos,
337cdf0e10cSrcweir ( nCount - nPos ) * sizeof(SwTxtAttr*)
338cdf0e10cSrcweir );
339cdf0e10cSrcweir pArray[ nPos ] = (SwTxtAttr*)&rAttr;
340cdf0e10cSrcweir
341cdf0e10cSrcweir nCount++;
342cdf0e10cSrcweir }
343cdf0e10cSrcweir
344cdf0e10cSrcweir /*************************************************************************
345cdf0e10cSrcweir * SwAttrHandler::SwAttrStack::Remove()
346cdf0e10cSrcweir *************************************************************************/
347cdf0e10cSrcweir
Remove(const SwTxtAttr & rAttr)348cdf0e10cSrcweir void SwAttrHandler::SwAttrStack::Remove( const SwTxtAttr& rAttr )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir sal_uInt16 nPos = Pos( rAttr );
351cdf0e10cSrcweir if ( nPos < nCount )
352cdf0e10cSrcweir {
353cdf0e10cSrcweir memmove( pArray + nPos, pArray + nPos + 1,
354cdf0e10cSrcweir ( nCount - 1 - nPos ) * sizeof(SwTxtAttr*)
355cdf0e10cSrcweir );
356cdf0e10cSrcweir nCount--;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir }
359cdf0e10cSrcweir
360cdf0e10cSrcweir /*************************************************************************
361cdf0e10cSrcweir * SwAttrHandler::SwAttrStack::Top()
362cdf0e10cSrcweir *************************************************************************/
363cdf0e10cSrcweir
Top() const364cdf0e10cSrcweir const SwTxtAttr* SwAttrHandler::SwAttrStack::Top() const
365cdf0e10cSrcweir {
366cdf0e10cSrcweir return nCount ? pArray[ nCount - 1 ] : 0;
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir /*************************************************************************
370cdf0e10cSrcweir * SwAttrHandler::SwAttrStack::Pos()
371cdf0e10cSrcweir *************************************************************************/
372cdf0e10cSrcweir
Pos(const SwTxtAttr & rAttr) const373cdf0e10cSrcweir sal_uInt16 SwAttrHandler::SwAttrStack::Pos( const SwTxtAttr& rAttr ) const
374cdf0e10cSrcweir {
375cdf0e10cSrcweir if ( ! nCount )
376cdf0e10cSrcweir // empty stack
377cdf0e10cSrcweir return USHRT_MAX;
378cdf0e10cSrcweir
379cdf0e10cSrcweir for ( sal_uInt16 nIdx = nCount; nIdx > 0; )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir if ( &rAttr == pArray[ --nIdx ] )
382cdf0e10cSrcweir return nIdx;
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385cdf0e10cSrcweir // element not found
386cdf0e10cSrcweir return USHRT_MAX;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir
389cdf0e10cSrcweir /*************************************************************************
390cdf0e10cSrcweir * SwAttrHandler::SwAttrHandler()
391cdf0e10cSrcweir *************************************************************************/
392cdf0e10cSrcweir
SwAttrHandler()393cdf0e10cSrcweir SwAttrHandler::SwAttrHandler() : mpShell( 0 ), pFnt( 0 ), bVertLayout( sal_False )
394cdf0e10cSrcweir
395cdf0e10cSrcweir {
396cdf0e10cSrcweir memset( pDefaultArray, 0, NUM_DEFAULT_VALUES * sizeof(SfxPoolItem*) );
397cdf0e10cSrcweir }
398cdf0e10cSrcweir
~SwAttrHandler()399cdf0e10cSrcweir SwAttrHandler::~SwAttrHandler()
400cdf0e10cSrcweir {
401cdf0e10cSrcweir delete pFnt;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir
404cdf0e10cSrcweir /*************************************************************************
405cdf0e10cSrcweir * SwAttrHandler::Init()
406cdf0e10cSrcweir *************************************************************************/
407cdf0e10cSrcweir
Init(const SwAttrSet & rAttrSet,const IDocumentSettingAccess & rIDocumentSettingAcces,const ViewShell * pSh)408cdf0e10cSrcweir void SwAttrHandler::Init( const SwAttrSet& rAttrSet,
409cdf0e10cSrcweir const IDocumentSettingAccess& rIDocumentSettingAcces,
410cdf0e10cSrcweir const ViewShell* pSh )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir mpIDocumentSettingAccess = &rIDocumentSettingAcces;
413cdf0e10cSrcweir mpShell = pSh;
414cdf0e10cSrcweir
415cdf0e10cSrcweir for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++ )
416cdf0e10cSrcweir pDefaultArray[ StackPos[ i ] ] = &rAttrSet.Get( i, sal_True );
417cdf0e10cSrcweir }
418cdf0e10cSrcweir
Init(const SfxPoolItem ** pPoolItem,const SwAttrSet * pAS,const IDocumentSettingAccess & rIDocumentSettingAcces,const ViewShell * pSh,SwFont & rFnt,sal_Bool bVL)419cdf0e10cSrcweir void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
420cdf0e10cSrcweir const IDocumentSettingAccess& rIDocumentSettingAcces,
421cdf0e10cSrcweir const ViewShell* pSh,
422cdf0e10cSrcweir SwFont& rFnt, sal_Bool bVL )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir // initialize default array
425cdf0e10cSrcweir memcpy( pDefaultArray, pPoolItem,
426cdf0e10cSrcweir NUM_DEFAULT_VALUES * sizeof(SfxPoolItem*) );
427cdf0e10cSrcweir
428cdf0e10cSrcweir mpIDocumentSettingAccess = &rIDocumentSettingAcces;
429cdf0e10cSrcweir mpShell = pSh;
430cdf0e10cSrcweir
431cdf0e10cSrcweir // do we have to apply additional paragraph attributes?
432cdf0e10cSrcweir bVertLayout = bVL;
433cdf0e10cSrcweir
434cdf0e10cSrcweir if ( pAS && pAS->Count() )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir SfxItemIter aIter( *pAS );
437cdf0e10cSrcweir sal_uInt16 nWhich;
438cdf0e10cSrcweir const SfxPoolItem* pItem = aIter.GetCurItem();
439cdf0e10cSrcweir while( sal_True )
440cdf0e10cSrcweir {
441cdf0e10cSrcweir nWhich = pItem->Which();
442cdf0e10cSrcweir if (isCHRATR(nWhich))
443cdf0e10cSrcweir {
444cdf0e10cSrcweir pDefaultArray[ StackPos[ nWhich ] ] = pItem;
445cdf0e10cSrcweir FontChg( *pItem, rFnt, sal_True );
446cdf0e10cSrcweir }
447cdf0e10cSrcweir
448cdf0e10cSrcweir if( aIter.IsAtEnd() )
449cdf0e10cSrcweir break;
450cdf0e10cSrcweir
451cdf0e10cSrcweir pItem = aIter.NextItem();
452cdf0e10cSrcweir }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir // It is possible, that Init is called more than once, e.g., in a
456cdf0e10cSrcweir // SwTxtFrm::FormatOnceMore situation.
457cdf0e10cSrcweir delete pFnt;
458cdf0e10cSrcweir pFnt = new SwFont( rFnt );
459cdf0e10cSrcweir }
460cdf0e10cSrcweir
Reset()461cdf0e10cSrcweir void SwAttrHandler::Reset( )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < NUM_ATTRIBUTE_STACKS; i++ )
464cdf0e10cSrcweir aAttrStack[ i ].Reset();
465cdf0e10cSrcweir }
466cdf0e10cSrcweir
467cdf0e10cSrcweir /*************************************************************************
468cdf0e10cSrcweir * SwAttrHandler::PushAndChg()
469cdf0e10cSrcweir *************************************************************************/
470cdf0e10cSrcweir
PushAndChg(const SwTxtAttr & rAttr,SwFont & rFnt)471cdf0e10cSrcweir void SwAttrHandler::PushAndChg( const SwTxtAttr& rAttr, SwFont& rFnt )
472cdf0e10cSrcweir {
473cdf0e10cSrcweir // these special attributes in fact represent a collection of attributes
474cdf0e10cSrcweir // they have to be pushed to each stack they belong to
475cdf0e10cSrcweir if ( RES_TXTATR_INETFMT == rAttr.Which() ||
476cdf0e10cSrcweir RES_TXTATR_CHARFMT == rAttr.Which() ||
477cdf0e10cSrcweir RES_TXTATR_AUTOFMT == rAttr.Which() )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir const SfxItemSet* pSet = CharFmt::GetItemSet( rAttr.GetAttr() );
480cdf0e10cSrcweir if ( !pSet ) return;
481cdf0e10cSrcweir
482cdf0e10cSrcweir for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++)
483cdf0e10cSrcweir {
484cdf0e10cSrcweir const SfxPoolItem* pItem;
485cdf0e10cSrcweir sal_Bool bRet = SFX_ITEM_SET == pSet->GetItemState( i, rAttr.Which() != RES_TXTATR_AUTOFMT, &pItem );
486cdf0e10cSrcweir
487cdf0e10cSrcweir if ( bRet )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir // we push rAttr onto the appropriate stack
490cdf0e10cSrcweir if ( Push( rAttr, *pItem ) )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir // we let pItem change rFnt
493cdf0e10cSrcweir Color aColor;
494cdf0e10cSrcweir if ( lcl_ChgHyperLinkColor( rAttr, *pItem, mpShell, &aColor ) )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir SvxColorItem aItemNext( aColor, RES_CHRATR_COLOR );
497cdf0e10cSrcweir FontChg( aItemNext, rFnt, sal_True );
498cdf0e10cSrcweir }
499cdf0e10cSrcweir else
500cdf0e10cSrcweir FontChg( *pItem, rFnt, sal_True );
501cdf0e10cSrcweir }
502cdf0e10cSrcweir }
503cdf0e10cSrcweir }
504cdf0e10cSrcweir }
505cdf0e10cSrcweir // this is the usual case, we have a basic attribute, push it onto the
506cdf0e10cSrcweir // stack and change the font
507cdf0e10cSrcweir else
508cdf0e10cSrcweir {
509cdf0e10cSrcweir if ( Push( rAttr, rAttr.GetAttr() ) )
510cdf0e10cSrcweir // we let pItem change rFnt
511cdf0e10cSrcweir FontChg( rAttr.GetAttr(), rFnt, sal_True );
512cdf0e10cSrcweir }
513cdf0e10cSrcweir }
514cdf0e10cSrcweir
515cdf0e10cSrcweir /*************************************************************************
516cdf0e10cSrcweir * SwAttrHandler::Push()
517cdf0e10cSrcweir *************************************************************************/
518cdf0e10cSrcweir
Push(const SwTxtAttr & rAttr,const SfxPoolItem & rItem)519cdf0e10cSrcweir sal_Bool SwAttrHandler::Push( const SwTxtAttr& rAttr, const SfxPoolItem& rItem )
520cdf0e10cSrcweir {
521cdf0e10cSrcweir ASSERT( rItem.Which() < RES_TXTATR_WITHEND_END,
522cdf0e10cSrcweir "I do not want this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
523cdf0e10cSrcweir
524cdf0e10cSrcweir // robust
525cdf0e10cSrcweir if ( RES_TXTATR_WITHEND_END <= rItem.Which() )
526cdf0e10cSrcweir return sal_False;
527cdf0e10cSrcweir
528*69a74367SOliver-Rainer Wittmann const sal_uInt16 nStack = StackPos[ rItem.Which() ];
529cdf0e10cSrcweir
530cdf0e10cSrcweir // attributes originating from redlining have highest priority
531cdf0e10cSrcweir // second priority are hyperlink attributes, which have a color replacement
532cdf0e10cSrcweir const SwTxtAttr* pTopAttr = aAttrStack[ nStack ].Top();
533*69a74367SOliver-Rainer Wittmann if ( !pTopAttr
534*69a74367SOliver-Rainer Wittmann || rAttr.IsPriorityAttr()
535*69a74367SOliver-Rainer Wittmann || ( !pTopAttr->IsPriorityAttr()
536*69a74367SOliver-Rainer Wittmann && !lcl_ChgHyperLinkColor( *pTopAttr, rItem, mpShell, 0 ) ) )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir aAttrStack[ nStack ].Push( rAttr );
539cdf0e10cSrcweir return sal_True;
540cdf0e10cSrcweir }
541cdf0e10cSrcweir
542*69a74367SOliver-Rainer Wittmann const sal_uInt16 nPos = aAttrStack[ nStack ].Count();
543cdf0e10cSrcweir ASSERT( nPos, "empty stack?" );
544cdf0e10cSrcweir aAttrStack[ nStack ].Insert( rAttr, nPos - 1 );
545cdf0e10cSrcweir return sal_False;
546cdf0e10cSrcweir }
547cdf0e10cSrcweir
548cdf0e10cSrcweir /*************************************************************************
549cdf0e10cSrcweir * SwAttrHandler::PopAndChg()
550cdf0e10cSrcweir *************************************************************************/
551cdf0e10cSrcweir
PopAndChg(const SwTxtAttr & rAttr,SwFont & rFnt)552cdf0e10cSrcweir void SwAttrHandler::PopAndChg( const SwTxtAttr& rAttr, SwFont& rFnt )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir if ( RES_TXTATR_WITHEND_END <= rAttr.Which() )
555cdf0e10cSrcweir return; // robust
556cdf0e10cSrcweir
557cdf0e10cSrcweir // these special attributes in fact represent a collection of attributes
558cdf0e10cSrcweir // they have to be removed from each stack they belong to
559cdf0e10cSrcweir if ( RES_TXTATR_INETFMT == rAttr.Which() ||
560cdf0e10cSrcweir RES_TXTATR_CHARFMT == rAttr.Which() ||
561cdf0e10cSrcweir RES_TXTATR_AUTOFMT == rAttr.Which() )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir const SfxItemSet* pSet = CharFmt::GetItemSet( rAttr.GetAttr() );
564cdf0e10cSrcweir if ( !pSet ) return;
565cdf0e10cSrcweir
566cdf0e10cSrcweir for ( sal_uInt16 i = RES_CHRATR_BEGIN; i < RES_CHRATR_END; i++)
567cdf0e10cSrcweir {
568cdf0e10cSrcweir const SfxPoolItem* pItem;
569cdf0e10cSrcweir sal_Bool bRet = SFX_ITEM_SET == pSet->GetItemState( i, RES_TXTATR_AUTOFMT != rAttr.Which(), &pItem );
570cdf0e10cSrcweir if ( bRet )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir // we remove rAttr from the appropriate stack
573cdf0e10cSrcweir sal_uInt16 nStackPos = StackPos[ i ];
574cdf0e10cSrcweir aAttrStack[ nStackPos ].Remove( rAttr );
575cdf0e10cSrcweir // reset font according to attribute on top of stack
576cdf0e10cSrcweir // or default value
577cdf0e10cSrcweir ActivateTop( rFnt, i );
578cdf0e10cSrcweir }
579cdf0e10cSrcweir }
580cdf0e10cSrcweir }
581cdf0e10cSrcweir // this is the usual case, we have a basic attribute, remove it from the
582cdf0e10cSrcweir // stack and reset the font
583cdf0e10cSrcweir else
584cdf0e10cSrcweir {
585cdf0e10cSrcweir aAttrStack[ StackPos[ rAttr.Which() ] ].Remove( rAttr );
586cdf0e10cSrcweir // reset font according to attribute on top of stack
587cdf0e10cSrcweir // or default value
588cdf0e10cSrcweir ActivateTop( rFnt, rAttr.Which() );
589cdf0e10cSrcweir }
590cdf0e10cSrcweir }
591cdf0e10cSrcweir
592cdf0e10cSrcweir /*************************************************************************
593cdf0e10cSrcweir * SwAttrHandler::Pop()
594cdf0e10cSrcweir *
595cdf0e10cSrcweir * only used during redlining
596cdf0e10cSrcweir *************************************************************************/
597cdf0e10cSrcweir
Pop(const SwTxtAttr & rAttr)598cdf0e10cSrcweir void SwAttrHandler::Pop( const SwTxtAttr& rAttr )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir ASSERT( rAttr.Which() < RES_TXTATR_WITHEND_END,
601cdf0e10cSrcweir "I do not have this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
602cdf0e10cSrcweir
603cdf0e10cSrcweir if ( rAttr.Which() < RES_TXTATR_WITHEND_END )
604cdf0e10cSrcweir {
605cdf0e10cSrcweir aAttrStack[ StackPos[ rAttr.Which() ] ].Remove( rAttr );
606cdf0e10cSrcweir }
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir /*************************************************************************
610cdf0e10cSrcweir * SwAttrHandler::ActivateTop()
611cdf0e10cSrcweir *************************************************************************/
ActivateTop(SwFont & rFnt,const sal_uInt16 nAttr)612cdf0e10cSrcweir void SwAttrHandler::ActivateTop( SwFont& rFnt, const sal_uInt16 nAttr )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir ASSERT( nAttr < RES_TXTATR_WITHEND_END,
615cdf0e10cSrcweir "I cannot activate this attribute, nWhich >= RES_TXTATR_WITHEND_END" );
616cdf0e10cSrcweir
617cdf0e10cSrcweir const sal_uInt16 nStackPos = StackPos[ nAttr ];
618cdf0e10cSrcweir const SwTxtAttr* pTopAt = aAttrStack[ nStackPos ].Top();
619cdf0e10cSrcweir if ( pTopAt )
620cdf0e10cSrcweir {
621cdf0e10cSrcweir // check if top attribute is collection of attributes
622cdf0e10cSrcweir if ( RES_TXTATR_INETFMT == pTopAt->Which() ||
623cdf0e10cSrcweir RES_TXTATR_CHARFMT == pTopAt->Which() ||
624cdf0e10cSrcweir RES_TXTATR_AUTOFMT == pTopAt->Which() )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir const SfxItemSet* pSet = CharFmt::GetItemSet( pTopAt->GetAttr() );
627cdf0e10cSrcweir const SfxPoolItem* pItemNext;
628cdf0e10cSrcweir pSet->GetItemState( nAttr, RES_TXTATR_AUTOFMT != pTopAt->Which(), &pItemNext );
629cdf0e10cSrcweir
630cdf0e10cSrcweir Color aColor;
631cdf0e10cSrcweir if ( lcl_ChgHyperLinkColor( *pTopAt, *pItemNext, mpShell, &aColor ) )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir SvxColorItem aItemNext( aColor, RES_CHRATR_COLOR );
634cdf0e10cSrcweir FontChg( aItemNext, rFnt, sal_False );
635cdf0e10cSrcweir }
636cdf0e10cSrcweir else
637cdf0e10cSrcweir FontChg( *pItemNext, rFnt, sal_False );
638cdf0e10cSrcweir }
639cdf0e10cSrcweir else
640cdf0e10cSrcweir FontChg( pTopAt->GetAttr(), rFnt, sal_False );
641cdf0e10cSrcweir }
642cdf0e10cSrcweir
643cdf0e10cSrcweir // default value has to be set, we only have default values for char attribs
644cdf0e10cSrcweir else if ( nStackPos < NUM_DEFAULT_VALUES )
645cdf0e10cSrcweir FontChg( *pDefaultArray[ nStackPos ], rFnt, sal_False );
646cdf0e10cSrcweir else if ( RES_TXTATR_REFMARK == nAttr )
647cdf0e10cSrcweir rFnt.GetRef()--;
648cdf0e10cSrcweir else if ( RES_TXTATR_TOXMARK == nAttr )
649cdf0e10cSrcweir rFnt.GetTox()--;
650cdf0e10cSrcweir else if ( (RES_TXTATR_META == nAttr) || (RES_TXTATR_METAFIELD == nAttr) )
651cdf0e10cSrcweir {
652cdf0e10cSrcweir rFnt.GetMeta()--;
653cdf0e10cSrcweir }
654cdf0e10cSrcweir else if ( RES_TXTATR_CJK_RUBY == nAttr )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir // ruby stack has no more attributes
657cdf0e10cSrcweir // check, if an rotation attribute has to be applied
658cdf0e10cSrcweir sal_uInt16 nTwoLineStack = StackPos[ RES_CHRATR_TWO_LINES ];
659cdf0e10cSrcweir sal_Bool bTwoLineAct = sal_False;
660cdf0e10cSrcweir const SfxPoolItem* pTwoLineItem = 0;
661cdf0e10cSrcweir const SwTxtAttr* pTwoLineAttr = aAttrStack[ nTwoLineStack ].Top();
662cdf0e10cSrcweir
663cdf0e10cSrcweir if ( pTwoLineAttr )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir pTwoLineItem = CharFmt::GetItem( *pTwoLineAttr, RES_CHRATR_TWO_LINES );
666cdf0e10cSrcweir bTwoLineAct = ((SvxTwoLinesItem*)pTwoLineItem)->GetValue();
667cdf0e10cSrcweir }
668cdf0e10cSrcweir else
669cdf0e10cSrcweir bTwoLineAct =
670cdf0e10cSrcweir ((SvxTwoLinesItem*)pDefaultArray[ nTwoLineStack ])->GetValue();
671cdf0e10cSrcweir
672cdf0e10cSrcweir if ( bTwoLineAct )
673cdf0e10cSrcweir return;
674cdf0e10cSrcweir
675cdf0e10cSrcweir // eventually, an rotate attribute has to be activated
676cdf0e10cSrcweir sal_uInt16 nRotateStack = StackPos[ RES_CHRATR_ROTATE ];
677cdf0e10cSrcweir const SfxPoolItem* pRotateItem = 0;
678cdf0e10cSrcweir const SwTxtAttr* pRotateAttr = aAttrStack[ nRotateStack ].Top();
679cdf0e10cSrcweir
680cdf0e10cSrcweir if ( pRotateAttr )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir pRotateItem = CharFmt::GetItem( *pRotateAttr, RES_CHRATR_ROTATE );
683cdf0e10cSrcweir rFnt.SetVertical( ((SvxCharRotateItem*)pRotateItem)->GetValue(),
684cdf0e10cSrcweir bVertLayout );
685cdf0e10cSrcweir }
686cdf0e10cSrcweir else
687cdf0e10cSrcweir rFnt.SetVertical(
688cdf0e10cSrcweir ((SvxCharRotateItem*)pDefaultArray[ nRotateStack ])->GetValue(),
689cdf0e10cSrcweir bVertLayout
690cdf0e10cSrcweir );
691cdf0e10cSrcweir }
692*69a74367SOliver-Rainer Wittmann else if ( RES_TXTATR_INPUTFIELD == nAttr )
693*69a74367SOliver-Rainer Wittmann rFnt.GetInputField()--;
694cdf0e10cSrcweir }
695cdf0e10cSrcweir
696cdf0e10cSrcweir /*************************************************************************
697cdf0e10cSrcweir * Font Changing Function
698cdf0e10cSrcweir *
699cdf0e10cSrcweir * When popping an attribute from the stack, the top mose remaining
700cdf0e10cSrcweir * attribute in the stack becomes valid. The following function change
701cdf0e10cSrcweir * a font depending on the stack id.
702cdf0e10cSrcweir *************************************************************************/
703cdf0e10cSrcweir
FontChg(const SfxPoolItem & rItem,SwFont & rFnt,sal_Bool bPush)704cdf0e10cSrcweir void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPush )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir switch ( rItem.Which() )
707cdf0e10cSrcweir {
708cdf0e10cSrcweir case RES_CHRATR_CASEMAP :
709cdf0e10cSrcweir rFnt.SetCaseMap( ((SvxCaseMapItem&)rItem).GetCaseMap() );
710cdf0e10cSrcweir break;
711cdf0e10cSrcweir case RES_CHRATR_COLOR :
712cdf0e10cSrcweir rFnt.SetColor( ((SvxColorItem&)rItem).GetValue() );
713cdf0e10cSrcweir break;
714cdf0e10cSrcweir case RES_CHRATR_CONTOUR :
715cdf0e10cSrcweir rFnt.SetOutline( ((SvxContourItem&)rItem).GetValue() );
716cdf0e10cSrcweir break;
717cdf0e10cSrcweir case RES_CHRATR_CROSSEDOUT :
718cdf0e10cSrcweir rFnt.SetStrikeout( ((SvxCrossedOutItem&)rItem).GetStrikeout() );
719cdf0e10cSrcweir break;
720cdf0e10cSrcweir case RES_CHRATR_ESCAPEMENT :
721cdf0e10cSrcweir rFnt.SetEscapement( ((SvxEscapementItem&)rItem).GetEsc() );
722cdf0e10cSrcweir rFnt.SetProportion( ((SvxEscapementItem&)rItem).GetProp() );
723cdf0e10cSrcweir break;
724cdf0e10cSrcweir case RES_CHRATR_FONT :
725cdf0e10cSrcweir rFnt.SetName( ((SvxFontItem&)rItem).GetFamilyName(), SW_LATIN );
726cdf0e10cSrcweir rFnt.SetStyleName( ((SvxFontItem&)rItem).GetStyleName(), SW_LATIN );
727cdf0e10cSrcweir rFnt.SetFamily( ((SvxFontItem&)rItem).GetFamily(), SW_LATIN );
728cdf0e10cSrcweir rFnt.SetPitch( ((SvxFontItem&)rItem).GetPitch(), SW_LATIN );
729cdf0e10cSrcweir rFnt.SetCharSet( ((SvxFontItem&)rItem).GetCharSet(), SW_LATIN );
730cdf0e10cSrcweir break;
731cdf0e10cSrcweir case RES_CHRATR_FONTSIZE :
732cdf0e10cSrcweir rFnt.SetSize(Size(0,((SvxFontHeightItem&)rItem).GetHeight() ), SW_LATIN );
733cdf0e10cSrcweir break;
734cdf0e10cSrcweir case RES_CHRATR_KERNING :
735cdf0e10cSrcweir rFnt.SetFixKerning( ((SvxKerningItem&)rItem).GetValue() );
736cdf0e10cSrcweir break;
737cdf0e10cSrcweir case RES_CHRATR_LANGUAGE :
738cdf0e10cSrcweir rFnt.SetLanguage( ((SvxLanguageItem&)rItem).GetLanguage(), SW_LATIN );
739cdf0e10cSrcweir break;
740cdf0e10cSrcweir case RES_CHRATR_POSTURE :
741cdf0e10cSrcweir rFnt.SetItalic( ((SvxPostureItem&)rItem).GetPosture(), SW_LATIN );
742cdf0e10cSrcweir break;
743cdf0e10cSrcweir case RES_CHRATR_SHADOWED :
744cdf0e10cSrcweir rFnt.SetShadow( ((SvxShadowedItem&)rItem).GetValue() );
745cdf0e10cSrcweir break;
746cdf0e10cSrcweir case RES_CHRATR_UNDERLINE :
747cdf0e10cSrcweir {
748cdf0e10cSrcweir const sal_uInt16 nStackPos = StackPos[ RES_CHRATR_HIDDEN ];
749cdf0e10cSrcweir const SwTxtAttr* pTopAt = aAttrStack[ nStackPos ].Top();
750cdf0e10cSrcweir
751cdf0e10cSrcweir const SfxPoolItem* pTmpItem = pTopAt ?
752cdf0e10cSrcweir CharFmt::GetItem( *pTopAt, RES_CHRATR_HIDDEN ) :
753cdf0e10cSrcweir pDefaultArray[ nStackPos ];
754cdf0e10cSrcweir
755cdf0e10cSrcweir if( (mpShell && !mpShell->GetWin()) ||
756cdf0e10cSrcweir (pTmpItem && !static_cast<const SvxCharHiddenItem*>(pTmpItem)->GetValue()) )
757cdf0e10cSrcweir {
758cdf0e10cSrcweir rFnt.SetUnderline( ((SvxUnderlineItem&)rItem).GetLineStyle() );
759cdf0e10cSrcweir rFnt.SetUnderColor( ((SvxUnderlineItem&)rItem).GetColor() );
760cdf0e10cSrcweir }
761cdf0e10cSrcweir break;
762cdf0e10cSrcweir }
763cdf0e10cSrcweir case RES_CHRATR_OVERLINE :
764cdf0e10cSrcweir rFnt.SetOverline( ((SvxOverlineItem&)rItem).GetLineStyle() );
765cdf0e10cSrcweir rFnt.SetOverColor( ((SvxOverlineItem&)rItem).GetColor() );
766cdf0e10cSrcweir break;
767cdf0e10cSrcweir case RES_CHRATR_WEIGHT :
768cdf0e10cSrcweir rFnt.SetWeight( ((SvxWeightItem&)rItem).GetWeight(), SW_LATIN );
769cdf0e10cSrcweir break;
770cdf0e10cSrcweir case RES_CHRATR_WORDLINEMODE :
771cdf0e10cSrcweir rFnt.SetWordLineMode( ((SvxWordLineModeItem&)rItem).GetValue() );
772cdf0e10cSrcweir break;
773cdf0e10cSrcweir case RES_CHRATR_AUTOKERN :
774cdf0e10cSrcweir if( ((SvxAutoKernItem&)rItem).GetValue() )
775cdf0e10cSrcweir {
776cdf0e10cSrcweir rFnt.SetAutoKern( ( !mpIDocumentSettingAccess ||
777cdf0e10cSrcweir !mpIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION) ) ?
778cdf0e10cSrcweir KERNING_FONTSPECIFIC :
779cdf0e10cSrcweir KERNING_ASIAN );
780cdf0e10cSrcweir }
781cdf0e10cSrcweir else
782cdf0e10cSrcweir rFnt.SetAutoKern( 0 );
783cdf0e10cSrcweir break;
784cdf0e10cSrcweir case RES_CHRATR_BLINK :
785cdf0e10cSrcweir rFnt.SetBlink( ((SvxBlinkItem&)rItem).GetValue() );
786cdf0e10cSrcweir break;
787cdf0e10cSrcweir case RES_CHRATR_BACKGROUND :
788cdf0e10cSrcweir rFnt.SetBackColor(new Color( ((SvxBrushItem&)rItem).GetColor() ) );
789cdf0e10cSrcweir break;
790cdf0e10cSrcweir case RES_CHRATR_CJK_FONT :
791cdf0e10cSrcweir rFnt.SetName( ((SvxFontItem&)rItem).GetFamilyName(), SW_CJK );
792cdf0e10cSrcweir rFnt.SetStyleName( ((SvxFontItem&)rItem).GetStyleName(), SW_CJK );
793cdf0e10cSrcweir rFnt.SetFamily( ((SvxFontItem&)rItem).GetFamily(), SW_CJK );
794cdf0e10cSrcweir rFnt.SetPitch( ((SvxFontItem&)rItem).GetPitch(), SW_CJK );
795cdf0e10cSrcweir rFnt.SetCharSet( ((SvxFontItem&)rItem).GetCharSet(), SW_CJK );
796cdf0e10cSrcweir break;
797cdf0e10cSrcweir case RES_CHRATR_CJK_FONTSIZE :
798cdf0e10cSrcweir rFnt.SetSize(Size( 0, ((SvxFontHeightItem&)rItem).GetHeight()), SW_CJK);
799cdf0e10cSrcweir break;
800cdf0e10cSrcweir case RES_CHRATR_CJK_LANGUAGE :
801cdf0e10cSrcweir rFnt.SetLanguage( ((SvxLanguageItem&)rItem).GetLanguage(), SW_CJK );
802cdf0e10cSrcweir break;
803cdf0e10cSrcweir case RES_CHRATR_CJK_POSTURE :
804cdf0e10cSrcweir rFnt.SetItalic( ((SvxPostureItem&)rItem).GetPosture(), SW_CJK );
805cdf0e10cSrcweir break;
806cdf0e10cSrcweir case RES_CHRATR_CJK_WEIGHT :
807cdf0e10cSrcweir rFnt.SetWeight( ((SvxWeightItem&)rItem).GetWeight(), SW_CJK );
808cdf0e10cSrcweir break;
809cdf0e10cSrcweir case RES_CHRATR_CTL_FONT :
810cdf0e10cSrcweir rFnt.SetName( ((SvxFontItem&)rItem).GetFamilyName(), SW_CTL );
811cdf0e10cSrcweir rFnt.SetStyleName( ((SvxFontItem&)rItem).GetStyleName(), SW_CTL );
812cdf0e10cSrcweir rFnt.SetFamily( ((SvxFontItem&)rItem).GetFamily(), SW_CTL );
813cdf0e10cSrcweir rFnt.SetPitch( ((SvxFontItem&)rItem).GetPitch(), SW_CTL );
814cdf0e10cSrcweir rFnt.SetCharSet( ((SvxFontItem&)rItem).GetCharSet(), SW_CTL );
815cdf0e10cSrcweir break;
816cdf0e10cSrcweir case RES_CHRATR_CTL_FONTSIZE :
817cdf0e10cSrcweir rFnt.SetSize(Size(0, ((SvxFontHeightItem&)rItem).GetHeight() ), SW_CTL);
818cdf0e10cSrcweir break;
819cdf0e10cSrcweir case RES_CHRATR_CTL_LANGUAGE :
820cdf0e10cSrcweir rFnt.SetLanguage( ((SvxLanguageItem&)rItem).GetLanguage(), SW_CTL );
821cdf0e10cSrcweir break;
822cdf0e10cSrcweir case RES_CHRATR_CTL_POSTURE :
823cdf0e10cSrcweir rFnt.SetItalic( ((SvxPostureItem&)rItem).GetPosture(), SW_CTL );
824cdf0e10cSrcweir break;
825cdf0e10cSrcweir case RES_CHRATR_CTL_WEIGHT :
826cdf0e10cSrcweir rFnt.SetWeight( ((SvxWeightItem&)rItem).GetWeight(), SW_CTL );
827cdf0e10cSrcweir break;
828cdf0e10cSrcweir case RES_CHRATR_EMPHASIS_MARK :
829cdf0e10cSrcweir rFnt.SetEmphasisMark(
830cdf0e10cSrcweir ((SvxEmphasisMarkItem&)rItem).GetEmphasisMark()
831cdf0e10cSrcweir );
832cdf0e10cSrcweir break;
833cdf0e10cSrcweir case RES_CHRATR_SCALEW :
834cdf0e10cSrcweir rFnt.SetPropWidth( ((SvxCharScaleWidthItem&)rItem).GetValue() );
835cdf0e10cSrcweir break;
836cdf0e10cSrcweir case RES_CHRATR_RELIEF :
837cdf0e10cSrcweir rFnt.SetRelief( (FontRelief)((SvxCharReliefItem&)rItem).GetValue() );
838cdf0e10cSrcweir break;
839cdf0e10cSrcweir case RES_CHRATR_HIDDEN :
840cdf0e10cSrcweir if( mpShell && mpShell->GetWin())
841cdf0e10cSrcweir {
842cdf0e10cSrcweir if ( ((SvxCharHiddenItem&)rItem).GetValue() )
843cdf0e10cSrcweir rFnt.SetUnderline( UNDERLINE_DOTTED );
844cdf0e10cSrcweir else
845cdf0e10cSrcweir ActivateTop( rFnt, RES_CHRATR_UNDERLINE );
846cdf0e10cSrcweir }
847cdf0e10cSrcweir break;
848cdf0e10cSrcweir case RES_CHRATR_ROTATE :
849cdf0e10cSrcweir {
850cdf0e10cSrcweir // rotate attribute is applied, when:
851cdf0e10cSrcweir // 1. ruby stack is empty and
852cdf0e10cSrcweir // 2. top of two line stack ( or default attribute )is an
853cdf0e10cSrcweir // deactivated two line attribute
854cdf0e10cSrcweir const bool bRuby =
855cdf0e10cSrcweir 0 != aAttrStack[ StackPos[ RES_TXTATR_CJK_RUBY ] ].Count();
856cdf0e10cSrcweir
857cdf0e10cSrcweir if ( bRuby )
858cdf0e10cSrcweir break;
859cdf0e10cSrcweir
860cdf0e10cSrcweir sal_uInt16 nTwoLineStack = StackPos[ RES_CHRATR_TWO_LINES ];
861cdf0e10cSrcweir sal_Bool bTwoLineAct = sal_False;
862cdf0e10cSrcweir const SfxPoolItem* pTwoLineItem = 0;
863cdf0e10cSrcweir const SwTxtAttr* pTwoLineAttr = aAttrStack[ nTwoLineStack ].Top();
864cdf0e10cSrcweir
865cdf0e10cSrcweir if ( pTwoLineAttr )
866cdf0e10cSrcweir {
867cdf0e10cSrcweir pTwoLineItem = CharFmt::GetItem( *pTwoLineAttr, RES_CHRATR_TWO_LINES );
868cdf0e10cSrcweir bTwoLineAct = ((SvxTwoLinesItem*)pTwoLineItem)->GetValue();
869cdf0e10cSrcweir }
870cdf0e10cSrcweir else
871cdf0e10cSrcweir bTwoLineAct =
872cdf0e10cSrcweir ((SvxTwoLinesItem*)pDefaultArray[ nTwoLineStack ])->GetValue();
873cdf0e10cSrcweir
874cdf0e10cSrcweir if ( !bTwoLineAct )
875cdf0e10cSrcweir rFnt.SetVertical( ((SvxCharRotateItem&)rItem).GetValue(),
876cdf0e10cSrcweir bVertLayout );
877cdf0e10cSrcweir
878cdf0e10cSrcweir break;
879cdf0e10cSrcweir }
880cdf0e10cSrcweir case RES_CHRATR_TWO_LINES :
881cdf0e10cSrcweir {
882cdf0e10cSrcweir sal_Bool bRuby = 0 !=
883cdf0e10cSrcweir aAttrStack[ StackPos[ RES_TXTATR_CJK_RUBY ] ].Count();
884cdf0e10cSrcweir sal_Bool bTwoLineAct = sal_False;
885cdf0e10cSrcweir
886cdf0e10cSrcweir // two line is activated, if
887cdf0e10cSrcweir // 1. no ruby attribute is set and
888cdf0e10cSrcweir // 2. attribute is active
889cdf0e10cSrcweir bTwoLineAct = ((SvxTwoLinesItem&)rItem).GetValue();
890cdf0e10cSrcweir
891cdf0e10cSrcweir if ( !bRuby && bTwoLineAct )
892cdf0e10cSrcweir {
893cdf0e10cSrcweir rFnt.SetVertical( 0, bVertLayout );
894cdf0e10cSrcweir break;
895cdf0e10cSrcweir }
896cdf0e10cSrcweir
897cdf0e10cSrcweir // a deactivating two line attribute is on top of stack,
898cdf0e10cSrcweir // check if rotate attribute has to be enabled
899cdf0e10cSrcweir if ( bRuby )
900cdf0e10cSrcweir break;
901cdf0e10cSrcweir
902cdf0e10cSrcweir sal_uInt16 nRotateStack = StackPos[ RES_CHRATR_ROTATE ];
903cdf0e10cSrcweir const SfxPoolItem* pRotateItem = 0;
904cdf0e10cSrcweir const SwTxtAttr* pRotateAttr = aAttrStack[ nRotateStack ].Top();
905cdf0e10cSrcweir
906cdf0e10cSrcweir if ( pRotateAttr )
907cdf0e10cSrcweir {
908cdf0e10cSrcweir pRotateItem = CharFmt::GetItem( *pRotateAttr, RES_CHRATR_ROTATE );
909cdf0e10cSrcweir rFnt.SetVertical( ((SvxCharRotateItem*)pRotateItem)->GetValue(),
910cdf0e10cSrcweir bVertLayout );
911cdf0e10cSrcweir }
912cdf0e10cSrcweir else
913cdf0e10cSrcweir rFnt.SetVertical(
914cdf0e10cSrcweir ((SvxCharRotateItem*)pDefaultArray[ nRotateStack ])->GetValue(),
915cdf0e10cSrcweir bVertLayout
916cdf0e10cSrcweir );
917cdf0e10cSrcweir break;
918cdf0e10cSrcweir }
919cdf0e10cSrcweir case RES_TXTATR_CJK_RUBY :
920cdf0e10cSrcweir rFnt.SetVertical( 0, bVertLayout );
921cdf0e10cSrcweir break;
922cdf0e10cSrcweir case RES_TXTATR_REFMARK :
923cdf0e10cSrcweir if ( bPush )
924cdf0e10cSrcweir rFnt.GetRef()++;
925cdf0e10cSrcweir else
926cdf0e10cSrcweir rFnt.GetRef()--;
927cdf0e10cSrcweir break;
928cdf0e10cSrcweir case RES_TXTATR_TOXMARK :
929cdf0e10cSrcweir if ( bPush )
930cdf0e10cSrcweir rFnt.GetTox()++;
931cdf0e10cSrcweir else
932cdf0e10cSrcweir rFnt.GetTox()--;
933cdf0e10cSrcweir break;
934cdf0e10cSrcweir case RES_TXTATR_META:
935cdf0e10cSrcweir case RES_TXTATR_METAFIELD:
936cdf0e10cSrcweir if ( bPush )
937cdf0e10cSrcweir rFnt.GetMeta()++;
938cdf0e10cSrcweir else
939cdf0e10cSrcweir rFnt.GetMeta()--;
940cdf0e10cSrcweir break;
941*69a74367SOliver-Rainer Wittmann case RES_TXTATR_INPUTFIELD :
942*69a74367SOliver-Rainer Wittmann if ( bPush )
943*69a74367SOliver-Rainer Wittmann rFnt.GetInputField()++;
944*69a74367SOliver-Rainer Wittmann else
945*69a74367SOliver-Rainer Wittmann rFnt.GetInputField()--;
946*69a74367SOliver-Rainer Wittmann break;
947cdf0e10cSrcweir }
948cdf0e10cSrcweir }
949cdf0e10cSrcweir
950cdf0e10cSrcweir // Takes the default font and calculated the ascent and height
GetDefaultAscentAndHeight(ViewShell * pShell,OutputDevice & rOut,sal_uInt16 & nAscent,sal_uInt16 & nHeight) const951cdf0e10cSrcweir void SwAttrHandler::GetDefaultAscentAndHeight( ViewShell* pShell, OutputDevice& rOut,
952cdf0e10cSrcweir sal_uInt16& nAscent, sal_uInt16& nHeight ) const
953cdf0e10cSrcweir {
954cdf0e10cSrcweir ASSERT( pFnt, "No font available for GetDefaultAscentAndHeight" )
955cdf0e10cSrcweir
956cdf0e10cSrcweir if ( pFnt )
957cdf0e10cSrcweir {
958cdf0e10cSrcweir SwFont aFont( *pFnt );
959cdf0e10cSrcweir nHeight = aFont.GetHeight( pShell, rOut );
960cdf0e10cSrcweir nAscent = aFont.GetAscent( pShell, rOut );
961cdf0e10cSrcweir }
962cdf0e10cSrcweir }
963cdf0e10cSrcweir
964