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 #include "precompiled_reportdesign.hxx" 28*cdf0e10cSrcweir #include "SectionView.hxx" 29*cdf0e10cSrcweir #include "DesignView.hxx" 30*cdf0e10cSrcweir #include <RptPage.hxx> 31*cdf0e10cSrcweir #include <RptObject.hxx> 32*cdf0e10cSrcweir #include <RptDef.hxx> 33*cdf0e10cSrcweir #include <svx/svxids.hrc> 34*cdf0e10cSrcweir #include <svx/svddrgmt.hxx> 35*cdf0e10cSrcweir #include <vcl/scrbar.hxx> 36*cdf0e10cSrcweir #include "ReportSection.hxx" 37*cdf0e10cSrcweir #include "ReportWindow.hxx" 38*cdf0e10cSrcweir #include "uistrings.hrc" 39*cdf0e10cSrcweir #include <tools/debug.hxx> 40*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir namespace rptui 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir using namespace ::com::sun::star; 45*cdf0e10cSrcweir TYPEINIT1( OSectionView, SdrView ); 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir //---------------------------------------------------------------------------- 48*cdf0e10cSrcweir DBG_NAME( rpt_OSectionView ) 49*cdf0e10cSrcweir OSectionView::OSectionView( SdrModel* pModel, OReportSection* _pSectionWindow, OReportWindow* pEditor ) 50*cdf0e10cSrcweir :SdrView( pModel, _pSectionWindow ) 51*cdf0e10cSrcweir ,m_pReportWindow( pEditor ) 52*cdf0e10cSrcweir ,m_pSectionWindow(_pSectionWindow) 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir DBG_CTOR( rpt_OSectionView,NULL); 55*cdf0e10cSrcweir // SetPagePaintingAllowed(false); 56*cdf0e10cSrcweir SetBufferedOutputAllowed(true); 57*cdf0e10cSrcweir SetBufferedOverlayAllowed(true); 58*cdf0e10cSrcweir SetPageBorderVisible(false); 59*cdf0e10cSrcweir SetBordVisible(); 60*cdf0e10cSrcweir SetQuickTextEditMode(sal_False); 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir //---------------------------------------------------------------------------- 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir OSectionView::~OSectionView() 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir DBG_DTOR( rpt_OSectionView,NULL); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir //---------------------------------------------------------------------------- 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir void OSectionView::MarkListHasChanged() 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir DBG_CHKTHIS( rpt_OSectionView,NULL); 75*cdf0e10cSrcweir SdrView::MarkListHasChanged(); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir if ( m_pReportWindow && m_pSectionWindow && !m_pSectionWindow->getPage()->getSpecialMode() ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir //m_pReportWindow->unmarkAllObjects(this); // WHY 80*cdf0e10cSrcweir DlgEdHint aHint( RPTUI_HINT_SELECTIONCHANGED ); 81*cdf0e10cSrcweir m_pReportWindow->getReportView()->Broadcast( aHint ); 82*cdf0e10cSrcweir m_pReportWindow->getReportView()->UpdatePropertyBrowserDelayed(*this); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir //---------------------------------------------------------------------------- 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir void OSectionView::MakeVisible( const Rectangle& rRect, Window& rWin ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir DBG_CHKTHIS( rpt_OSectionView,NULL); 91*cdf0e10cSrcweir // visible area 92*cdf0e10cSrcweir MapMode aMap( rWin.GetMapMode() ); 93*cdf0e10cSrcweir const Point aOrg( aMap.GetOrigin() ); 94*cdf0e10cSrcweir const Size aVisSize( rWin.GetOutputSize() ); 95*cdf0e10cSrcweir const Rectangle aVisRect( Point(-aOrg.X(),-aOrg.Y()), aVisSize ); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir // check, if rectangle is inside visible area 98*cdf0e10cSrcweir if ( !aVisRect.IsInside( rRect ) ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir // calculate scroll distance; the rectangle must be inside the visible area 101*cdf0e10cSrcweir sal_Int32 nScrollX = 0, nScrollY = 0; 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir const sal_Int32 nVisLeft = aVisRect.Left(); 104*cdf0e10cSrcweir const sal_Int32 nVisRight = aVisRect.Right(); 105*cdf0e10cSrcweir const sal_Int32 nVisTop = aVisRect.Top(); 106*cdf0e10cSrcweir const sal_Int32 nVisBottom = aVisRect.Bottom(); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir // don't scroll beyond the page size 109*cdf0e10cSrcweir Size aPageSize = m_pSectionWindow->getPage()->GetSize(); 110*cdf0e10cSrcweir const sal_Int32 nPageWidth = aPageSize.Width(); 111*cdf0e10cSrcweir const sal_Int32 nPageHeight = aPageSize.Height(); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir if ( nVisRight + nScrollX > nPageWidth ) 114*cdf0e10cSrcweir nScrollX = nPageWidth - nVisRight; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir if ( nVisLeft + nScrollX < 0 ) 117*cdf0e10cSrcweir nScrollX = -nVisLeft; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir if ( nVisBottom + nScrollY > nPageHeight ) 120*cdf0e10cSrcweir nScrollY = nPageHeight - nVisBottom; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir if ( nVisTop + nScrollY < 0 ) 123*cdf0e10cSrcweir nScrollY = -nVisTop; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // scroll window 126*cdf0e10cSrcweir rWin.Update(); 127*cdf0e10cSrcweir rWin.Scroll( -nScrollX, -nScrollY ); 128*cdf0e10cSrcweir aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) ); 129*cdf0e10cSrcweir rWin.SetMapMode( aMap ); 130*cdf0e10cSrcweir rWin.Update(); 131*cdf0e10cSrcweir rWin.Invalidate(); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir if ( m_pReportWindow ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir const DlgEdHint aHint( RPTUI_HINT_WINDOWSCROLLED ); 136*cdf0e10cSrcweir m_pReportWindow->getReportView()->Broadcast( aHint ); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir else 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir rWin.Invalidate(INVALIDATE_NOERASE); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir //------------------------------------------------------------------------------ 145*cdf0e10cSrcweir void OSectionView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir DBG_CHKTHIS( rpt_OSectionView,NULL); 148*cdf0e10cSrcweir SdrView::Notify(rBC,rHint); 149*cdf0e10cSrcweir if ( rHint.ISA(SdrHint) ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir const SdrObject* pObj = ((SdrHint&)rHint).GetObject(); 152*cdf0e10cSrcweir const SdrHintKind eKind = ((SdrHint&)rHint).GetKind(); 153*cdf0e10cSrcweir // check for change of selected object 154*cdf0e10cSrcweir if(HINT_OBJCHG == eKind && pObj && IsObjMarked(const_cast<SdrObject*>(pObj))) 155*cdf0e10cSrcweir AdjustMarkHdl(); 156*cdf0e10cSrcweir else if ( eKind == HINT_OBJREMOVED ) 157*cdf0e10cSrcweir ObjectRemovedInAliveMode(pObj); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir //------------------------------------------------------------------------------ 162*cdf0e10cSrcweir void OSectionView::ObjectRemovedInAliveMode( const SdrObject* _pObject ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir DBG_CHKTHIS( rpt_OSectionView,NULL); 165*cdf0e10cSrcweir const SdrMarkList& rMarkedList = GetMarkedObjectList(); 166*cdf0e10cSrcweir const sal_uLong nMark = rMarkedList.GetMarkCount(); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir for( sal_uLong i = 0; i < nMark; i++ ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir SdrObject* pSdrObj = rMarkedList.GetMark(i)->GetMarkedSdrObj(); 171*cdf0e10cSrcweir if (_pObject == pSdrObj) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir SdrPageView* pPgView = GetSdrPageView(); 174*cdf0e10cSrcweir BrkAction(); 175*cdf0e10cSrcweir MarkObj( pSdrObj, pPgView, sal_True ); 176*cdf0e10cSrcweir break; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 182*cdf0e10cSrcweir void OSectionView::SetMarkedToLayer( SdrLayerID _nLayerNo ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir if (AreObjectsMarked()) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir // #i11702# use SdrUndoObjectLayerChange for undo 187*cdf0e10cSrcweir // STR_UNDO_SELATTR is "Attributes" - should use a different text later 188*cdf0e10cSrcweir BegUndo( ); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir const SdrMarkList& rMark = GetMarkedObjectList(); 191*cdf0e10cSrcweir sal_uLong nCount = rMark.GetMarkCount(); 192*cdf0e10cSrcweir for (sal_uLong i=0; i<nCount; i++) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); 195*cdf0e10cSrcweir if ( pObj->ISA(OCustomShape) ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), _nLayerNo) ); 198*cdf0e10cSrcweir pObj->SetLayer( _nLayerNo ); 199*cdf0e10cSrcweir OObjectBase* pBaseObj = dynamic_cast<OObjectBase*>(pObj); 200*cdf0e10cSrcweir try 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir pBaseObj->getReportComponent()->setPropertyValue(PROPERTY_OPAQUE,uno::makeAny(_nLayerNo == RPT_LAYER_FRONT)); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir catch(const uno::Exception&) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir EndUndo(); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir // #84073# check mark list now instead of later in a timer 214*cdf0e10cSrcweir CheckMarked(); 215*cdf0e10cSrcweir MarkListHasChanged(); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 219*cdf0e10cSrcweir bool OSectionView::OnlyShapesMarked() const 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir const SdrMarkList& rMark = GetMarkedObjectList(); 222*cdf0e10cSrcweir const sal_uLong nCount = rMark.GetMarkCount(); 223*cdf0e10cSrcweir if ( !nCount ) 224*cdf0e10cSrcweir return false; 225*cdf0e10cSrcweir sal_uLong i=0; 226*cdf0e10cSrcweir for (; i<nCount; i++) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); 229*cdf0e10cSrcweir if ( !pObj->ISA(OCustomShape) ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir break; 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir } // for (sal_uLong i=0; i<nCount; i++) 234*cdf0e10cSrcweir return i == nCount; 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir bool OSectionView::IsDragResize() const 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir const SdrDragMethod* pDragMethod = GetDragMethod(); 240*cdf0e10cSrcweir if (pDragMethod) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir bool bMoveOnly = pDragMethod->getMoveOnly(); 243*cdf0e10cSrcweir if (bMoveOnly == false) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir // current marked components will be resized 246*cdf0e10cSrcweir return true; 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir return false; 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 253*cdf0e10cSrcweir short OSectionView::GetLayerIdOfMarkedObjects() const 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir short nRet = SHRT_MAX; 256*cdf0e10cSrcweir const SdrMarkList &rMrkList = GetMarkedObjectList(); 257*cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj(); 260*cdf0e10cSrcweir if ( nRet == SHRT_MAX ) 261*cdf0e10cSrcweir nRet = pObj->GetLayer(); 262*cdf0e10cSrcweir else if ( nRet != pObj->GetLayer() ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir nRet = -1; 265*cdf0e10cSrcweir break; 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir if ( nRet == SHRT_MAX ) 269*cdf0e10cSrcweir nRet = -1; 270*cdf0e10cSrcweir return nRet; 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir //============================================================================ 274*cdf0e10cSrcweir } // rptui 275*cdf0e10cSrcweir //============================================================================ 276