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 31*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION 32*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <hintids.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <tools/pstm.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #define _SVSTDARR_LONGSSORT 43*cdf0e10cSrcweir #define _SVSTDARR_LONGS 44*cdf0e10cSrcweir #include <svl/svstdarr.hxx> 45*cdf0e10cSrcweir #include <editeng/paperinf.hxx> 46*cdf0e10cSrcweir #ifndef _SVX_TSTPITEM_HXX //autogen 47*cdf0e10cSrcweir #include <editeng/tstpitem.hxx> 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #include <editeng/lrspitem.hxx> 50*cdf0e10cSrcweir #include <editeng/brshitem.hxx> 51*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen 52*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir #ifndef _MENU_HXX //autogen 55*cdf0e10cSrcweir #include <vcl/menu.hxx> 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #ifndef _CMDID_H 59*cdf0e10cSrcweir #include <cmdid.h> 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir #include <frmatr.hxx> 62*cdf0e10cSrcweir #include <swtypes.hxx> 63*cdf0e10cSrcweir #include <wrtsh.hxx> 64*cdf0e10cSrcweir #ifndef _VIEW_HXX 65*cdf0e10cSrcweir #include <view.hxx> 66*cdf0e10cSrcweir #endif 67*cdf0e10cSrcweir #ifndef _BASESH_HXX 68*cdf0e10cSrcweir #include <basesh.hxx> 69*cdf0e10cSrcweir #endif 70*cdf0e10cSrcweir #include <drpcps.hxx> 71*cdf0e10cSrcweir #include <envfmt.hxx> 72*cdf0e10cSrcweir #include <fmtcol.hxx> 73*cdf0e10cSrcweir #ifndef _PARDLG_HXX 74*cdf0e10cSrcweir #include "swuipardlg.hxx" 75*cdf0e10cSrcweir #endif 76*cdf0e10cSrcweir #include <pattern.hxx> 77*cdf0e10cSrcweir #include <poolfmt.hxx> 78*cdf0e10cSrcweir #include <uiborder.hxx> 79*cdf0e10cSrcweir #include <uitool.hxx> 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir #ifndef _ENVFMT_HRC 82*cdf0e10cSrcweir #include <envfmt.hrc> 83*cdf0e10cSrcweir #endif 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir #include "swabstdlg.hxx" 86*cdf0e10cSrcweir #include "chrdlg.hrc" 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir namespace swui 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir SwAbstractDialogFactory * GetFactory(); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir static PopupMenu *pMenu; 94*cdf0e10cSrcweir static long lUserW = 5669; // 10 cm 95*cdf0e10cSrcweir static long lUserH = 5669; // 10 cm 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir // -------------------------------------------------------------------------- 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir SwEnvFmtPage::SwEnvFmtPage(Window* pParent, const SfxItemSet& rSet) : 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir SfxTabPage(pParent, SW_RES(TP_ENV_FMT), rSet), 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir aAddrFL (this, SW_RES( FL_ADDRESSEE )), 105*cdf0e10cSrcweir aAddrPosInfo (this, SW_RES( TXT_ADDR_POS )), 106*cdf0e10cSrcweir aAddrLeftText (this, SW_RES( TXT_ADDR_LEFT )), 107*cdf0e10cSrcweir aAddrLeftField (this, SW_RES( FLD_ADDR_LEFT )), 108*cdf0e10cSrcweir aAddrTopText (this, SW_RES( TXT_ADDR_TOP )), 109*cdf0e10cSrcweir aAddrTopField (this, SW_RES( FLD_ADDR_TOP )), 110*cdf0e10cSrcweir aAddrFormatInfo (this, SW_RES( TXT_ADDR_FORMAT )), 111*cdf0e10cSrcweir aAddrEditButton (this, SW_RES( BTN_ADDR_EDIT )), 112*cdf0e10cSrcweir aSendFL (this, SW_RES( FL_SENDER )), 113*cdf0e10cSrcweir aSendPosInfo (this, SW_RES( TXT_SEND_POS )), 114*cdf0e10cSrcweir aSendLeftText (this, SW_RES( TXT_SEND_LEFT )), 115*cdf0e10cSrcweir aSendLeftField (this, SW_RES( FLD_SEND_LEFT )), 116*cdf0e10cSrcweir aSendTopText (this, SW_RES( TXT_SEND_TOP )), 117*cdf0e10cSrcweir aSendTopField (this, SW_RES( FLD_SEND_TOP )), 118*cdf0e10cSrcweir aSendFormatInfo (this, SW_RES( TXT_SEND_FORMAT )), 119*cdf0e10cSrcweir aSendEditButton (this, SW_RES( BTN_SEND_EDIT )), 120*cdf0e10cSrcweir aSizeFL (this, SW_RES( FL_SIZE )), 121*cdf0e10cSrcweir aSizeFormatText (this, SW_RES( TXT_SIZE_FORMAT )), 122*cdf0e10cSrcweir aSizeFormatBox (this, SW_RES( BOX_SIZE_FORMAT )), 123*cdf0e10cSrcweir aSizeWidthText (this, SW_RES( TXT_SIZE_WIDTH )), 124*cdf0e10cSrcweir aSizeWidthField (this, SW_RES( FLD_SIZE_WIDTH )), 125*cdf0e10cSrcweir aSizeHeightText (this, SW_RES( TXT_SIZE_HEIGHT )), 126*cdf0e10cSrcweir aSizeHeightField (this, SW_RES( FLD_SIZE_HEIGHT )), 127*cdf0e10cSrcweir aPreview (this, SW_RES( WIN_PREVIEW )) 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir FreeResource(); 131*cdf0e10cSrcweir SetExchangeSupport(); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir // Metriken 134*cdf0e10cSrcweir FieldUnit aMetric = ::GetDfltMetric(sal_False); 135*cdf0e10cSrcweir SetMetric(aAddrLeftField, aMetric); 136*cdf0e10cSrcweir SetMetric(aAddrTopField, aMetric); 137*cdf0e10cSrcweir SetMetric(aSendLeftField, aMetric); 138*cdf0e10cSrcweir SetMetric(aSendTopField, aMetric); 139*cdf0e10cSrcweir SetMetric(aSizeWidthField, aMetric); 140*cdf0e10cSrcweir SetMetric(aSizeHeightField, aMetric); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir // Menues einhaengen 143*cdf0e10cSrcweir ::pMenu = new PopupMenu(SW_RES(MNU_EDIT)); 144*cdf0e10cSrcweir aAddrEditButton.SetPopupMenu(::pMenu); 145*cdf0e10cSrcweir aSendEditButton.SetPopupMenu(::pMenu); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir // Handler installieren 148*cdf0e10cSrcweir Link aLk = LINK(this, SwEnvFmtPage, ModifyHdl); 149*cdf0e10cSrcweir aAddrLeftField .SetUpHdl( aLk ); 150*cdf0e10cSrcweir aAddrTopField .SetUpHdl( aLk ); 151*cdf0e10cSrcweir aSendLeftField .SetUpHdl( aLk ); 152*cdf0e10cSrcweir aSendTopField .SetUpHdl( aLk ); 153*cdf0e10cSrcweir aSizeWidthField .SetUpHdl( aLk ); 154*cdf0e10cSrcweir aSizeHeightField.SetUpHdl( aLk ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir aAddrLeftField .SetDownHdl( aLk ); 157*cdf0e10cSrcweir aAddrTopField .SetDownHdl( aLk ); 158*cdf0e10cSrcweir aSendLeftField .SetDownHdl( aLk ); 159*cdf0e10cSrcweir aSendTopField .SetDownHdl( aLk ); 160*cdf0e10cSrcweir aSizeWidthField .SetDownHdl( aLk ); 161*cdf0e10cSrcweir aSizeHeightField.SetDownHdl( aLk ); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir aAddrLeftField .SetLoseFocusHdl( aLk ); 164*cdf0e10cSrcweir aAddrTopField .SetLoseFocusHdl( aLk ); 165*cdf0e10cSrcweir aSendLeftField .SetLoseFocusHdl( aLk ); 166*cdf0e10cSrcweir aSendTopField .SetLoseFocusHdl( aLk ); 167*cdf0e10cSrcweir aSizeWidthField .SetLoseFocusHdl( aLk ); 168*cdf0e10cSrcweir aSizeHeightField.SetLoseFocusHdl( aLk ); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir aLk = LINK(this, SwEnvFmtPage, EditHdl ); 171*cdf0e10cSrcweir aAddrEditButton.SetSelectHdl( aLk ); 172*cdf0e10cSrcweir aSendEditButton.SetSelectHdl( aLk ); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir aPreview.SetBorderStyle( WINDOW_BORDER_MONO ); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir aSizeFormatBox .SetSelectHdl(LINK(this, SwEnvFmtPage, FormatHdl)); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir // aSizeFormatBox 179*cdf0e10cSrcweir for (sal_uInt16 i = PAPER_A3; i <= PAPER_KAI32BIG; i++) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir if (i != PAPER_USER) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir String aPaperName = SvxPaperInfo::GetName((Paper) i), 184*cdf0e10cSrcweir aEntryName; 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir sal_uInt16 nPos = 0; 187*cdf0e10cSrcweir sal_Bool bFound = sal_False; 188*cdf0e10cSrcweir while (nPos < aSizeFormatBox.GetEntryCount() && !bFound) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir aEntryName = aSizeFormatBox.GetEntry(i); 191*cdf0e10cSrcweir if (aEntryName < aPaperName) 192*cdf0e10cSrcweir nPos++; 193*cdf0e10cSrcweir else 194*cdf0e10cSrcweir bFound = sal_True; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir aSizeFormatBox.InsertEntry(aPaperName, nPos); 197*cdf0e10cSrcweir aIDs.Insert((sal_uInt16) i, nPos); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir aSizeFormatBox.InsertEntry(SvxPaperInfo::GetName(PAPER_USER)); 201*cdf0e10cSrcweir aIDs.Insert((sal_uInt16) PAPER_USER, aIDs.Count()); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir // -------------------------------------------------------------------------- 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir __EXPORT SwEnvFmtPage::~SwEnvFmtPage() 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir aAddrEditButton.SetPopupMenu(0); 211*cdf0e10cSrcweir aSendEditButton.SetPopupMenu(0); 212*cdf0e10cSrcweir delete ::pMenu; 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir // -------------------------------------------------------------------------- 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SwEnvFmtPage, ModifyHdl, Edit *, pEdit ) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir long lWVal = static_cast< long >(GetFldVal(aSizeWidthField )); 221*cdf0e10cSrcweir long lHVal = static_cast< long >(GetFldVal(aSizeHeightField)); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir long lWidth = Max(lWVal, lHVal); 224*cdf0e10cSrcweir long lHeight = Min(lWVal, lHVal); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir if (pEdit == &aSizeWidthField || pEdit == &aSizeHeightField) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir Paper ePaper = SvxPaperInfo::GetSvxPaper( 229*cdf0e10cSrcweir Size(lHeight, lWidth), MAP_TWIP, sal_True); 230*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < aIDs.Count(); i++) 231*cdf0e10cSrcweir if (aIDs[i] == (sal_uInt16)ePaper) 232*cdf0e10cSrcweir aSizeFormatBox.SelectEntryPos(i); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir // Benutzergroesse merken 235*cdf0e10cSrcweir if (aIDs[aSizeFormatBox.GetSelectEntryPos()] == (sal_uInt16)PAPER_USER) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir lUserW = lWidth ; 238*cdf0e10cSrcweir lUserH = lHeight; 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir aSizeFormatBox.GetSelectHdl().Call(&aSizeFormatBox); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir else 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir FillItem(GetParent()->aEnvItem); 246*cdf0e10cSrcweir SetMinMax(); 247*cdf0e10cSrcweir aPreview.Invalidate(); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir return 0; 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SwEnvFmtPage, ModifyHdl, Edit *, pEdit ) 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir // -------------------------------------------------------------------------- 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir IMPL_LINK( SwEnvFmtPage, EditHdl, MenuButton *, pButton ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir SwWrtShell* pSh = GetParent()->pSh; 259*cdf0e10cSrcweir ASSERT(pSh, "Shell fehlt"); 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir // Collection-Ptr ermitteln 262*cdf0e10cSrcweir sal_Bool bSender = pButton != &aAddrEditButton; 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir SwTxtFmtColl* pColl = pSh->GetTxtCollFromPool( static_cast< sal_uInt16 >( 265*cdf0e10cSrcweir bSender ? RES_POOLCOLL_SENDADRESS : RES_POOLCOLL_JAKETADRESS)); 266*cdf0e10cSrcweir ASSERT(pColl, "Text-Collection fehlt"); 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir switch (pButton->GetCurItemId()) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir case MID_CHAR: 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir // Damit die Hintergrundfarbe nicht uebergebuegelt wird: 275*cdf0e10cSrcweir SfxAllItemSet aTmpSet(*pCollSet); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir // Das CHRATR_BACKGROUND-Attribut wird fuer den Dialog in 278*cdf0e10cSrcweir // ein RES_BACKGROUND verwandelt und wieder zurueck ... 279*cdf0e10cSrcweir const SfxPoolItem *pTmpBrush; 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir if( SFX_ITEM_SET == aTmpSet.GetItemState( RES_CHRATR_BACKGROUND, 282*cdf0e10cSrcweir sal_True, &pTmpBrush ) ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 285*cdf0e10cSrcweir aTmpBrush.SetWhich( RES_BACKGROUND ); 286*cdf0e10cSrcweir aTmpSet.Put( aTmpBrush ); 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir else 289*cdf0e10cSrcweir aTmpSet.ClearItem( RES_BACKGROUND ); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir SwAbstractDialogFactory* pFact = swui::GetFactory(); 292*cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( GetParent(), pSh->GetView(), aTmpSet, DLG_CHAR ,&pColl->GetName() ); 295*cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!"); 296*cdf0e10cSrcweir if (pDlg->Execute() == RET_OK) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir SfxItemSet aOutputSet( *pDlg->GetOutputItemSet() ); 299*cdf0e10cSrcweir if( SFX_ITEM_SET == aOutputSet.GetItemState( RES_BACKGROUND, 300*cdf0e10cSrcweir sal_False, &pTmpBrush ) ) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir SvxBrushItem aTmpBrush( *((SvxBrushItem*)pTmpBrush) ); 303*cdf0e10cSrcweir aTmpBrush.SetWhich( RES_CHRATR_BACKGROUND ); 304*cdf0e10cSrcweir pCollSet->Put( aTmpBrush ); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir aOutputSet.ClearItem( RES_BACKGROUND ); 307*cdf0e10cSrcweir //pColl->SetAttr( aTmpSet ); 308*cdf0e10cSrcweir pCollSet->Put(aOutputSet); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir delete pDlg; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir break; 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir case MID_PARA: 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir SfxItemSet *pCollSet = GetCollItemSet(pColl, bSender); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir // Damit die Tabulatoren nicht uebergebuegelt werden: 319*cdf0e10cSrcweir SfxAllItemSet aTmpSet(*pCollSet); 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir // Tabulatoren, DefaultTabs ins ItemSet Stecken 322*cdf0e10cSrcweir const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&) 323*cdf0e10cSrcweir pSh->GetView().GetCurShell()->GetPool().GetDefaultItem(RES_PARATR_TABSTOP); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir sal_uInt16 nDefDist = ::GetTabDist( rDefTabs ); 326*cdf0e10cSrcweir SfxUInt16Item aDefDistItem( SID_ATTR_TABSTOP_DEFAULTS, nDefDist ); 327*cdf0e10cSrcweir aTmpSet.Put( aDefDistItem ); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir // Aktueller Tab 330*cdf0e10cSrcweir SfxUInt16Item aTabPos( SID_ATTR_TABSTOP_POS, 0 ); 331*cdf0e10cSrcweir aTmpSet.Put( aTabPos ); 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir // linker Rand als Offset 334*cdf0e10cSrcweir const long nOff = ((SvxLRSpaceItem&)aTmpSet.Get( RES_LR_SPACE )). 335*cdf0e10cSrcweir GetTxtLeft(); 336*cdf0e10cSrcweir SfxInt32Item aOff( SID_ATTR_TABSTOP_OFFSET, nOff ); 337*cdf0e10cSrcweir aTmpSet.Put( aOff ); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir // BoxInfo setzen 340*cdf0e10cSrcweir ::PrepareBoxInfo( aTmpSet, *pSh ); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir SwParaDlg *pDlg = new SwParaDlg(GetParent(), pSh->GetView(), aTmpSet, DLG_ENVELOP, &pColl->GetName()); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir if ( pDlg->Execute() == RET_OK ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir // Defaults evtl umsetzen 347*cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 348*cdf0e10cSrcweir SfxItemSet* pOutputSet = (SfxItemSet*)pDlg->GetOutputItemSet(); 349*cdf0e10cSrcweir sal_uInt16 nNewDist; 350*cdf0e10cSrcweir if( SFX_ITEM_SET == pOutputSet->GetItemState( SID_ATTR_TABSTOP_DEFAULTS, 351*cdf0e10cSrcweir sal_False, &pItem ) && 352*cdf0e10cSrcweir nDefDist != (nNewDist = ((SfxUInt16Item*)pItem)->GetValue()) ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir SvxTabStopItem aDefTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ); 355*cdf0e10cSrcweir MakeDefTabs( nNewDist, aDefTabs ); 356*cdf0e10cSrcweir pSh->SetDefault( aDefTabs ); 357*cdf0e10cSrcweir pOutputSet->ClearItem( SID_ATTR_TABSTOP_DEFAULTS ); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir if( pOutputSet->Count() ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir //pColl->SetAttr( *pOutputSet ); 362*cdf0e10cSrcweir pCollSet->Put(*pOutputSet); 363*cdf0e10cSrcweir } 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir delete pDlg; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir break; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir return 0; 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir /*------------------------------------------------------------------------ 373*cdf0e10cSrcweir Beschreibung: Ein temporaeres Itemset, das bei Abbruch verworfen wird 374*cdf0e10cSrcweir ------------------------------------------------------------------------*/ 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir SfxItemSet *SwEnvFmtPage::GetCollItemSet(SwTxtFmtColl* pColl, sal_Bool bSender) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir SfxItemSet *&pAddrSet = bSender ? GetParent()->pSenderSet : GetParent()->pAddresseeSet; 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir if (!pAddrSet) 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir // Range ermitteln (Ranges beider Itemsets mergen) 383*cdf0e10cSrcweir const sal_uInt16 *pRanges = pColl->GetAttrSet().GetRanges(); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA aRanges[] = 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir RES_PARATR_BEGIN, RES_PARATR_ADJUST, 388*cdf0e10cSrcweir RES_PARATR_TABSTOP, RES_PARATR_END-1, 389*cdf0e10cSrcweir RES_LR_SPACE, RES_UL_SPACE, 390*cdf0e10cSrcweir RES_BACKGROUND, RES_SHADOW, 391*cdf0e10cSrcweir SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS, 392*cdf0e10cSrcweir SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS, 393*cdf0e10cSrcweir SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET, 394*cdf0e10cSrcweir SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 395*cdf0e10cSrcweir 0, 0 396*cdf0e10cSrcweir }; 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir // BruteForce-Merge, weil MergeRange in SvTools buggy ist: 399*cdf0e10cSrcweir sal_uInt16 i = 0; 400*cdf0e10cSrcweir SvLongsSort aMergedRanges( 0, 10 ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir while (pRanges[i]) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir for (sal_uInt16 nPos = pRanges[i]; nPos <= pRanges[i+1]; nPos++) 405*cdf0e10cSrcweir aMergedRanges.Insert(nPos); 406*cdf0e10cSrcweir i += 2; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir i = 0; 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir while (aRanges[i]) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir for (sal_uInt16 nPos = aRanges[i]; nPos <= aRanges[i+1]; nPos++) 414*cdf0e10cSrcweir aMergedRanges.Insert(nPos); 415*cdf0e10cSrcweir i += 2; 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir // Ranges kompaktieren 419*cdf0e10cSrcweir SvLongs aCompactedRanges( 0, 10 ); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir aCompactedRanges.Insert(aMergedRanges[0], aCompactedRanges.Count()); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir for (i = 0; i < aMergedRanges.Count(); i++) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir while (i + 1 < aMergedRanges.Count() && 426*cdf0e10cSrcweir aMergedRanges[i+1] - aMergedRanges[i] == 1) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir i++; 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir long nEnd = aMergedRanges[i]; 431*cdf0e10cSrcweir aCompactedRanges.Insert(nEnd, aCompactedRanges.Count()); 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir if (i + 1 < aMergedRanges.Count()) 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir long nStart = aMergedRanges[i+1]; 436*cdf0e10cSrcweir aCompactedRanges.Insert(nStart, aCompactedRanges.Count()); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir // Neue Ranges erzeugen 441*cdf0e10cSrcweir sal_uInt16 *pNewRanges = new sal_uInt16[aCompactedRanges.Count() + 1]; 442*cdf0e10cSrcweir for (i = 0; i < aCompactedRanges.Count(); i++) 443*cdf0e10cSrcweir pNewRanges[i] = (sal_uInt16)aCompactedRanges[i]; 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir pNewRanges[i] = 0; 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir pAddrSet = new SfxItemSet(GetParent()->pSh->GetView().GetCurShell()->GetPool(), 448*cdf0e10cSrcweir pNewRanges); 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir pAddrSet->Put(pColl->GetAttrSet()); 451*cdf0e10cSrcweir delete[] pNewRanges; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir return pAddrSet; 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir // -------------------------------------------------------------------------- 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir IMPL_LINK( SwEnvFmtPage, FormatHdl, ListBox *, EMPTYARG ) 461*cdf0e10cSrcweir { 462*cdf0e10cSrcweir long lWidth; 463*cdf0e10cSrcweir long lHeight; 464*cdf0e10cSrcweir long lSendFromLeft; 465*cdf0e10cSrcweir long lSendFromTop; 466*cdf0e10cSrcweir long lAddrFromLeft; 467*cdf0e10cSrcweir long lAddrFromTop; 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir sal_uInt16 nPaper = aIDs[aSizeFormatBox.GetSelectEntryPos()]; 470*cdf0e10cSrcweir if (nPaper != (sal_uInt16)PAPER_USER) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir Size aSz = SvxPaperInfo::GetPaperSize((Paper)nPaper); 473*cdf0e10cSrcweir lWidth = Max(aSz.Width(), aSz.Height()); 474*cdf0e10cSrcweir lHeight = Min(aSz.Width(), aSz.Height()); 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir else 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir lWidth = lUserW; 479*cdf0e10cSrcweir lHeight = lUserH; 480*cdf0e10cSrcweir } 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir lSendFromLeft = 566; // 1cm 483*cdf0e10cSrcweir lSendFromTop = 566; // 1cm 484*cdf0e10cSrcweir lAddrFromLeft = lWidth / 2; 485*cdf0e10cSrcweir lAddrFromTop = lHeight / 2; 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir SetFldVal(aAddrLeftField, lAddrFromLeft); 488*cdf0e10cSrcweir SetFldVal(aAddrTopField , lAddrFromTop ); 489*cdf0e10cSrcweir SetFldVal(aSendLeftField, lSendFromLeft); 490*cdf0e10cSrcweir SetFldVal(aSendTopField , lSendFromTop ); 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir SetFldVal(aSizeWidthField , lWidth ); 493*cdf0e10cSrcweir SetFldVal(aSizeHeightField, lHeight); 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir SetMinMax(); 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir FillItem(GetParent()->aEnvItem); 498*cdf0e10cSrcweir aPreview.Invalidate(); 499*cdf0e10cSrcweir return 0; 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir // -------------------------------------------------------------------------- 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir void SwEnvFmtPage::SetMinMax() 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir long lWVal = static_cast< long >(GetFldVal(aSizeWidthField )); 508*cdf0e10cSrcweir long lHVal = static_cast< long >(GetFldVal(aSizeHeightField)); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir long lWidth = Max(lWVal, lHVal), 511*cdf0e10cSrcweir lHeight = Min(lWVal, lHVal); 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir // Min und Max 514*cdf0e10cSrcweir aAddrLeftField.SetMin((long) 100 * (GetFldVal(aSendLeftField) + 566), FUNIT_TWIP); 515*cdf0e10cSrcweir aAddrLeftField.SetMax((long) 100 * (lWidth - 2 * 566), FUNIT_TWIP); 516*cdf0e10cSrcweir aAddrTopField .SetMin((long) 100 * (GetFldVal(aSendTopField ) + 2 * 566), FUNIT_TWIP); 517*cdf0e10cSrcweir aAddrTopField .SetMax((long) 100 * (lHeight - 2 * 566), FUNIT_TWIP); 518*cdf0e10cSrcweir aSendLeftField.SetMin((long) 100 * (566), FUNIT_TWIP); 519*cdf0e10cSrcweir aSendLeftField.SetMax((long) 100 * (GetFldVal(aAddrLeftField) - 566), FUNIT_TWIP); 520*cdf0e10cSrcweir aSendTopField .SetMin((long) 100 * (566), FUNIT_TWIP); 521*cdf0e10cSrcweir aSendTopField .SetMax((long) 100 * (GetFldVal(aAddrTopField ) - 2 * 566), FUNIT_TWIP); 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir // First und Last 524*cdf0e10cSrcweir aAddrLeftField.SetFirst(aAddrLeftField.GetMin()); 525*cdf0e10cSrcweir aAddrLeftField.SetLast (aAddrLeftField.GetMax()); 526*cdf0e10cSrcweir aAddrTopField .SetFirst(aAddrTopField .GetMin()); 527*cdf0e10cSrcweir aAddrTopField .SetLast (aAddrTopField .GetMax()); 528*cdf0e10cSrcweir aSendLeftField.SetFirst(aSendLeftField.GetMin()); 529*cdf0e10cSrcweir aSendLeftField.SetLast (aSendLeftField.GetMax()); 530*cdf0e10cSrcweir aSendTopField .SetFirst(aSendTopField .GetMin()); 531*cdf0e10cSrcweir aSendTopField .SetLast (aSendTopField .GetMax()); 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir // Fields neu formatieren 534*cdf0e10cSrcweir aAddrLeftField .Reformat(); 535*cdf0e10cSrcweir aAddrTopField .Reformat(); 536*cdf0e10cSrcweir aSendLeftField .Reformat(); 537*cdf0e10cSrcweir aSendTopField .Reformat(); 538*cdf0e10cSrcweir aSizeWidthField .Reformat(); 539*cdf0e10cSrcweir aSizeHeightField.Reformat(); 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir // -------------------------------------------------------------------------- 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir SfxTabPage* __EXPORT SwEnvFmtPage::Create(Window* pParent, const SfxItemSet& rSet) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir return new SwEnvFmtPage(pParent, rSet); 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir void __EXPORT SwEnvFmtPage::ActivatePage(const SfxItemSet& rSet) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir SfxItemSet aSet(rSet); 556*cdf0e10cSrcweir aSet.Put(GetParent()->aEnvItem); 557*cdf0e10cSrcweir Reset(aSet); 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir // ---------------------------------------------------------------------------- 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir int __EXPORT SwEnvFmtPage::DeactivatePage(SfxItemSet* _pSet) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir if( _pSet ) 566*cdf0e10cSrcweir FillItemSet(*_pSet); 567*cdf0e10cSrcweir return SfxTabPage::LEAVE_PAGE; 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir // -------------------------------------------------------------------------- 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir void SwEnvFmtPage::FillItem(SwEnvItem& rItem) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir rItem.lAddrFromLeft = static_cast< sal_Int32 >(GetFldVal(aAddrLeftField)); 576*cdf0e10cSrcweir rItem.lAddrFromTop = static_cast< sal_Int32 >(GetFldVal(aAddrTopField )); 577*cdf0e10cSrcweir rItem.lSendFromLeft = static_cast< sal_Int32 >(GetFldVal(aSendLeftField)); 578*cdf0e10cSrcweir rItem.lSendFromTop = static_cast< sal_Int32 >(GetFldVal(aSendTopField )); 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir sal_uInt16 nPaper = aIDs[aSizeFormatBox.GetSelectEntryPos()]; 581*cdf0e10cSrcweir if (nPaper == (sal_uInt16)PAPER_USER) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir long lWVal = static_cast< long >(GetFldVal(aSizeWidthField )); 584*cdf0e10cSrcweir long lHVal = static_cast< long >(GetFldVal(aSizeHeightField)); 585*cdf0e10cSrcweir rItem.lWidth = Max(lWVal, lHVal); 586*cdf0e10cSrcweir rItem.lHeight = Min(lWVal, lHVal); 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir else 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir long lWVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Width (); 591*cdf0e10cSrcweir long lHVal = SvxPaperInfo::GetPaperSize((Paper)nPaper).Height(); 592*cdf0e10cSrcweir rItem.lWidth = Max(lWVal, lHVal); 593*cdf0e10cSrcweir rItem.lHeight = Min(lWVal, lHVal); 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir // -------------------------------------------------------------------------- 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir sal_Bool __EXPORT SwEnvFmtPage::FillItemSet(SfxItemSet& rSet) 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir FillItem(GetParent()->aEnvItem); 603*cdf0e10cSrcweir rSet.Put(GetParent()->aEnvItem); 604*cdf0e10cSrcweir return sal_True; 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir // -------------------------------------------------------------------------- 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir void __EXPORT SwEnvFmtPage::Reset(const SfxItemSet& rSet) 611*cdf0e10cSrcweir { 612*cdf0e10cSrcweir const SwEnvItem& rItem = (const SwEnvItem&) rSet.Get(FN_ENVELOP); 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir Paper ePaper = SvxPaperInfo::GetSvxPaper( 615*cdf0e10cSrcweir Size( Min(rItem.lWidth, rItem.lHeight), 616*cdf0e10cSrcweir Max(rItem.lWidth, rItem.lHeight)), MAP_TWIP, sal_True); 617*cdf0e10cSrcweir for (sal_uInt16 i = 0; i < (sal_uInt16) aIDs.Count(); i++) 618*cdf0e10cSrcweir if (aIDs[i] == (sal_uInt16)ePaper) 619*cdf0e10cSrcweir aSizeFormatBox.SelectEntryPos(i); 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir // Die MetricFields 622*cdf0e10cSrcweir SetFldVal(aAddrLeftField, rItem.lAddrFromLeft); 623*cdf0e10cSrcweir SetFldVal(aAddrTopField , rItem.lAddrFromTop ); 624*cdf0e10cSrcweir SetFldVal(aSendLeftField, rItem.lSendFromLeft); 625*cdf0e10cSrcweir SetFldVal(aSendTopField , rItem.lSendFromTop ); 626*cdf0e10cSrcweir SetFldVal(aSizeWidthField , Max(rItem.lWidth, rItem.lHeight)); 627*cdf0e10cSrcweir SetFldVal(aSizeHeightField , Min(rItem.lWidth, rItem.lHeight)); 628*cdf0e10cSrcweir SetMinMax(); 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir DELETEZ(GetParent()->pSenderSet); 631*cdf0e10cSrcweir DELETEZ(GetParent()->pAddresseeSet); 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir 636