1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10*efeef26fSAndrew Rist *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19*efeef26fSAndrew Rist *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
27cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <hintids.hxx>
33cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
34cdf0e10cSrcweir #define _SVSTDARR_STRINGSISORTDTOR
35cdf0e10cSrcweir #include <svl/svstdarr.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include "cmdid.h"
38cdf0e10cSrcweir #include "swmodule.hxx"
39cdf0e10cSrcweir #include "view.hxx"
40cdf0e10cSrcweir #include "wrtsh.hxx"
41cdf0e10cSrcweir #include "globals.hrc"
42cdf0e10cSrcweir
43cdf0e10cSrcweir
44cdf0e10cSrcweir #ifndef _METRIC_HXX //autogen
45cdf0e10cSrcweir #include <vcl/metric.hxx>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #include <svl/stritem.hxx>
48cdf0e10cSrcweir #include <editeng/fontitem.hxx>
49cdf0e10cSrcweir #include <svx/htmlmode.hxx>
50cdf0e10cSrcweir #include <sfx2/objsh.hxx>
51cdf0e10cSrcweir #include <editeng/svxfont.hxx>
52cdf0e10cSrcweir #include <vcl/print.hxx>
53cdf0e10cSrcweir #include <sfx2/printer.hxx>
54cdf0e10cSrcweir #ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
55cdf0e10cSrcweir #include <com/sun/star/i18n/ScriptType.hdl>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx>
58cdf0e10cSrcweir #include <com/sun/star/i18n/XBreakIterator.hpp>
59cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
60cdf0e10cSrcweir
61cdf0e10cSrcweir #define _SVSTDARR_XUB_STRLEN
62cdf0e10cSrcweir #define _SVSTDARR_USHORTS
63cdf0e10cSrcweir #define _SVSTDARR_ULONGS
64cdf0e10cSrcweir #include <svl/svstdarr.hxx>
65cdf0e10cSrcweir
66cdf0e10cSrcweir #include "charatr.hxx"
67cdf0e10cSrcweir #include "viewopt.hxx"
68cdf0e10cSrcweir #include "drpcps.hxx"
69cdf0e10cSrcweir #include "paratr.hxx"
70cdf0e10cSrcweir #include "uitool.hxx"
71cdf0e10cSrcweir #include "charfmt.hxx"
72cdf0e10cSrcweir
73cdf0e10cSrcweir #include "chrdlg.hrc"
74cdf0e10cSrcweir #include "drpcps.hrc"
75cdf0e10cSrcweir
76cdf0e10cSrcweir
77cdf0e10cSrcweir using namespace ::com::sun::star;
78cdf0e10cSrcweir using namespace ::com::sun::star::uno;
79cdf0e10cSrcweir using namespace ::com::sun::star::lang;
80cdf0e10cSrcweir //using namespace i18n; !using this namespace leads to mysterious conflicts with ScriptType::...!
81cdf0e10cSrcweir // so don't use this instead of the following defines!
82cdf0e10cSrcweir
83cdf0e10cSrcweir #define I18N ::com::sun::star::i18n
84cdf0e10cSrcweir #define I18N_SCRIPTTYPE ::com::sun::star::i18n::ScriptType
85cdf0e10cSrcweir
86cdf0e10cSrcweir // Globals ******************************************************************
87cdf0e10cSrcweir
88cdf0e10cSrcweir static sal_uInt16 __FAR_DATA aPageRg[] = {
89cdf0e10cSrcweir RES_PARATR_DROP, RES_PARATR_DROP,
90cdf0e10cSrcweir 0
91cdf0e10cSrcweir };
92cdf0e10cSrcweir
93cdf0e10cSrcweir
94cdf0e10cSrcweir
95cdf0e10cSrcweir // class SwDropCapsPict *****************************************************
96cdf0e10cSrcweir
97cdf0e10cSrcweir class SwDropCapsPict : public Control
98cdf0e10cSrcweir {
99cdf0e10cSrcweir String maText;
100cdf0e10cSrcweir String maScriptText;
101cdf0e10cSrcweir Color maBackColor;
102cdf0e10cSrcweir Color maTextLineColor;
103cdf0e10cSrcweir sal_uInt8 mnLines;
104cdf0e10cSrcweir long mnTotLineH;
105cdf0e10cSrcweir long mnLineH;
106cdf0e10cSrcweir long mnTextH;
107cdf0e10cSrcweir sal_uInt16 mnDistance;
108cdf0e10cSrcweir sal_Int32 mnLeading;
109cdf0e10cSrcweir Printer* mpPrinter;
110cdf0e10cSrcweir sal_Bool mbDelPrinter;
111cdf0e10cSrcweir SvULongs maTextWidth;
112cdf0e10cSrcweir SvXub_StrLens maScriptChg;
113cdf0e10cSrcweir SvUShorts maScriptType;
114cdf0e10cSrcweir SvxFont maFont;
115cdf0e10cSrcweir SvxFont maCJKFont;
116cdf0e10cSrcweir SvxFont maCTLFont;
117cdf0e10cSrcweir Size maTextSize;
118cdf0e10cSrcweir Reference< I18N::XBreakIterator > xBreak;
119cdf0e10cSrcweir
120cdf0e10cSrcweir virtual void Paint(const Rectangle &rRect);
121cdf0e10cSrcweir void CheckScript( void );
122cdf0e10cSrcweir Size CalcTextSize( void );
123cdf0e10cSrcweir inline void InitPrinter( void );
124cdf0e10cSrcweir void _InitPrinter( void );
125cdf0e10cSrcweir void GetFontSettings( const SwDropCapsPage& _rPage, Font& _rFont, sal_uInt16 _nWhich );
126cdf0e10cSrcweir public:
127cdf0e10cSrcweir
SwDropCapsPict(Window * pParent,const ResId & rResId)128cdf0e10cSrcweir SwDropCapsPict(Window *pParent, const ResId &rResId) :
129cdf0e10cSrcweir Control(pParent, rResId), mpPrinter( NULL ), mbDelPrinter( sal_False ) {}
130cdf0e10cSrcweir ~SwDropCapsPict();
131cdf0e10cSrcweir
132cdf0e10cSrcweir void UpdatePaintSettings( void ); // also invalidates control!
133cdf0e10cSrcweir
134cdf0e10cSrcweir inline void SetText( const String& rT );
135cdf0e10cSrcweir inline void SetLines( sal_uInt8 nL );
136cdf0e10cSrcweir inline void SetDistance( sal_uInt16 nD );
137cdf0e10cSrcweir inline void SetValues( const String& rText, sal_uInt8 nLines, sal_uInt16 nDistance );
138cdf0e10cSrcweir
139cdf0e10cSrcweir void DrawPrev( const Point& rPt );
140cdf0e10cSrcweir };
141cdf0e10cSrcweir
SetText(const String & rT)142cdf0e10cSrcweir inline void SwDropCapsPict::SetText( const String& rT )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir maText = rT;
145cdf0e10cSrcweir UpdatePaintSettings();
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
SetLines(sal_uInt8 nL)148cdf0e10cSrcweir inline void SwDropCapsPict::SetLines( sal_uInt8 nL )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir mnLines = nL;
151cdf0e10cSrcweir UpdatePaintSettings();
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
SetDistance(sal_uInt16 nD)154cdf0e10cSrcweir inline void SwDropCapsPict::SetDistance( sal_uInt16 nD )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir mnDistance = nD;
157cdf0e10cSrcweir UpdatePaintSettings();
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
SetValues(const String & rText,sal_uInt8 nLines,sal_uInt16 nDistance)160cdf0e10cSrcweir inline void SwDropCapsPict::SetValues( const String& rText, sal_uInt8 nLines, sal_uInt16 nDistance )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir maText = rText;
163cdf0e10cSrcweir mnLines = nLines;
164cdf0e10cSrcweir mnDistance = nDistance;
165cdf0e10cSrcweir
166cdf0e10cSrcweir UpdatePaintSettings();
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
InitPrinter(void)169cdf0e10cSrcweir inline void SwDropCapsPict::InitPrinter( void )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir if( !mpPrinter )
172cdf0e10cSrcweir _InitPrinter();
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir /****************************************************************************
176cdf0e10cSrcweir Default-String aus Zeichenanzahl erzeugen (A, AB, ABC, ...)
177cdf0e10cSrcweir ****************************************************************************/
178cdf0e10cSrcweir
179cdf0e10cSrcweir
GetDefaultString(sal_uInt16 nChars)180cdf0e10cSrcweir String GetDefaultString(sal_uInt16 nChars)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir String aStr;
183cdf0e10cSrcweir for (sal_uInt16 i = 0; i < nChars; i++)
184cdf0e10cSrcweir aStr += String((char) (i + 65));
185cdf0e10cSrcweir return aStr;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir
calcFontHeightAnyAscent(OutputDevice * _pWin,Font & _rFont,long & _nHeight,long & _nAscent)188cdf0e10cSrcweir static void calcFontHeightAnyAscent( OutputDevice* _pWin, Font& _rFont, long& _nHeight, long& _nAscent )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir if ( !_nHeight )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir _pWin->SetFont( _rFont );
193cdf0e10cSrcweir FontMetric aMetric( _pWin->GetFontMetric() );
194cdf0e10cSrcweir _nHeight = aMetric.GetLineHeight();
195cdf0e10cSrcweir _nAscent = aMetric.GetAscent();
196cdf0e10cSrcweir }
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199cdf0e10cSrcweir /****************************************************************************
200cdf0e10cSrcweir Pict: Dtor
201cdf0e10cSrcweir ****************************************************************************/
202cdf0e10cSrcweir
203cdf0e10cSrcweir
~SwDropCapsPict()204cdf0e10cSrcweir SwDropCapsPict::~SwDropCapsPict()
205cdf0e10cSrcweir {
206cdf0e10cSrcweir if( mbDelPrinter )
207cdf0e10cSrcweir delete mpPrinter;
208cdf0e10cSrcweir }
209cdf0e10cSrcweir
210cdf0e10cSrcweir /****************************************************************************
211cdf0e10cSrcweir Pict: Update Font
212cdf0e10cSrcweir ****************************************************************************/
213cdf0e10cSrcweir
214cdf0e10cSrcweir #define LINES 10
215cdf0e10cSrcweir #define BORDER 2
216cdf0e10cSrcweir
GetFontSettings(const SwDropCapsPage & _rPage,Font & _rFont,sal_uInt16 _nWhich)217cdf0e10cSrcweir void SwDropCapsPict::GetFontSettings( const SwDropCapsPage& _rPage, Font& _rFont, sal_uInt16 _nWhich )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir SfxItemSet aSet( _rPage.rSh.GetAttrPool(), _nWhich, _nWhich);
220cdf0e10cSrcweir _rPage.rSh.GetCurAttr(aSet);
221cdf0e10cSrcweir SvxFontItem aFmtFont((SvxFontItem &) aSet.Get(_nWhich));
222cdf0e10cSrcweir
223cdf0e10cSrcweir _rFont.SetFamily (aFmtFont.GetFamily());
224cdf0e10cSrcweir _rFont.SetName (aFmtFont.GetFamilyName());
225cdf0e10cSrcweir _rFont.SetPitch (aFmtFont.GetPitch());
226cdf0e10cSrcweir _rFont.SetCharSet(aFmtFont.GetCharSet());
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
UpdatePaintSettings(void)229cdf0e10cSrcweir void SwDropCapsPict::UpdatePaintSettings( void )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir maBackColor = GetSettings().GetStyleSettings().GetWindowColor();
232cdf0e10cSrcweir maTextLineColor = Color( COL_LIGHTGRAY );
233cdf0e10cSrcweir
234cdf0e10cSrcweir // gray lines
235cdf0e10cSrcweir mnTotLineH = (GetOutputSizePixel().Height() - 2 * BORDER) / LINES;
236cdf0e10cSrcweir mnLineH = mnTotLineH - 2;
237cdf0e10cSrcweir mnLeading = GetFontMetric().GetIntLeading();
238cdf0e10cSrcweir
239cdf0e10cSrcweir Font aFont;
240cdf0e10cSrcweir {
241cdf0e10cSrcweir SwDropCapsPage* pPage = ( SwDropCapsPage* ) GetParent();
242cdf0e10cSrcweir if (!pPage->aTemplateBox.GetSelectEntryPos())
243cdf0e10cSrcweir {
244cdf0e10cSrcweir // Font an Absatzanfang erfragen
245cdf0e10cSrcweir pPage->rSh.SttCrsrMove();
246cdf0e10cSrcweir pPage->rSh.Push();
247cdf0e10cSrcweir pPage->rSh.ClearMark();
248cdf0e10cSrcweir SwWhichPara pSwuifnParaCurr = GetfnParaCurr();
249cdf0e10cSrcweir SwPosPara pSwuifnParaStart = GetfnParaStart();
250cdf0e10cSrcweir pPage->rSh.MovePara(pSwuifnParaCurr,pSwuifnParaStart);
251cdf0e10cSrcweir // normal
252cdf0e10cSrcweir GetFontSettings( *pPage, aFont, RES_CHRATR_FONT );
253cdf0e10cSrcweir
254cdf0e10cSrcweir // CJK
255cdf0e10cSrcweir GetFontSettings( *pPage, maCJKFont, RES_CHRATR_CJK_FONT );
256cdf0e10cSrcweir
257cdf0e10cSrcweir // CTL
258cdf0e10cSrcweir GetFontSettings( *pPage, maCTLFont, RES_CHRATR_CTL_FONT );
259cdf0e10cSrcweir
260cdf0e10cSrcweir pPage->rSh.Pop(sal_False);
261cdf0e10cSrcweir pPage->rSh.EndCrsrMove();
262cdf0e10cSrcweir }
263cdf0e10cSrcweir else
264cdf0e10cSrcweir {
265cdf0e10cSrcweir // Font an Zeichenvorlage erfragen
266cdf0e10cSrcweir SwCharFmt *pFmt = pPage->rSh.GetCharStyle(
267cdf0e10cSrcweir pPage->aTemplateBox.GetSelectEntry(),
268cdf0e10cSrcweir SwWrtShell::GETSTYLE_CREATEANY );
269cdf0e10cSrcweir ASSERT(pFmt, "Zeichenvorlage existiert nicht!");
270cdf0e10cSrcweir const SvxFontItem &rFmtFont = pFmt->GetFont();
271cdf0e10cSrcweir
272cdf0e10cSrcweir aFont.SetFamily (rFmtFont.GetFamily());
273cdf0e10cSrcweir aFont.SetName (rFmtFont.GetFamilyName());
274cdf0e10cSrcweir aFont.SetPitch (rFmtFont.GetPitch());
275cdf0e10cSrcweir aFont.SetCharSet(rFmtFont.GetCharSet());
276cdf0e10cSrcweir }
277cdf0e10cSrcweir }
278cdf0e10cSrcweir
279cdf0e10cSrcweir mnTextH = mnLines * mnTotLineH;
280cdf0e10cSrcweir aFont.SetSize(Size(0, mnTextH));
281cdf0e10cSrcweir maCJKFont.SetSize(Size(0, mnTextH));
282cdf0e10cSrcweir maCTLFont.SetSize(Size(0, mnTextH));
283cdf0e10cSrcweir
284cdf0e10cSrcweir aFont.SetTransparent(sal_True);
285cdf0e10cSrcweir maCJKFont.SetTransparent(sal_True);
286cdf0e10cSrcweir maCTLFont.SetTransparent(sal_True);
287cdf0e10cSrcweir
288cdf0e10cSrcweir aFont.SetColor( SwViewOption::GetFontColor() );
289cdf0e10cSrcweir maCJKFont.SetColor( SwViewOption::GetFontColor() );
290cdf0e10cSrcweir maCTLFont.SetColor( SwViewOption::GetFontColor() );
291cdf0e10cSrcweir
292cdf0e10cSrcweir aFont.SetFillColor(GetSettings().GetStyleSettings().GetWindowColor());
293cdf0e10cSrcweir maCJKFont.SetFillColor(GetSettings().GetStyleSettings().GetWindowColor());
294cdf0e10cSrcweir maCTLFont.SetFillColor(GetSettings().GetStyleSettings().GetWindowColor());
295cdf0e10cSrcweir
296cdf0e10cSrcweir maCJKFont.SetSize(Size(0, maCJKFont.GetSize().Height() + mnLeading));
297cdf0e10cSrcweir maCTLFont.SetSize(Size(0, maCTLFont.GetSize().Height() + mnLeading));
298cdf0e10cSrcweir
299cdf0e10cSrcweir SetFont(aFont);
300cdf0e10cSrcweir aFont.SetSize(Size(0, aFont.GetSize().Height() + mnLeading));
301cdf0e10cSrcweir SetFont(aFont);
302cdf0e10cSrcweir maFont = aFont;
303cdf0e10cSrcweir
304cdf0e10cSrcweir CheckScript();
305cdf0e10cSrcweir
306cdf0e10cSrcweir maTextSize = CalcTextSize();
307cdf0e10cSrcweir
308cdf0e10cSrcweir Invalidate();
309cdf0e10cSrcweir }
310cdf0e10cSrcweir
311cdf0e10cSrcweir /****************************************************************************
312cdf0e10cSrcweir Pict: Paint-Overload
313cdf0e10cSrcweir ****************************************************************************/
314cdf0e10cSrcweir
Paint(const Rectangle &)315cdf0e10cSrcweir void SwDropCapsPict::Paint(const Rectangle &/*rRect*/)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir if (!IsVisible())
318cdf0e10cSrcweir return;
319cdf0e10cSrcweir
320cdf0e10cSrcweir SetMapMode(MapMode(MAP_PIXEL));
321cdf0e10cSrcweir SetLineColor();
322cdf0e10cSrcweir
323cdf0e10cSrcweir SetFillColor( maBackColor );
324cdf0e10cSrcweir
325cdf0e10cSrcweir Size aOutputSizePixel( GetOutputSizePixel() );
326cdf0e10cSrcweir
327cdf0e10cSrcweir DrawRect(Rectangle(Point(0, 0), aOutputSizePixel ));
328cdf0e10cSrcweir SetClipRegion(Region(Rectangle(
329cdf0e10cSrcweir Point(BORDER, BORDER),
330cdf0e10cSrcweir Size (aOutputSizePixel.Width () - 2 * BORDER,
331cdf0e10cSrcweir aOutputSizePixel.Height() - 2 * BORDER))));
332cdf0e10cSrcweir
333cdf0e10cSrcweir ASSERT(mnLineH > 0, "So klein lassen wir uns nicht machen");
334cdf0e10cSrcweir long nY0 = (aOutputSizePixel.Height() - (LINES * mnTotLineH)) / 2;
335cdf0e10cSrcweir SetFillColor( maTextLineColor );
336cdf0e10cSrcweir for (sal_uInt16 i = 0; i < LINES; ++i)
337cdf0e10cSrcweir DrawRect(Rectangle(Point(BORDER, nY0 + i * mnTotLineH), Size(aOutputSizePixel.Width() - 2 * BORDER, mnLineH)));
338cdf0e10cSrcweir
339cdf0e10cSrcweir // Texthintergrund mit Abstand (240 twips ~ 1 Zeilenhoehe)
340cdf0e10cSrcweir sal_uLong lDistance = mnDistance;
341cdf0e10cSrcweir sal_uInt16 nDistW = (sal_uInt16) (sal_uLong) (((lDistance * 100) / 240) * mnTotLineH) / 100;
342cdf0e10cSrcweir SetFillColor( maBackColor );
343cdf0e10cSrcweir if(((SwDropCapsPage*)GetParent())->aDropCapsBox.IsChecked())
344cdf0e10cSrcweir {
345cdf0e10cSrcweir Size aTextSize( maTextSize );
346cdf0e10cSrcweir aTextSize.Width() += nDistW;
347cdf0e10cSrcweir DrawRect( Rectangle( Point( BORDER, nY0 ), aTextSize ) );
348cdf0e10cSrcweir
349cdf0e10cSrcweir // Text zeichnen
350cdf0e10cSrcweir DrawPrev( Point( BORDER, nY0 - mnLeading ) );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir
353cdf0e10cSrcweir SetClipRegion();
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
DrawPrev(const Point & rPt)356cdf0e10cSrcweir void SwDropCapsPict::DrawPrev( const Point& rPt )
357cdf0e10cSrcweir {
358cdf0e10cSrcweir Point aPt(rPt);
359cdf0e10cSrcweir InitPrinter();
360cdf0e10cSrcweir
361cdf0e10cSrcweir Font aOldFont = mpPrinter->GetFont();
362cdf0e10cSrcweir sal_uInt16 nScript;
363cdf0e10cSrcweir size_t nIdx = 0;
364cdf0e10cSrcweir xub_StrLen nStart = 0;
365cdf0e10cSrcweir xub_StrLen nEnd;
366cdf0e10cSrcweir size_t nCnt = maScriptChg.size();
367cdf0e10cSrcweir
368cdf0e10cSrcweir if( nCnt )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir nEnd = maScriptChg[ nIdx ];
371cdf0e10cSrcweir nScript = maScriptType[ nIdx ];
372cdf0e10cSrcweir }
373cdf0e10cSrcweir else
374cdf0e10cSrcweir {
375cdf0e10cSrcweir nEnd = maText.Len();
376cdf0e10cSrcweir nScript = I18N_SCRIPTTYPE::LATIN;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir do
379cdf0e10cSrcweir {
380cdf0e10cSrcweir SvxFont& rFnt = (nScript==I18N_SCRIPTTYPE::ASIAN) ? maCJKFont : ((nScript==I18N_SCRIPTTYPE::COMPLEX) ? maCTLFont : maFont);
381cdf0e10cSrcweir mpPrinter->SetFont( rFnt );
382cdf0e10cSrcweir
383cdf0e10cSrcweir rFnt.DrawPrev( this, mpPrinter, aPt, maText, nStart, nEnd - nStart );
384cdf0e10cSrcweir
385cdf0e10cSrcweir aPt.X() += maTextWidth[ nIdx++ ];
386cdf0e10cSrcweir if( nEnd < maText.Len() && nIdx < nCnt )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir nStart = nEnd;
389cdf0e10cSrcweir nEnd = maScriptChg[ nIdx ];
390cdf0e10cSrcweir nScript = maScriptType[ nIdx ];
391cdf0e10cSrcweir }
392cdf0e10cSrcweir else
393cdf0e10cSrcweir break;
394cdf0e10cSrcweir }
395cdf0e10cSrcweir while( sal_True );
396cdf0e10cSrcweir mpPrinter->SetFont( aOldFont );
397cdf0e10cSrcweir }
398cdf0e10cSrcweir
CheckScript(void)399cdf0e10cSrcweir void SwDropCapsPict::CheckScript( void )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir if( maScriptText == maText )
402cdf0e10cSrcweir return;
403cdf0e10cSrcweir
404cdf0e10cSrcweir maScriptText = maText;
405cdf0e10cSrcweir size_t nCnt = maScriptChg.size();
406cdf0e10cSrcweir if( nCnt )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir maScriptChg.clear();
409cdf0e10cSrcweir maScriptType.Remove( 0, nCnt );
410cdf0e10cSrcweir maTextWidth.Remove( 0, nCnt );
411cdf0e10cSrcweir nCnt = 0;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir if( !xBreak.is() )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
416cdf0e10cSrcweir xBreak = Reference< I18N::XBreakIterator >(xMSF->createInstance(
417cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ),UNO_QUERY);
418cdf0e10cSrcweir }
419cdf0e10cSrcweir if( xBreak.is() )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir sal_uInt16 nScript = xBreak->getScriptType( maText, 0 );
422cdf0e10cSrcweir sal_uInt16 nChg = 0;
423cdf0e10cSrcweir if( I18N_SCRIPTTYPE::WEAK == nScript )
424cdf0e10cSrcweir {
425cdf0e10cSrcweir nChg = (xub_StrLen)xBreak->endOfScript( maText, nChg, nScript );
426cdf0e10cSrcweir if( nChg < maText.Len() )
427cdf0e10cSrcweir nScript = xBreak->getScriptType( maText, nChg );
428cdf0e10cSrcweir else
429cdf0e10cSrcweir nScript = I18N_SCRIPTTYPE::LATIN;
430cdf0e10cSrcweir }
431cdf0e10cSrcweir
432cdf0e10cSrcweir do
433cdf0e10cSrcweir {
434cdf0e10cSrcweir nChg = (xub_StrLen)xBreak->endOfScript( maText, nChg, nScript );
435cdf0e10cSrcweir maScriptChg.push_back( nChg );
436cdf0e10cSrcweir maScriptType.Insert( nScript, nCnt );
437cdf0e10cSrcweir maTextWidth.Insert( sal_uLong(0), nCnt++ );
438cdf0e10cSrcweir
439cdf0e10cSrcweir if( nChg < maText.Len() )
440cdf0e10cSrcweir nScript = xBreak->getScriptType( maText, nChg );
441cdf0e10cSrcweir else
442cdf0e10cSrcweir break;
443cdf0e10cSrcweir } while( sal_True );
444cdf0e10cSrcweir }
445cdf0e10cSrcweir }
446cdf0e10cSrcweir
CalcTextSize(void)447cdf0e10cSrcweir Size SwDropCapsPict::CalcTextSize( void )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir InitPrinter();
450cdf0e10cSrcweir
451cdf0e10cSrcweir sal_uInt16 nScript;
452cdf0e10cSrcweir size_t nIdx = 0;
453cdf0e10cSrcweir xub_StrLen nStart = 0;
454cdf0e10cSrcweir xub_StrLen nEnd;
455cdf0e10cSrcweir size_t nCnt = maScriptChg.size();
456cdf0e10cSrcweir if( nCnt )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir nEnd = maScriptChg[ nIdx ];
459cdf0e10cSrcweir nScript = maScriptType[ nIdx ];
460cdf0e10cSrcweir }
461cdf0e10cSrcweir else
462cdf0e10cSrcweir {
463cdf0e10cSrcweir nEnd = maText.Len();
464cdf0e10cSrcweir nScript = I18N_SCRIPTTYPE::LATIN;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir long nTxtWidth = 0;
467cdf0e10cSrcweir long nCJKHeight = 0;
468cdf0e10cSrcweir long nCTLHeight = 0;
469cdf0e10cSrcweir long nHeight = 0;
470cdf0e10cSrcweir long nAscent = 0;
471cdf0e10cSrcweir long nCJKAscent = 0;
472cdf0e10cSrcweir long nCTLAscent = 0;
473cdf0e10cSrcweir do
474cdf0e10cSrcweir {
475cdf0e10cSrcweir SvxFont& rFnt = ( nScript == I18N_SCRIPTTYPE::ASIAN )? maCJKFont :
476cdf0e10cSrcweir ( ( nScript == I18N_SCRIPTTYPE::COMPLEX )? maCTLFont : maFont );
477cdf0e10cSrcweir sal_uLong nWidth = rFnt.GetTxtSize( mpPrinter, maText, nStart, nEnd-nStart ).Width();
478cdf0e10cSrcweir
479cdf0e10cSrcweir if( nIdx < maTextWidth.Count() )
480cdf0e10cSrcweir maTextWidth[ nIdx++ ] = nWidth;
481cdf0e10cSrcweir nTxtWidth += nWidth;
482cdf0e10cSrcweir switch(nScript)
483cdf0e10cSrcweir {
484cdf0e10cSrcweir case I18N_SCRIPTTYPE::ASIAN:
485cdf0e10cSrcweir calcFontHeightAnyAscent( this, maCJKFont, nCJKHeight, nCJKAscent );
486cdf0e10cSrcweir break;
487cdf0e10cSrcweir case I18N_SCRIPTTYPE::COMPLEX:
488cdf0e10cSrcweir calcFontHeightAnyAscent( this, maCTLFont, nCTLHeight, nCTLAscent );
489cdf0e10cSrcweir break;
490cdf0e10cSrcweir default:
491cdf0e10cSrcweir calcFontHeightAnyAscent( this, maFont, nHeight, nAscent );
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
494cdf0e10cSrcweir if( nEnd < maText.Len() && nIdx < nCnt )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir nStart = nEnd;
497cdf0e10cSrcweir nEnd = maScriptChg[ nIdx ];
498cdf0e10cSrcweir nScript = maScriptType[ nIdx ];
499cdf0e10cSrcweir }
500cdf0e10cSrcweir else
501cdf0e10cSrcweir break;
502cdf0e10cSrcweir }
503cdf0e10cSrcweir while( sal_True );
504cdf0e10cSrcweir nHeight -= nAscent;
505cdf0e10cSrcweir nCJKHeight -= nCJKAscent;
506cdf0e10cSrcweir nCTLHeight -= nCTLAscent;
507cdf0e10cSrcweir if( nHeight < nCJKHeight )
508cdf0e10cSrcweir nHeight = nCJKHeight;
509cdf0e10cSrcweir if( nAscent < nCJKAscent )
510cdf0e10cSrcweir nAscent = nCJKAscent;
511cdf0e10cSrcweir if( nHeight < nCTLHeight )
512cdf0e10cSrcweir nHeight = nCTLHeight;
513cdf0e10cSrcweir if( nAscent < nCTLAscent )
514cdf0e10cSrcweir nAscent = nCTLAscent;
515cdf0e10cSrcweir nHeight += nAscent;
516cdf0e10cSrcweir
517cdf0e10cSrcweir Size aTxtSize( nTxtWidth, nHeight );
518cdf0e10cSrcweir return aTxtSize;
519cdf0e10cSrcweir }
520cdf0e10cSrcweir
_InitPrinter()521cdf0e10cSrcweir void SwDropCapsPict::_InitPrinter()
522cdf0e10cSrcweir {
523cdf0e10cSrcweir SfxViewShell* pSh = SfxViewShell::Current();
524cdf0e10cSrcweir
525cdf0e10cSrcweir if ( pSh )
526cdf0e10cSrcweir mpPrinter = pSh->GetPrinter();
527cdf0e10cSrcweir
528cdf0e10cSrcweir if ( !mpPrinter )
529cdf0e10cSrcweir {
530cdf0e10cSrcweir mpPrinter = new Printer;
531cdf0e10cSrcweir mbDelPrinter = sal_True;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir }
534cdf0e10cSrcweir
535cdf0e10cSrcweir /****************************************************************************
536cdf0e10cSrcweir Dlg: Ctor
537cdf0e10cSrcweir ****************************************************************************/
538cdf0e10cSrcweir
539cdf0e10cSrcweir
SwDropCapsDlg(Window * pParent,const SfxItemSet & rSet)540cdf0e10cSrcweir SwDropCapsDlg::SwDropCapsDlg(Window *pParent, const SfxItemSet &rSet ) :
541cdf0e10cSrcweir
542cdf0e10cSrcweir SfxSingleTabDialog(pParent, rSet, 0)
543cdf0e10cSrcweir
544cdf0e10cSrcweir {
545cdf0e10cSrcweir SwDropCapsPage* pNewPage = (SwDropCapsPage*) SwDropCapsPage::Create(this, rSet);
546cdf0e10cSrcweir pNewPage->SetFormat(sal_False);
547cdf0e10cSrcweir SetTabPage(pNewPage);
548cdf0e10cSrcweir }
549cdf0e10cSrcweir
550cdf0e10cSrcweir /****************************************************************************
551cdf0e10cSrcweir Dlg: Dtor
552cdf0e10cSrcweir ****************************************************************************/
553cdf0e10cSrcweir
554cdf0e10cSrcweir
~SwDropCapsDlg()555cdf0e10cSrcweir SwDropCapsDlg::~SwDropCapsDlg()
556cdf0e10cSrcweir {
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
559cdf0e10cSrcweir /****************************************************************************
560cdf0e10cSrcweir Page: Ctor
561cdf0e10cSrcweir ****************************************************************************/
562cdf0e10cSrcweir
563cdf0e10cSrcweir
SwDropCapsPage(Window * pParent,const SfxItemSet & rSet)564cdf0e10cSrcweir SwDropCapsPage::SwDropCapsPage(Window *pParent, const SfxItemSet &rSet) :
565cdf0e10cSrcweir
566cdf0e10cSrcweir SfxTabPage(pParent, SW_RES(TP_DROPCAPS), rSet),
567cdf0e10cSrcweir
568cdf0e10cSrcweir aSettingsFL (this, SW_RES(FL_SETTINGS)),
569cdf0e10cSrcweir aDropCapsBox (this, SW_RES(CB_SWITCH )),
570cdf0e10cSrcweir aWholeWordCB (this, SW_RES(CB_WORD )),
571cdf0e10cSrcweir aSwitchText (this, SW_RES(FT_DROPCAPS )),
572cdf0e10cSrcweir aDropCapsField(this, SW_RES(FLD_DROPCAPS)),
573cdf0e10cSrcweir aLinesText (this, SW_RES(TXT_LINES )),
574cdf0e10cSrcweir aLinesField (this, SW_RES(FLD_LINES )),
575cdf0e10cSrcweir aDistanceText (this, SW_RES(TXT_DISTANCE)),
576cdf0e10cSrcweir aDistanceField(this, SW_RES(FLD_DISTANCE)),
577cdf0e10cSrcweir
578cdf0e10cSrcweir aContentFL (this, SW_RES(FL_CONTENT )),
579cdf0e10cSrcweir aTextText (this, SW_RES(TXT_TEXT )),
580cdf0e10cSrcweir aTextEdit (this, SW_RES(EDT_TEXT )),
581cdf0e10cSrcweir aTemplateText (this, SW_RES(TXT_TEMPLATE)),
582cdf0e10cSrcweir aTemplateBox (this, SW_RES(BOX_TEMPLATE)),
583cdf0e10cSrcweir
584cdf0e10cSrcweir pPict (new SwDropCapsPict(this, SW_RES(CNT_PICT))),
585cdf0e10cSrcweir
586cdf0e10cSrcweir bModified(sal_False),
587cdf0e10cSrcweir bFormat(sal_True),
588cdf0e10cSrcweir rSh(::GetActiveView()->GetWrtShell())
589cdf0e10cSrcweir {
590cdf0e10cSrcweir FreeResource();
591cdf0e10cSrcweir SetExchangeSupport();
592cdf0e10cSrcweir
593cdf0e10cSrcweir sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
594cdf0e10cSrcweir bHtmlMode = nHtmlMode & HTMLMODE_ON ? sal_True : sal_False;
595cdf0e10cSrcweir
596cdf0e10cSrcweir //Im Vorlagendialog kann der Text nicht beeinflusst werden
597cdf0e10cSrcweir aTextText.Enable( !bFormat );
598cdf0e10cSrcweir aTextEdit.Enable( !bFormat );
599cdf0e10cSrcweir
600cdf0e10cSrcweir // Metriken
601cdf0e10cSrcweir SetMetric( aDistanceField, GetDfltMetric(bHtmlMode) );
602cdf0e10cSrcweir
603cdf0e10cSrcweir pPict->SetBorderStyle( WINDOW_BORDER_MONO );
604cdf0e10cSrcweir
605cdf0e10cSrcweir // Handler installieren
606cdf0e10cSrcweir Link aLk = LINK(this, SwDropCapsPage, ModifyHdl);
607cdf0e10cSrcweir aDropCapsField.SetModifyHdl( aLk );
608cdf0e10cSrcweir aLinesField .SetModifyHdl( aLk );
609cdf0e10cSrcweir aDistanceField.SetModifyHdl( aLk );
610cdf0e10cSrcweir aTextEdit .SetModifyHdl( aLk );
611cdf0e10cSrcweir aDropCapsBox .SetClickHdl (LINK(this, SwDropCapsPage, ClickHdl ));
612cdf0e10cSrcweir aTemplateBox .SetSelectHdl(LINK(this, SwDropCapsPage, SelectHdl));
613cdf0e10cSrcweir aWholeWordCB .SetClickHdl (LINK(this, SwDropCapsPage, WholeWordHdl ));
614cdf0e10cSrcweir }
615cdf0e10cSrcweir
616cdf0e10cSrcweir /****************************************************************************
617cdf0e10cSrcweir Page: Dtor
618cdf0e10cSrcweir ****************************************************************************/
619cdf0e10cSrcweir
620cdf0e10cSrcweir
~SwDropCapsPage()621cdf0e10cSrcweir SwDropCapsPage::~SwDropCapsPage()
622cdf0e10cSrcweir {
623cdf0e10cSrcweir delete pPict;
624cdf0e10cSrcweir }
625cdf0e10cSrcweir
626cdf0e10cSrcweir
DeactivatePage(SfxItemSet * _pSet)627cdf0e10cSrcweir int SwDropCapsPage::DeactivatePage(SfxItemSet * _pSet)
628cdf0e10cSrcweir {
629cdf0e10cSrcweir if ( _pSet )
630cdf0e10cSrcweir FillSet( *_pSet );
631cdf0e10cSrcweir
632cdf0e10cSrcweir return LEAVE_PAGE;
633cdf0e10cSrcweir }
634cdf0e10cSrcweir
635cdf0e10cSrcweir /****************************************************************************
636cdf0e10cSrcweir Page: Factory
637cdf0e10cSrcweir ****************************************************************************/
638cdf0e10cSrcweir
639cdf0e10cSrcweir
Create(Window * pParent,const SfxItemSet & rSet)640cdf0e10cSrcweir SfxTabPage* SwDropCapsPage::Create(Window *pParent,
641cdf0e10cSrcweir const SfxItemSet &rSet)
642cdf0e10cSrcweir {
643cdf0e10cSrcweir return new SwDropCapsPage(pParent, rSet);
644cdf0e10cSrcweir }
645cdf0e10cSrcweir
646cdf0e10cSrcweir /****************************************************************************
647cdf0e10cSrcweir Page: FillItemSet-Overload
648cdf0e10cSrcweir ****************************************************************************/
649cdf0e10cSrcweir
650cdf0e10cSrcweir
FillItemSet(SfxItemSet & rSet)651cdf0e10cSrcweir sal_Bool SwDropCapsPage::FillItemSet(SfxItemSet &rSet)
652cdf0e10cSrcweir {
653cdf0e10cSrcweir if(bModified)
654cdf0e10cSrcweir FillSet(rSet);
655cdf0e10cSrcweir return bModified;
656cdf0e10cSrcweir }
657cdf0e10cSrcweir
658cdf0e10cSrcweir /****************************************************************************
659cdf0e10cSrcweir Page: Reset-Overload
660cdf0e10cSrcweir ****************************************************************************/
661cdf0e10cSrcweir
662cdf0e10cSrcweir
Reset(const SfxItemSet & rSet)663cdf0e10cSrcweir void SwDropCapsPage::Reset(const SfxItemSet &rSet)
664cdf0e10cSrcweir {
665cdf0e10cSrcweir // Zeichen, Zeilen, Abstand und Text
666cdf0e10cSrcweir SwFmtDrop aFmtDrop((SwFmtDrop &) rSet.Get(RES_PARATR_DROP));
667cdf0e10cSrcweir if (aFmtDrop.GetLines() > 1)
668cdf0e10cSrcweir {
669cdf0e10cSrcweir aDropCapsField.SetValue(aFmtDrop.GetChars());
670cdf0e10cSrcweir aLinesField .SetValue(aFmtDrop.GetLines());
671cdf0e10cSrcweir aDistanceField.SetValue(aDistanceField.Normalize(aFmtDrop.GetDistance()), FUNIT_TWIP);
672cdf0e10cSrcweir aWholeWordCB .Check (aFmtDrop.GetWholeWord());
673cdf0e10cSrcweir }
674cdf0e10cSrcweir else
675cdf0e10cSrcweir {
676cdf0e10cSrcweir aDropCapsField.SetValue(1);
677cdf0e10cSrcweir aLinesField .SetValue(3);
678cdf0e10cSrcweir aDistanceField.SetValue(0);
679cdf0e10cSrcweir }
680cdf0e10cSrcweir
681cdf0e10cSrcweir ::FillCharStyleListBox(aTemplateBox, rSh.GetView().GetDocShell(), sal_True);
682cdf0e10cSrcweir
683cdf0e10cSrcweir aTemplateBox.InsertEntry(SW_RESSTR(SW_STR_NONE), 0);
684cdf0e10cSrcweir // Vorlage defaulten
685cdf0e10cSrcweir aTemplateBox.SelectEntryPos(0);
686cdf0e10cSrcweir if (aFmtDrop.GetCharFmt())
687cdf0e10cSrcweir aTemplateBox.SelectEntry(aFmtDrop.GetCharFmt()->GetName());
688cdf0e10cSrcweir
689cdf0e10cSrcweir // Controls enablen
690cdf0e10cSrcweir aDropCapsBox.Check(aFmtDrop.GetLines() > 1);
691cdf0e10cSrcweir const sal_uInt16 nVal = sal_uInt16(aDropCapsField.GetValue());
692cdf0e10cSrcweir if (bFormat)
693cdf0e10cSrcweir aTextEdit.SetText(GetDefaultString(nVal));
694cdf0e10cSrcweir else
695cdf0e10cSrcweir {
696cdf0e10cSrcweir aTextEdit.SetText(rSh.GetDropTxt(nVal));
697cdf0e10cSrcweir aTextEdit.Enable();
698cdf0e10cSrcweir aTextText.Enable();
699cdf0e10cSrcweir }
700cdf0e10cSrcweir
701cdf0e10cSrcweir // Preview
702cdf0e10cSrcweir pPict->SetValues( aTextEdit.GetText(),
703cdf0e10cSrcweir sal_uInt8( aLinesField.GetValue() ),
704cdf0e10cSrcweir sal_uInt16( aDistanceField.Denormalize( aDistanceField.GetValue( FUNIT_TWIP ) ) ) );
705cdf0e10cSrcweir
706cdf0e10cSrcweir ClickHdl(&aDropCapsBox);
707cdf0e10cSrcweir bModified = sal_False;
708cdf0e10cSrcweir }
709cdf0e10cSrcweir
710cdf0e10cSrcweir /****************************************************************************
711cdf0e10cSrcweir Page: Click-Handler der CheckBox
712cdf0e10cSrcweir ****************************************************************************/
713cdf0e10cSrcweir
714cdf0e10cSrcweir
IMPL_LINK(SwDropCapsPage,ClickHdl,Button *,EMPTYARG)715cdf0e10cSrcweir IMPL_LINK( SwDropCapsPage, ClickHdl, Button *, EMPTYARG )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir sal_Bool bChecked = aDropCapsBox.IsChecked();
718cdf0e10cSrcweir
719cdf0e10cSrcweir aWholeWordCB .Enable( bChecked && !bHtmlMode );
720cdf0e10cSrcweir
721cdf0e10cSrcweir aSwitchText.Enable( bChecked && !aWholeWordCB.IsChecked() );
722cdf0e10cSrcweir aDropCapsField.Enable( bChecked && !aWholeWordCB.IsChecked() );
723cdf0e10cSrcweir aLinesText .Enable( bChecked );
724cdf0e10cSrcweir aLinesField .Enable( bChecked );
725cdf0e10cSrcweir aDistanceText.Enable( bChecked );
726cdf0e10cSrcweir aDistanceField.Enable( bChecked );
727cdf0e10cSrcweir aTemplateText .Enable( bChecked );
728cdf0e10cSrcweir aTemplateBox .Enable( bChecked );
729cdf0e10cSrcweir aTextEdit .Enable( bChecked && !bFormat );
730cdf0e10cSrcweir aTextText .Enable( bChecked && !bFormat );
731cdf0e10cSrcweir
732cdf0e10cSrcweir if ( bChecked )
733cdf0e10cSrcweir {
734cdf0e10cSrcweir ModifyHdl(&aDropCapsField);
735cdf0e10cSrcweir aDropCapsField.GrabFocus();
736cdf0e10cSrcweir }
737cdf0e10cSrcweir else
738cdf0e10cSrcweir pPict->SetText(aEmptyStr);
739cdf0e10cSrcweir
740cdf0e10cSrcweir bModified = sal_True;
741cdf0e10cSrcweir
742cdf0e10cSrcweir return 0;
743cdf0e10cSrcweir }
744cdf0e10cSrcweir
745cdf0e10cSrcweir /****************************************************************************
746cdf0e10cSrcweir Page: Click-Handler der CheckBox
747cdf0e10cSrcweir ****************************************************************************/
748cdf0e10cSrcweir
749cdf0e10cSrcweir
IMPL_LINK(SwDropCapsPage,WholeWordHdl,CheckBox *,EMPTYARG)750cdf0e10cSrcweir IMPL_LINK( SwDropCapsPage, WholeWordHdl, CheckBox *, EMPTYARG )
751cdf0e10cSrcweir {
752cdf0e10cSrcweir aDropCapsField.Enable( !aWholeWordCB.IsChecked() );
753cdf0e10cSrcweir
754cdf0e10cSrcweir ModifyHdl(&aDropCapsField);
755cdf0e10cSrcweir
756cdf0e10cSrcweir bModified = sal_True;
757cdf0e10cSrcweir
758cdf0e10cSrcweir return 0;
759cdf0e10cSrcweir }
760cdf0e10cSrcweir
761cdf0e10cSrcweir /****************************************************************************
762cdf0e10cSrcweir Page: Modify-Handler der SpinFields
763cdf0e10cSrcweir ****************************************************************************/
764cdf0e10cSrcweir
765cdf0e10cSrcweir
IMPL_LINK(SwDropCapsPage,ModifyHdl,Edit *,pEdit)766cdf0e10cSrcweir IMPL_LINK( SwDropCapsPage, ModifyHdl, Edit *, pEdit )
767cdf0e10cSrcweir {
768cdf0e10cSrcweir String sPreview;
769cdf0e10cSrcweir
770cdf0e10cSrcweir // Ggf. Text setzen
771cdf0e10cSrcweir if (pEdit == &aDropCapsField)
772cdf0e10cSrcweir {
773cdf0e10cSrcweir sal_uInt16 nVal;
774cdf0e10cSrcweir sal_Bool bSetText = sal_False;
775cdf0e10cSrcweir
776cdf0e10cSrcweir if (!aWholeWordCB.IsChecked())
777cdf0e10cSrcweir nVal = (sal_uInt16)aDropCapsField.GetValue();
778cdf0e10cSrcweir else
779cdf0e10cSrcweir nVal = 0;
780cdf0e10cSrcweir
781cdf0e10cSrcweir if (bFormat || !rSh.GetDropTxt(1).Len())
782cdf0e10cSrcweir sPreview = GetDefaultString(nVal);
783cdf0e10cSrcweir else
784cdf0e10cSrcweir {
785cdf0e10cSrcweir bSetText = sal_True;
786cdf0e10cSrcweir sPreview = rSh.GetDropTxt(nVal);
787cdf0e10cSrcweir }
788cdf0e10cSrcweir
789cdf0e10cSrcweir String sEdit(aTextEdit.GetText());
790cdf0e10cSrcweir
791cdf0e10cSrcweir if (sEdit.Len() && sPreview.CompareTo(sEdit, sEdit.Len()) != COMPARE_EQUAL)
792cdf0e10cSrcweir {
793cdf0e10cSrcweir sPreview = sEdit.Copy(0, sPreview.Len());
794cdf0e10cSrcweir bSetText = sal_False;
795cdf0e10cSrcweir }
796cdf0e10cSrcweir
797cdf0e10cSrcweir if (bSetText)
798cdf0e10cSrcweir aTextEdit.SetText(sPreview);
799cdf0e10cSrcweir }
800cdf0e10cSrcweir else if (pEdit == &aTextEdit) // Ggf. Anzahl setzen
801cdf0e10cSrcweir {
802cdf0e10cSrcweir sal_uInt16 nTmp = aTextEdit.GetText().Len();
803cdf0e10cSrcweir aDropCapsField.SetValue(Max((sal_uInt16)1, nTmp));
804cdf0e10cSrcweir
805cdf0e10cSrcweir sPreview = aTextEdit.GetText().Copy(0, nTmp);
806cdf0e10cSrcweir }
807cdf0e10cSrcweir
808cdf0e10cSrcweir // Bild anpassen
809cdf0e10cSrcweir if (pEdit == &aDropCapsField || pEdit == &aTextEdit)
810cdf0e10cSrcweir pPict->SetText (sPreview);
811cdf0e10cSrcweir else if (pEdit == &aLinesField)
812cdf0e10cSrcweir pPict->SetLines((sal_uInt8)aLinesField.GetValue());
813cdf0e10cSrcweir else
814cdf0e10cSrcweir pPict->SetDistance((sal_uInt16)aDistanceField.Denormalize(aDistanceField.GetValue(FUNIT_TWIP)));
815cdf0e10cSrcweir
816cdf0e10cSrcweir bModified = sal_True;
817cdf0e10cSrcweir
818cdf0e10cSrcweir return 0;
819cdf0e10cSrcweir }
820cdf0e10cSrcweir
821cdf0e10cSrcweir /****************************************************************************
822cdf0e10cSrcweir Page: Select-Handler der Template-Box.
823cdf0e10cSrcweir *****************************************************************************/
824cdf0e10cSrcweir
825cdf0e10cSrcweir
IMPL_LINK_INLINE_START(SwDropCapsPage,SelectHdl,ListBox *,EMPTYARG)826cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwDropCapsPage, SelectHdl, ListBox *, EMPTYARG )
827cdf0e10cSrcweir {
828cdf0e10cSrcweir pPict->UpdatePaintSettings();
829cdf0e10cSrcweir bModified = sal_True;
830cdf0e10cSrcweir return 0;
831cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(SwDropCapsPage,SelectHdl,ListBox *,EMPTYARG)832cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwDropCapsPage, SelectHdl, ListBox *, EMPTYARG )
833cdf0e10cSrcweir
834cdf0e10cSrcweir
835cdf0e10cSrcweir sal_uInt16* SwDropCapsPage::GetRanges()
836cdf0e10cSrcweir {
837cdf0e10cSrcweir return aPageRg;
838cdf0e10cSrcweir }
839cdf0e10cSrcweir
840cdf0e10cSrcweir
FillSet(SfxItemSet & rSet)841cdf0e10cSrcweir void SwDropCapsPage::FillSet( SfxItemSet &rSet )
842cdf0e10cSrcweir {
843cdf0e10cSrcweir if(bModified)
844cdf0e10cSrcweir {
845cdf0e10cSrcweir SwFmtDrop aFmt;
846cdf0e10cSrcweir
847cdf0e10cSrcweir sal_Bool bOn = aDropCapsBox.IsChecked();
848cdf0e10cSrcweir if(bOn)
849cdf0e10cSrcweir {
850cdf0e10cSrcweir // Anzahl, Zeilen, Abstand
851cdf0e10cSrcweir aFmt.GetChars() = (sal_uInt8) aDropCapsField.GetValue();
852cdf0e10cSrcweir aFmt.GetLines() = (sal_uInt8) aLinesField.GetValue();
853cdf0e10cSrcweir aFmt.GetDistance() = (sal_uInt16) aDistanceField.Denormalize(aDistanceField.GetValue(FUNIT_TWIP));
854cdf0e10cSrcweir aFmt.GetWholeWord() = aWholeWordCB.IsChecked();
855cdf0e10cSrcweir
856cdf0e10cSrcweir // Vorlage
857cdf0e10cSrcweir if (aTemplateBox.GetSelectEntryPos())
858cdf0e10cSrcweir aFmt.SetCharFmt(rSh.GetCharStyle(aTemplateBox.GetSelectEntry()));
859cdf0e10cSrcweir }
860cdf0e10cSrcweir else
861cdf0e10cSrcweir {
862cdf0e10cSrcweir aFmt.GetChars() = 1;
863cdf0e10cSrcweir aFmt.GetLines() = 1;
864cdf0e10cSrcweir aFmt.GetDistance() = 0;
865cdf0e10cSrcweir }
866cdf0e10cSrcweir
867cdf0e10cSrcweir // Attribute setzen
868cdf0e10cSrcweir const SfxPoolItem* pOldItem;
869cdf0e10cSrcweir if(0 == (pOldItem = GetOldItem( rSet, FN_FORMAT_DROPCAPS )) ||
870cdf0e10cSrcweir aFmt != *pOldItem )
871cdf0e10cSrcweir rSet.Put(aFmt);
872cdf0e10cSrcweir
873cdf0e10cSrcweir // Harte Textformatierung
874cdf0e10cSrcweir // Bug 24974: In Gestalter/Vorlagenkatoplog macht das keinen Sinn!!
875cdf0e10cSrcweir if( !bFormat && aDropCapsBox.IsChecked() )
876cdf0e10cSrcweir {
877cdf0e10cSrcweir String sText(aTextEdit.GetText());
878cdf0e10cSrcweir
879cdf0e10cSrcweir if (!aWholeWordCB.IsChecked())
880cdf0e10cSrcweir sText.Erase( static_cast< xub_StrLen >(aDropCapsField.GetValue()));
881cdf0e10cSrcweir
882cdf0e10cSrcweir SfxStringItem aStr(FN_PARAM_1, sText);
883cdf0e10cSrcweir rSet.Put( aStr );
884cdf0e10cSrcweir }
885cdf0e10cSrcweir }
886cdf0e10cSrcweir }
887cdf0e10cSrcweir
888cdf0e10cSrcweir
889cdf0e10cSrcweir
890cdf0e10cSrcweir
891