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