1efeef26fSAndrew Rist /************************************************************** 2*1f7882eeSmseidel * 3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5efeef26fSAndrew Rist * distributed with this work for additional information 6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10*1f7882eeSmseidel * 11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1f7882eeSmseidel * 13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14efeef26fSAndrew Rist * software distributed under the License is distributed on an 15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17efeef26fSAndrew Rist * specific language governing permissions and limitations 18efeef26fSAndrew Rist * under the License. 19*1f7882eeSmseidel * 20efeef26fSAndrew Rist *************************************************************/ 21efeef26fSAndrew Rist 22*1f7882eeSmseidel 23*1f7882eeSmseidel 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "cmdid.h" 28cdf0e10cSrcweir #include "hintids.hxx" 29cdf0e10cSrcweir #include <algorithm> 30cdf0e10cSrcweir #include <svl/eitem.hxx> 31cdf0e10cSrcweir #include <editeng/lrspitem.hxx> 32cdf0e10cSrcweir #include <editeng/ulspitem.hxx> 33cdf0e10cSrcweir #include <editeng/sizeitem.hxx> 34cdf0e10cSrcweir #include <svx/pageitem.hxx> 35cdf0e10cSrcweir #include <editeng/brshitem.hxx> 36cdf0e10cSrcweir #include <editeng/frmdiritem.hxx> 37cdf0e10cSrcweir #include <vcl/bitmap.hxx> 38cdf0e10cSrcweir #include <vcl/graph.hxx> 39cdf0e10cSrcweir #include <tgrditem.hxx> 40cdf0e10cSrcweir #include <viewopt.hxx> 41cdf0e10cSrcweir #include "colex.hxx" 42cdf0e10cSrcweir #include "colmgr.hxx" 43cdf0e10cSrcweir 4456b35d86SArmin Le Grand //UUUU 4556b35d86SArmin Le Grand #include <svx/unobrushitemhelper.hxx> 4656b35d86SArmin Le Grand 47cdf0e10cSrcweir /*----------------------------------------------------------------------- 48cdf0e10cSrcweir Beschreibung: Uebernahme der aktualisierten Werte aus dem Set 49cdf0e10cSrcweir -----------------------------------------------------------------------*/ 50cdf0e10cSrcweir void SwPageExample::UpdateExample( const SfxItemSet& rSet ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir const SvxPageItem* pPage = 0; 53cdf0e10cSrcweir SfxItemPool* pPool = rSet.GetPool(); 54cdf0e10cSrcweir sal_uInt16 nWhich = pPool->GetWhich( SID_ATTR_PAGE ); 55cdf0e10cSrcweir 56cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET ) 57cdf0e10cSrcweir { 58cdf0e10cSrcweir // Ausrichtung 59cdf0e10cSrcweir pPage = (const SvxPageItem*)&rSet.Get( nWhich ); 60cdf0e10cSrcweir 61cdf0e10cSrcweir if ( pPage ) 62cdf0e10cSrcweir SetUsage( pPage->GetPageUsage() ); 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir nWhich = pPool->GetWhich( SID_ATTR_PAGE_SIZE ); 66cdf0e10cSrcweir 67cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir // Orientation und Size aus dem PageItem 70cdf0e10cSrcweir const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get( nWhich ); 71cdf0e10cSrcweir SetSize( rSize.GetSize() ); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir nWhich = RES_LR_SPACE; 74cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir // linken und rechten Rand einstellen 77cdf0e10cSrcweir const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get( nWhich ); 78cdf0e10cSrcweir 79cdf0e10cSrcweir SetLeft( rLRSpace.GetLeft() ); 80cdf0e10cSrcweir SetRight( rLRSpace.GetRight() ); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir else 83cdf0e10cSrcweir { 84cdf0e10cSrcweir SetLeft( 0 ); 85cdf0e10cSrcweir SetRight( 0 ); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir nWhich = RES_UL_SPACE; 89cdf0e10cSrcweir 90cdf0e10cSrcweir if ( rSet.GetItemState( nWhich, sal_False ) == SFX_ITEM_SET ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir // oberen und unteren Rand einstellen 93cdf0e10cSrcweir const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)rSet.Get( nWhich ); 94cdf0e10cSrcweir 95cdf0e10cSrcweir SetTop( rULSpace.GetUpper() ); 96cdf0e10cSrcweir SetBottom( rULSpace.GetLower() ); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir else 99cdf0e10cSrcweir { 100cdf0e10cSrcweir SetTop( 0 ); 101cdf0e10cSrcweir SetBottom( 0 ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir 105cdf0e10cSrcweir // Kopfzeilen-Attribute auswerten 106cdf0e10cSrcweir const SfxPoolItem* pItem; 107cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_HEADERSET), 108cdf0e10cSrcweir sal_False, &pItem ) ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir const SfxItemSet& rHeaderSet = ((SvxSetItem*)pItem)->GetItemSet(); 111cdf0e10cSrcweir const SfxBoolItem& rHeaderOn = 112cdf0e10cSrcweir (const SfxBoolItem&)rHeaderSet.Get( pPool->GetWhich( SID_ATTR_PAGE_ON ) ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir if ( rHeaderOn.GetValue() ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir const SvxSizeItem& rSize = 117cdf0e10cSrcweir (const SvxSizeItem&)rHeaderSet.Get(pPool->GetWhich(SID_ATTR_PAGE_SIZE)); 118cdf0e10cSrcweir 119cdf0e10cSrcweir const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rHeaderSet.Get( 120cdf0e10cSrcweir pPool->GetWhich(SID_ATTR_ULSPACE)); 121cdf0e10cSrcweir const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rHeaderSet.Get( 122cdf0e10cSrcweir pPool->GetWhich(SID_ATTR_LRSPACE)); 123cdf0e10cSrcweir 124cdf0e10cSrcweir SetHdHeight( rSize.GetSize().Height() - rUL.GetLower()); 125cdf0e10cSrcweir SetHdDist( rUL.GetLower() ); 126cdf0e10cSrcweir SetHdLeft( rLR.GetLeft() ); 127cdf0e10cSrcweir SetHdRight( rLR.GetRight() ); 128cdf0e10cSrcweir SetHeader( sal_True ); 12956b35d86SArmin Le Grand 13056b35d86SArmin Le Grand if(SFX_ITEM_SET == rHeaderSet.GetItemState(RES_BACKGROUND)) 13156b35d86SArmin Le Grand { 13256b35d86SArmin Le Grand //UUUU create FillAttributes from SvxBrushItem //SetHdColor(rItem.GetColor()); 13356b35d86SArmin Le Grand const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rHeaderSet.Get(RES_BACKGROUND)); 13456b35d86SArmin Le Grand SfxItemSet aTempSet(*rHeaderSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 13556b35d86SArmin Le Grand 13656b35d86SArmin Le Grand setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 13756b35d86SArmin Le Grand setHeaderFillAttributes( 13856b35d86SArmin Le Grand drawinglayer::attribute::SdrAllFillAttributesHelperPtr( 13956b35d86SArmin Le Grand new drawinglayer::attribute::SdrAllFillAttributesHelper( 14056b35d86SArmin Le Grand aTempSet))); 14156b35d86SArmin Le Grand } 14256b35d86SArmin Le Grand 143cdf0e10cSrcweir if ( rHeaderSet.GetItemState( RES_BOX ) == SFX_ITEM_SET ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir const SvxBoxItem& rItem = 146cdf0e10cSrcweir (const SvxBoxItem&)rHeaderSet.Get( RES_BOX ); 147cdf0e10cSrcweir SetHdBorder( rItem ); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir } 150cdf0e10cSrcweir else 151cdf0e10cSrcweir SetHeader( sal_False ); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_FOOTERSET), 155cdf0e10cSrcweir sal_False, &pItem ) ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir const SfxItemSet& rFooterSet = ((SvxSetItem*)pItem)->GetItemSet(); 158cdf0e10cSrcweir const SfxBoolItem& rFooterOn = 159cdf0e10cSrcweir (const SfxBoolItem&)rFooterSet.Get( SID_ATTR_PAGE_ON ); 160cdf0e10cSrcweir 161cdf0e10cSrcweir if ( rFooterOn.GetValue() ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir const SvxSizeItem& rSize = 164cdf0e10cSrcweir (const SvxSizeItem&)rFooterSet.Get( pPool->GetWhich( SID_ATTR_PAGE_SIZE ) ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)rFooterSet.Get( 167cdf0e10cSrcweir pPool->GetWhich( SID_ATTR_ULSPACE ) ); 168cdf0e10cSrcweir const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)rFooterSet.Get( 169cdf0e10cSrcweir pPool->GetWhich( SID_ATTR_LRSPACE ) ); 170cdf0e10cSrcweir 171cdf0e10cSrcweir SetFtHeight( rSize.GetSize().Height() - rUL.GetUpper()); 172cdf0e10cSrcweir SetFtDist( rUL.GetUpper() ); 173cdf0e10cSrcweir SetFtLeft( rLR.GetLeft() ); 174cdf0e10cSrcweir SetFtRight( rLR.GetRight() ); 175cdf0e10cSrcweir SetFooter( sal_True ); 17656b35d86SArmin Le Grand 177cdf0e10cSrcweir if( rFooterSet.GetItemState( RES_BACKGROUND ) == SFX_ITEM_SET ) 17856b35d86SArmin Le Grand { 17956b35d86SArmin Le Grand //UUUU create FillAttributes from SvxBrushItem //SetFtColor(rItem.GetColor()); 18056b35d86SArmin Le Grand const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rFooterSet.Get(RES_BACKGROUND)); 18156b35d86SArmin Le Grand SfxItemSet aTempSet(*rFooterSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 18256b35d86SArmin Le Grand 18356b35d86SArmin Le Grand setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 18456b35d86SArmin Le Grand setFooterFillAttributes( 18556b35d86SArmin Le Grand drawinglayer::attribute::SdrAllFillAttributesHelperPtr( 18656b35d86SArmin Le Grand new drawinglayer::attribute::SdrAllFillAttributesHelper( 18756b35d86SArmin Le Grand aTempSet))); 18856b35d86SArmin Le Grand } 18956b35d86SArmin Le Grand 190cdf0e10cSrcweir if( rFooterSet.GetItemState( RES_BOX ) == SFX_ITEM_SET ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir const SvxBoxItem& rItem = 193cdf0e10cSrcweir (const SvxBoxItem&)rFooterSet.Get( RES_BOX ); 194cdf0e10cSrcweir SetFtBorder( rItem ); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir } 197cdf0e10cSrcweir else 198cdf0e10cSrcweir SetFooter( sal_False ); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 20156b35d86SArmin Le Grand if(SFX_ITEM_SET == rSet.GetItemState(RES_BACKGROUND, sal_False, &pItem)) 20256b35d86SArmin Le Grand { 20356b35d86SArmin Le Grand //UUUU create FillAttributes from SvxBrushItem 20456b35d86SArmin Le Grand const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(*pItem); 20556b35d86SArmin Le Grand SfxItemSet aTempSet(*rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 20656b35d86SArmin Le Grand 20756b35d86SArmin Le Grand setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); 20856b35d86SArmin Le Grand setPageFillAttributes( 20956b35d86SArmin Le Grand drawinglayer::attribute::SdrAllFillAttributesHelperPtr( 21056b35d86SArmin Le Grand new drawinglayer::attribute::SdrAllFillAttributesHelper( 21156b35d86SArmin Le Grand aTempSet))); 21256b35d86SArmin Le Grand } 213cdf0e10cSrcweir 214cdf0e10cSrcweir Invalidate(); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir /*----------------------------------------------------------------------- 217cdf0e10cSrcweir Beschreibung: 218cdf0e10cSrcweir -----------------------------------------------------------------------*/ 219cdf0e10cSrcweir 220cdf0e10cSrcweir 221cdf0e10cSrcweir void SwColExample::DrawPage( const Point& rOrg, 222cdf0e10cSrcweir const sal_Bool bSecond, 223cdf0e10cSrcweir const sal_Bool bEnabled ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir SwPageExample::DrawPage( rOrg, bSecond, bEnabled ); 226cdf0e10cSrcweir sal_uInt16 nColumnCount; 227cdf0e10cSrcweir if( pColMgr && 0 != (nColumnCount = pColMgr->GetCount())) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir long nL = GetLeft(); 230cdf0e10cSrcweir long nR = GetRight(); 231cdf0e10cSrcweir 232cdf0e10cSrcweir if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir // fuer gespiegelt drehen 235cdf0e10cSrcweir nL = GetRight(); 236cdf0e10cSrcweir nR = GetLeft(); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir SetFillColor( Color( COL_LIGHTGRAY ) ); 240cdf0e10cSrcweir Rectangle aRect; 241cdf0e10cSrcweir aRect.Right() = rOrg.X() + GetSize().Width() - nR; 242cdf0e10cSrcweir aRect.Left() = rOrg.X() + nL; 243cdf0e10cSrcweir aRect.Top() = rOrg.Y() + GetTop() 244cdf0e10cSrcweir + GetHdHeight() + GetHdDist(); 245cdf0e10cSrcweir aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom() 246cdf0e10cSrcweir - GetFtHeight() - GetFtDist(); 247cdf0e10cSrcweir DrawRect(aRect); 248cdf0e10cSrcweir 24956b35d86SArmin Le Grand //UUUU 25056b35d86SArmin Le Grand const Rectangle aDefineRect(aRect); 25156b35d86SArmin Le Grand 25256b35d86SArmin Le Grand //UUUU 25356b35d86SArmin Le Grand const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes = getPageFillAttributes(); 25456b35d86SArmin Le Grand 25556b35d86SArmin Le Grand if(!rFillAttributes.get() || !rFillAttributes->isUsed()) 256cdf0e10cSrcweir { 25756b35d86SArmin Le Grand //UUUU If there is no fill, use fallback color 258cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 259cdf0e10cSrcweir const Color& rFieldColor = rStyleSettings.GetFieldColor(); 26056b35d86SArmin Le Grand 26156b35d86SArmin Le Grand setPageFillAttributes( 26256b35d86SArmin Le Grand drawinglayer::attribute::SdrAllFillAttributesHelperPtr( 26356b35d86SArmin Le Grand new drawinglayer::attribute::SdrAllFillAttributesHelper( 26456b35d86SArmin Le Grand rFieldColor))); 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir // #97495# make sure that the automatic column widht's are always equal 268cdf0e10cSrcweir sal_Bool bAutoWidth = pColMgr->IsAutoWidth(); 269cdf0e10cSrcweir sal_Int32 nAutoColWidth = 0; 270cdf0e10cSrcweir if(bAutoWidth) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir sal_Int32 nColumnWidthSum = 0; 273cdf0e10cSrcweir sal_uInt16 i; 274cdf0e10cSrcweir for(i = 0; i < nColumnCount; ++i) 275cdf0e10cSrcweir nColumnWidthSum += pColMgr->GetColWidth( i ); 276cdf0e10cSrcweir nAutoColWidth = nColumnWidthSum / nColumnCount; 277cdf0e10cSrcweir } 278cdf0e10cSrcweir 279cdf0e10cSrcweir sal_uInt16 i; 280cdf0e10cSrcweir for( i = 0; i < nColumnCount; i++) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir if(!bAutoWidth) 283cdf0e10cSrcweir nAutoColWidth = pColMgr->GetColWidth( i ); 284cdf0e10cSrcweir aRect.Right() = aRect.Left() + nAutoColWidth; 285*1f7882eeSmseidel 28656b35d86SArmin Le Grand //UUUU use primitive draw command 28756b35d86SArmin Le Grand drawFillAttributes(getPageFillAttributes(), aRect, aDefineRect); 28856b35d86SArmin Le Grand 289cdf0e10cSrcweir if(i < nColumnCount - 1) 290cdf0e10cSrcweir aRect.Left() = aRect.Right() + pColMgr->GetGutterWidth(i); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir if(pColMgr->HasLine()) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir Point aUp( rOrg.X() + nL, rOrg.Y() + GetTop() ); 295cdf0e10cSrcweir Point aDown( rOrg.X() + nL, rOrg.Y() + GetSize().Height() 296cdf0e10cSrcweir - GetBottom() - GetFtHeight() - GetFtDist() ); 297cdf0e10cSrcweir 298cdf0e10cSrcweir if( pColMgr->GetLineHeightPercent() != 100 ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir long nLength = aDown.Y() - aUp.Y(); 301cdf0e10cSrcweir nLength -= nLength * pColMgr->GetLineHeightPercent() / 100; 302cdf0e10cSrcweir switch(pColMgr->GetAdjust()) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir case COLADJ_BOTTOM: aUp.Y() += nLength; break; 305cdf0e10cSrcweir case COLADJ_TOP: aDown.Y() -= nLength; break; 306cdf0e10cSrcweir case COLADJ_CENTER: 307cdf0e10cSrcweir aUp.Y() += nLength / 2; 308cdf0e10cSrcweir aDown.Y() -= nLength / 2; 309cdf0e10cSrcweir break; 310cdf0e10cSrcweir default:; // prevent warning 311cdf0e10cSrcweir } 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir int nDist; 315*1f7882eeSmseidel for( i = 0; i < nColumnCount - 1; i++) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir int nGutter = pColMgr->GetGutterWidth(i); 318cdf0e10cSrcweir nDist = pColMgr->GetColWidth( i ) + nGutter; 319cdf0e10cSrcweir nDist -= (i == 0) ? 320cdf0e10cSrcweir nGutter/2 : 321cdf0e10cSrcweir 0; 322cdf0e10cSrcweir aUp.X() += nDist; 323cdf0e10cSrcweir aDown.X() += nDist; 324cdf0e10cSrcweir DrawLine( aUp, aDown ); 325cdf0e10cSrcweir 326cdf0e10cSrcweir } 327cdf0e10cSrcweir } 328cdf0e10cSrcweir } 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir /*-----------------25.10.96 09.15------------------- 332cdf0e10cSrcweir 333cdf0e10cSrcweir --------------------------------------------------*/ 334cdf0e10cSrcweir 335cdf0e10cSrcweir 336cdf0e10cSrcweir SwColumnOnlyExample::SwColumnOnlyExample( Window* pParent, const ResId& rResId) : 337cdf0e10cSrcweir Window(pParent, rResId), 338cdf0e10cSrcweir m_aFrmSize(1,1) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir SetMapMode( MapMode( MAP_TWIP ) ); 341cdf0e10cSrcweir m_aWinSize = GetOutputSizePixel(); 342cdf0e10cSrcweir m_aWinSize.Height() -= 4; 343cdf0e10cSrcweir m_aWinSize.Width() -= 4; 344cdf0e10cSrcweir 345cdf0e10cSrcweir m_aWinSize = PixelToLogic( m_aWinSize ); 346cdf0e10cSrcweir 347cdf0e10cSrcweir SetBorderStyle( WINDOW_BORDER_MONO ); 348cdf0e10cSrcweir 349*1f7882eeSmseidel m_aFrmSize = SvxPaperInfo::GetPaperSize(PAPER_A4); // DIN A4 350cdf0e10cSrcweir ::FitToActualSize(m_aCols, (sal_uInt16)m_aFrmSize.Width()); 351cdf0e10cSrcweir 352cdf0e10cSrcweir long nHeight = m_aFrmSize.Height(); 353cdf0e10cSrcweir Fraction aScale( m_aWinSize.Height(), nHeight ); 354cdf0e10cSrcweir MapMode aMapMode( GetMapMode() ); 355cdf0e10cSrcweir aMapMode.SetScaleX( aScale ); 356cdf0e10cSrcweir aMapMode.SetScaleY( aScale ); 357cdf0e10cSrcweir SetMapMode( aMapMode ); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir 360cdf0e10cSrcweir /*-----------------25.10.96 09.16------------------- 361cdf0e10cSrcweir 362cdf0e10cSrcweir --------------------------------------------------*/ 363cdf0e10cSrcweir 364cdf0e10cSrcweir 365cdf0e10cSrcweir void SwColumnOnlyExample::Paint( const Rectangle& /*rRect*/ ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 368cdf0e10cSrcweir const Color& rFieldColor = rStyleSettings.GetFieldColor(); 369cdf0e10cSrcweir const Color& rDlgColor = rStyleSettings.GetDialogColor(); 370cdf0e10cSrcweir const Color& rFieldTextColor = SwViewOption::GetFontColor(); 371cdf0e10cSrcweir Color aGrayColor(COL_LIGHTGRAY); 372cdf0e10cSrcweir if(rFieldColor == aGrayColor) 373cdf0e10cSrcweir aGrayColor.Invert(); 374cdf0e10cSrcweir 375cdf0e10cSrcweir Size aLogSize(PixelToLogic(GetOutputSizePixel())); 376cdf0e10cSrcweir Rectangle aCompleteRect(Point(0,0), aLogSize); 377cdf0e10cSrcweir SetLineColor(rDlgColor); 378cdf0e10cSrcweir SetFillColor(rDlgColor); 379cdf0e10cSrcweir DrawRect(aCompleteRect); 380cdf0e10cSrcweir 381cdf0e10cSrcweir SetLineColor( rFieldTextColor ); 382cdf0e10cSrcweir Point aTL( (aLogSize.Width() - m_aFrmSize.Width()) / 2, 383cdf0e10cSrcweir (aLogSize.Height() - m_aFrmSize.Height()) / 2); 384cdf0e10cSrcweir Rectangle aRect(aTL, m_aFrmSize); 385cdf0e10cSrcweir 386cdf0e10cSrcweir //draw a shadow rectangle 387*1f7882eeSmseidel // SetFillColor( Color(COL_GRAY) ); 388*1f7882eeSmseidel // Rectangle aShadowRect(aRect); 389*1f7882eeSmseidel // aShadowRect.Move(aTL.Y(), aTL.Y()); 390*1f7882eeSmseidel // DrawRect(aShadowRect); 391cdf0e10cSrcweir 392cdf0e10cSrcweir SetFillColor( rFieldColor ); 393cdf0e10cSrcweir DrawRect(aRect); 394cdf0e10cSrcweir 395cdf0e10cSrcweir SetFillColor( aGrayColor ); 396cdf0e10cSrcweir 397cdf0e10cSrcweir //Spaltentrenner? 398cdf0e10cSrcweir long nLength = aLogSize.Height() - 2 * aTL.Y(); 399cdf0e10cSrcweir Point aUp( aTL ); 400cdf0e10cSrcweir Point aDown( aTL.X(), nLength ); 401cdf0e10cSrcweir sal_Bool bLines = sal_False; 402cdf0e10cSrcweir if(m_aCols.GetLineAdj() != COLADJ_NONE) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir bLines = sal_True; 405cdf0e10cSrcweir 406cdf0e10cSrcweir sal_uInt16 nPercent = m_aCols.GetLineHeight(); 407cdf0e10cSrcweir if( nPercent != 100 ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir nLength -= nLength * nPercent / 100; 410cdf0e10cSrcweir switch(m_aCols.GetLineAdj()) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir case COLADJ_BOTTOM: aUp.Y() += nLength; break; 413cdf0e10cSrcweir case COLADJ_TOP: aDown.Y() -= nLength; break; 414cdf0e10cSrcweir case COLADJ_CENTER: 415cdf0e10cSrcweir aUp.Y() += nLength / 2; 416cdf0e10cSrcweir aDown.Y() -= nLength / 2; 417cdf0e10cSrcweir break; 418cdf0e10cSrcweir default:; //prevent warning 419cdf0e10cSrcweir } 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir } 423cdf0e10cSrcweir const SwColumns& rCols = m_aCols.GetColumns(); 424cdf0e10cSrcweir sal_uInt16 nColCount = rCols.Count(); 425cdf0e10cSrcweir if( nColCount ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir DrawRect(aRect); 428cdf0e10cSrcweir SetFillColor( rFieldColor ); 429cdf0e10cSrcweir Rectangle aFrmRect(aTL, m_aFrmSize); 430cdf0e10cSrcweir long nSum = aTL.X(); 431cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nColCount; i++) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir SwColumn* pCol = rCols[i]; 434cdf0e10cSrcweir aFrmRect.Left() = nSum + pCol->GetLeft();//nSum + pCol->GetLeft() + aTL.X(); 435cdf0e10cSrcweir nSum += pCol->GetWishWidth(); 436cdf0e10cSrcweir aFrmRect.Right() = nSum - pCol->GetRight(); 437cdf0e10cSrcweir DrawRect(aFrmRect); 438cdf0e10cSrcweir } 439cdf0e10cSrcweir if(bLines ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir nSum = aTL.X(); 442cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nColCount - 1; i++) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir nSum += rCols[i]->GetWishWidth(); 445cdf0e10cSrcweir aUp.X() = nSum; 446cdf0e10cSrcweir aDown.X() = nSum; 447cdf0e10cSrcweir DrawLine(aUp, aDown); 448cdf0e10cSrcweir } 449cdf0e10cSrcweir } 450cdf0e10cSrcweir } 451cdf0e10cSrcweir } 452cdf0e10cSrcweir 453cdf0e10cSrcweir /*-----------------25.10.96 12.05------------------- 454cdf0e10cSrcweir 455cdf0e10cSrcweir --------------------------------------------------*/ 456cdf0e10cSrcweir 457cdf0e10cSrcweir 458cdf0e10cSrcweir void SwColumnOnlyExample::SetColumns(const SwFmtCol& rCol) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir m_aCols = rCol; 461cdf0e10cSrcweir sal_uInt16 nWishSum = m_aCols.GetWishWidth(); 462cdf0e10cSrcweir long nFrmWidth = m_aFrmSize.Width(); 463cdf0e10cSrcweir SwColumns& rCols = m_aCols.GetColumns(); 464cdf0e10cSrcweir sal_uInt16 nColCount = rCols.Count(); 465cdf0e10cSrcweir 466cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nColCount; i++) 467cdf0e10cSrcweir { 468cdf0e10cSrcweir SwColumn* pCol = rCols[i]; 469cdf0e10cSrcweir long nWish = pCol->GetWishWidth(); 470cdf0e10cSrcweir nWish *= nFrmWidth; 471cdf0e10cSrcweir nWish /= nWishSum; 472cdf0e10cSrcweir pCol->SetWishWidth((sal_uInt16)nWish); 473cdf0e10cSrcweir long nLeft = pCol->GetLeft(); 474cdf0e10cSrcweir nLeft *= nFrmWidth; 475cdf0e10cSrcweir nLeft /= nWishSum; 476cdf0e10cSrcweir pCol->SetLeft((sal_uInt16)nLeft); 477cdf0e10cSrcweir long nRight = pCol->GetRight(); 478cdf0e10cSrcweir nRight *= nFrmWidth; 479cdf0e10cSrcweir nRight /= nWishSum; 480cdf0e10cSrcweir pCol->SetRight((sal_uInt16)nRight); 481cdf0e10cSrcweir } 482cdf0e10cSrcweir // #97495# make sure that the automatic column width's are always equal 483cdf0e10cSrcweir if(nColCount && m_aCols.IsOrtho()) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir sal_Int32 nColumnWidthSum = 0; 486cdf0e10cSrcweir sal_uInt16 i; 487cdf0e10cSrcweir for(i = 0; i < nColCount; ++i) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir SwColumn* pCol = rCols[i]; 490cdf0e10cSrcweir nColumnWidthSum += pCol->GetWishWidth(); 491cdf0e10cSrcweir nColumnWidthSum -= (pCol->GetRight() + pCol->GetLeft()); 492cdf0e10cSrcweir } 493cdf0e10cSrcweir nColumnWidthSum /= nColCount; 494cdf0e10cSrcweir for(i = 0; i < nColCount; ++i) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir SwColumn* pCol = rCols[i]; 497cdf0e10cSrcweir pCol->SetWishWidth( static_cast< sal_uInt16 >(nColumnWidthSum + pCol->GetRight() + pCol->GetLeft())); 498cdf0e10cSrcweir } 499cdf0e10cSrcweir } 500cdf0e10cSrcweir } 501cdf0e10cSrcweir /* -----------------------------08.02.2002 11:44------------------------------ 502cdf0e10cSrcweir 503cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 504cdf0e10cSrcweir SwPageGridExample::~SwPageGridExample() 505cdf0e10cSrcweir { 506cdf0e10cSrcweir delete pGridItem; 507cdf0e10cSrcweir } 508cdf0e10cSrcweir /* -----------------------------08.02.2002 11:48------------------------------ 509cdf0e10cSrcweir 510cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 511cdf0e10cSrcweir #define MAX_ROWS 10 512cdf0e10cSrcweir #define MAX_LINES 15 513cdf0e10cSrcweir void SwPageGridExample::DrawPage( const Point& rOrg, 514cdf0e10cSrcweir const sal_Bool bSecond, 515cdf0e10cSrcweir const sal_Bool bEnabled ) 516cdf0e10cSrcweir { 517cdf0e10cSrcweir SwPageExample::DrawPage(rOrg, bSecond, bEnabled); 518cdf0e10cSrcweir if(pGridItem && pGridItem->GetGridType()) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir //paint the grid now 521cdf0e10cSrcweir Color aLineColor = pGridItem->GetColor(); 522cdf0e10cSrcweir if(aLineColor.GetColor() == COL_AUTO) 523cdf0e10cSrcweir { 524cdf0e10cSrcweir aLineColor = GetFillColor(); 525cdf0e10cSrcweir aLineColor.Invert(); 526cdf0e10cSrcweir } 527cdf0e10cSrcweir SetLineColor(aLineColor); 528cdf0e10cSrcweir long nL = GetLeft(); 529cdf0e10cSrcweir long nR = GetRight(); 530cdf0e10cSrcweir 531cdf0e10cSrcweir if ( GetUsage() == SVX_PAGE_MIRROR && !bSecond ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir // fuer gespiegelt drehen 534cdf0e10cSrcweir nL = GetRight(); 535cdf0e10cSrcweir nR = GetLeft(); 536cdf0e10cSrcweir } 537cdf0e10cSrcweir 538cdf0e10cSrcweir Rectangle aRect; 539cdf0e10cSrcweir aRect.Right() = rOrg.X() + GetSize().Width() - nR; 540cdf0e10cSrcweir aRect.Left() = rOrg.X() + nL; 541cdf0e10cSrcweir aRect.Top() = rOrg.Y() + GetTop() 542cdf0e10cSrcweir + GetHdHeight() + GetHdDist(); 543cdf0e10cSrcweir aRect.Bottom()= rOrg.Y() + GetSize().Height() - GetBottom() 544cdf0e10cSrcweir - GetFtHeight() - GetFtDist(); 545cdf0e10cSrcweir 546cdf0e10cSrcweir //increase the values to get a 'viewable' preview 547cdf0e10cSrcweir sal_Int32 nBaseHeight = pGridItem->GetBaseHeight() * 3; 548cdf0e10cSrcweir sal_Int32 nRubyHeight = pGridItem->GetRubyHeight() * 3; 549cdf0e10cSrcweir 550cdf0e10cSrcweir //detect height of rectangles 551cdf0e10cSrcweir Rectangle aRubyRect(aRect.TopLeft(), 552cdf0e10cSrcweir m_bVertical ? 553cdf0e10cSrcweir Size(nRubyHeight, aRect.GetHeight()) : 554cdf0e10cSrcweir Size(aRect.GetWidth(), nRubyHeight)); 555cdf0e10cSrcweir Rectangle aCharRect(aRect.TopLeft(), 556cdf0e10cSrcweir m_bVertical ? 557cdf0e10cSrcweir Size(nBaseHeight, aRect.GetHeight()) : 558cdf0e10cSrcweir Size(aRect.GetWidth(), nBaseHeight)); 559cdf0e10cSrcweir 560cdf0e10cSrcweir sal_Int32 nLineHeight = nBaseHeight + nRubyHeight; 561cdf0e10cSrcweir 562cdf0e10cSrcweir //detect count of rectangles 563cdf0e10cSrcweir sal_Int32 nLines = (m_bVertical ? aRect.GetWidth(): aRect.GetHeight()) / nLineHeight; 564cdf0e10cSrcweir if(nLines > pGridItem->GetLines()) 565cdf0e10cSrcweir nLines = pGridItem->GetLines(); 566cdf0e10cSrcweir 567cdf0e10cSrcweir // determine start position 568cdf0e10cSrcweir if(m_bVertical) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir sal_Int16 nXStart = static_cast< sal_Int16 >(aRect.GetWidth() / 2 - nLineHeight * nLines /2); 571cdf0e10cSrcweir aRubyRect.Move(nXStart, 0); 572cdf0e10cSrcweir aCharRect.Move(nXStart, 0); 573cdf0e10cSrcweir } 574cdf0e10cSrcweir else 575cdf0e10cSrcweir { 576cdf0e10cSrcweir sal_Int16 nYStart = static_cast< sal_Int16 >(aRect.GetHeight() / 2 - nLineHeight * nLines /2); 577cdf0e10cSrcweir aRubyRect.Move(0, nYStart); 578cdf0e10cSrcweir aCharRect.Move(0, nYStart); 579cdf0e10cSrcweir } 580cdf0e10cSrcweir 581cdf0e10cSrcweir if(pGridItem->IsRubyTextBelow()) 582cdf0e10cSrcweir m_bVertical ? aRubyRect.Move(nBaseHeight, 0) : aRubyRect.Move(0, nBaseHeight); 583cdf0e10cSrcweir else 584cdf0e10cSrcweir m_bVertical ? aCharRect.Move(nRubyHeight, 0) : aCharRect.Move(0, nRubyHeight); 585cdf0e10cSrcweir 586cdf0e10cSrcweir //vertical lines 587cdf0e10cSrcweir sal_Bool bBothLines = pGridItem->GetGridType() == GRID_LINES_CHARS; 588cdf0e10cSrcweir SetFillColor( Color( COL_TRANSPARENT ) ); 589cdf0e10cSrcweir sal_Int32 nXMove = m_bVertical ? nLineHeight : 0; 590cdf0e10cSrcweir sal_Int32 nYMove = m_bVertical ? 0 : nLineHeight; 591cdf0e10cSrcweir for(sal_Int32 nLine = 0; nLine < nLines; nLine++) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir DrawRect(aRubyRect); 594cdf0e10cSrcweir DrawRect(aCharRect); 595cdf0e10cSrcweir if(bBothLines) 596cdf0e10cSrcweir { 597cdf0e10cSrcweir Point aStart = aCharRect.TopLeft(); 598cdf0e10cSrcweir Point aEnd = m_bVertical ? aCharRect.TopRight() : aCharRect.BottomLeft(); 599cdf0e10cSrcweir while(m_bVertical ? aStart.Y() < aRect.Bottom(): aStart.X() < aRect.Right()) 600cdf0e10cSrcweir { 601cdf0e10cSrcweir DrawLine(aStart, aEnd); 602cdf0e10cSrcweir if(m_bVertical) 603cdf0e10cSrcweir aStart.Y() = aEnd.Y() += nBaseHeight; 604cdf0e10cSrcweir else 605cdf0e10cSrcweir aStart.X() = aEnd.X() += nBaseHeight; 606cdf0e10cSrcweir } 607cdf0e10cSrcweir } 608cdf0e10cSrcweir aRubyRect.Move(nXMove, nYMove); 609cdf0e10cSrcweir aCharRect.Move(nXMove, nYMove); 610cdf0e10cSrcweir } 611cdf0e10cSrcweir } 612cdf0e10cSrcweir } 613cdf0e10cSrcweir /* -----------------------------08.02.2002 11:48------------------------------ 614cdf0e10cSrcweir 615cdf0e10cSrcweir ---------------------------------------------------------------------------*/ 616cdf0e10cSrcweir void SwPageGridExample::UpdateExample( const SfxItemSet& rSet ) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir DELETEZ(pGridItem); 619cdf0e10cSrcweir //get the grid information 620cdf0e10cSrcweir if(SFX_ITEM_AVAILABLE <= rSet.GetItemState(RES_TEXTGRID, sal_True)) 621cdf0e10cSrcweir pGridItem = (SwTextGridItem*)((const SwTextGridItem&)rSet.Get(RES_TEXTGRID)).Clone(); 622cdf0e10cSrcweir if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR, sal_True )) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir const SvxFrameDirectionItem& rDirItem = 625cdf0e10cSrcweir (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR); 626cdf0e10cSrcweir m_bVertical = rDirItem.GetValue() == FRMDIR_VERT_TOP_RIGHT|| 627cdf0e10cSrcweir rDirItem.GetValue() == FRMDIR_VERT_TOP_LEFT; 628cdf0e10cSrcweir } 629cdf0e10cSrcweir SwPageExample::UpdateExample(rSet); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir 632*1f7882eeSmseidel /* vim: set noet sw=4 ts=4: */ 633