Files
libreoffice/sw/source/ui/ribbar/conrect.cxx

238 lines
7.1 KiB
C++
Raw Normal View History

2000-09-18 16:15:01 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:15:01 +00:00
*
* Copyright 2008 by Sun Microsystems, Inc.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:15:01 +00:00
*
* $RCSfile: conrect.cxx,v $
* $Revision: 1.16 $
2000-09-18 16:15:01 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:15:01 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:15:01 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
2000-09-18 16:15:01 +00:00
#include <sfx2/bindings.hxx>
#include <svx/htmlmode.hxx>
#include <svx/sdtacitm.hxx>
#include <svx/svdobj.hxx>
#include <svx/sdtagitm.hxx>
#include <svx/sdtakitm.hxx>
#include <svx/sdtaditm.hxx>
#include <svx/sdtaaitm.hxx>
#include <svx/svdview.hxx>
#include <svx/svdocapt.hxx>
#include <svx/outlobj.hxx>
2001-03-16 13:47:06 +00:00
#ifndef _CMDID_H
#include <cmdid.h>
#endif
#ifndef _VIEW_HXX
#include <view.hxx>
#endif
#include <edtwin.hxx>
#include <wrtsh.hxx>
#include <viewopt.hxx>
#ifndef _DRAWBASE_HXX
#include <drawbase.hxx>
#endif
#ifndef _CONRECT_HXX
#include <conrect.hxx>
#endif
2000-09-18 16:15:01 +00:00
/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/
2001-03-16 13:47:06 +00:00
ConstRectangle::ConstRectangle( SwWrtShell* pWrtShell, SwEditWin* pEditWin,
SwView* pSwView )
: SwDrawBase( pWrtShell, pEditWin, pSwView ),
bMarquee(FALSE),
// #93382#
mbVertical(sal_False)
2000-09-18 16:15:01 +00:00
{
}
/*************************************************************************
|*
|* MouseButtonDown-event
|*
\************************************************************************/
BOOL ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
{
BOOL bReturn;
if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == TRUE
&& m_pWin->GetSdrDrawMode() == OBJ_CAPTION)
2000-09-18 16:15:01 +00:00
{
m_pView->NoRotate();
if (m_pView->IsDrawSelMode())
2000-09-18 16:15:01 +00:00
{
m_pView->FlipDrawSelMode();
m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode());
2000-09-18 16:15:01 +00:00
}
}
return (bReturn);
}
/*************************************************************************
|*
|* MouseButtonUp-event
|*
\************************************************************************/
BOOL ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
{
Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
2000-09-18 16:15:01 +00:00
BOOL bRet = SwDrawBase::MouseButtonUp(rMEvt);
if( bRet )
2000-09-18 16:15:01 +00:00
{
SdrView *pSdrView = m_pSh->GetDrawView();
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
SdrObject* pObj = rMarkList.GetMark(0) ? rMarkList.GetMark(0)->GetMarkedSdrObj()
: 0;
switch( m_pWin->GetSdrDrawMode() )
2000-09-18 16:15:01 +00:00
{
case OBJ_TEXT:
if( bMarquee )
2000-09-18 16:15:01 +00:00
{
m_pSh->ChgAnchor(FLY_IN_CNTNT);
2000-09-18 16:15:01 +00:00
if( pObj )
{
// die fuer das Scrollen benoetigten Attribute setzen
SfxItemSet aItemSet( pSdrView->GetModel()->GetItemPool(),
2000-09-18 16:15:01 +00:00
SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
aItemSet.Put( SdrTextAutoGrowWidthItem( FALSE ) );
aItemSet.Put( SdrTextAutoGrowHeightItem( FALSE ) );
aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SCROLL ) );
aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
aItemSet.Put( SdrTextAniCountItem( 0 ) );
aItemSet.Put( SdrTextAniAmountItem(
(INT16)m_pWin->PixelToLogic(Size(2,1)).Width()) );
pObj->SetMergedItemSetAndBroadcast(aItemSet);
}
2000-09-18 16:15:01 +00:00
}
else if(mbVertical && pObj && pObj->ISA(SdrTextObj))
{
// #93382#
SdrTextObj* pText = (SdrTextObj*)pObj;
SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
pText->SetVerticalWriting(TRUE);
aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
pText->SetMergedItemSet(aSet);
}
if( pObj )
{
SdrPageView* pPV = pSdrView->GetSdrPageView();
m_pView->BeginTextEdit( pObj, pPV, m_pWin, sal_True );
}
m_pView->LeaveDrawCreate(); // In Selektionsmode wechseln
m_pSh->GetView().GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
break;
2000-09-18 16:15:01 +00:00
case OBJ_CAPTION:
if( bCapVertical && pObj )
{
SdrCaptionObj* pCaptObj = (SdrCaptionObj*)pObj;
pCaptObj->ForceOutlinerParaObject();
OutlinerParaObject* pOPO = pCaptObj->GetOutlinerParaObject();
if( pOPO && !pOPO->IsVertical() )
pOPO->SetVertical( TRUE );
}
break;
default:; //prevent warning
2000-09-18 16:15:01 +00:00
}
}
return bRet;
}
/*************************************************************************
|*
|* Function aktivieren
|*
\************************************************************************/
void ConstRectangle::Activate(const USHORT nSlotId)
{
bMarquee = bCapVertical = FALSE;
mbVertical = sal_False;
2000-09-18 16:15:01 +00:00
switch (nSlotId)
{
2001-03-16 13:47:06 +00:00
case SID_DRAW_LINE:
m_pWin->SetSdrDrawMode(OBJ_LINE);
2001-03-16 13:47:06 +00:00
break;
case SID_DRAW_RECT:
m_pWin->SetSdrDrawMode(OBJ_RECT);
2001-03-16 13:47:06 +00:00
break;
case SID_DRAW_ELLIPSE:
m_pWin->SetSdrDrawMode(OBJ_CIRC);
2001-03-16 13:47:06 +00:00
break;
case SID_DRAW_TEXT_MARQUEE:
bMarquee = TRUE;
m_pWin->SetSdrDrawMode(OBJ_TEXT);
break;
2001-03-16 13:47:06 +00:00
case SID_DRAW_TEXT_VERTICAL:
// #93382#
mbVertical = sal_True;
m_pWin->SetSdrDrawMode(OBJ_TEXT);
break;
case SID_DRAW_TEXT:
m_pWin->SetSdrDrawMode(OBJ_TEXT);
2001-03-16 13:47:06 +00:00
break;
case SID_DRAW_CAPTION_VERTICAL:
bCapVertical = TRUE;
// no break
case SID_DRAW_CAPTION:
m_pWin->SetSdrDrawMode(OBJ_CAPTION);
2001-03-16 13:47:06 +00:00
break;
default:
m_pWin->SetSdrDrawMode(OBJ_NONE);
2001-03-16 13:47:06 +00:00
break;
2000-09-18 16:15:01 +00:00
}
SwDrawBase::Activate(nSlotId);
}