Update ooo320-m1
[ooovba.git] / sw / source / ui / ribbar / conform.cxx
blob5137c353909ea32be90f9eeb1daec3e45dc56a08
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conform.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <svx/fmglob.hxx>
36 #include <svx/svdview.hxx>
37 #include <svx/fmshell.hxx>
39 #include "view.hxx"
40 #include "edtwin.hxx"
41 #include "wrtsh.hxx"
42 #include "drawbase.hxx"
43 #include "conform.hxx"
45 extern BOOL bNoInterrupt; // in mainwn.cxx
47 /*************************************************************************
49 |* Konstruktor
51 \************************************************************************/
54 ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
55 SwDrawBase(pWrtShell, pEditWin, pSwView)
57 m_bInsForm = TRUE;
60 /*************************************************************************
62 |* MouseButtonDown-event
64 \************************************************************************/
67 BOOL ConstFormControl::MouseButtonDown(const MouseEvent& rMEvt)
69 BOOL bReturn = FALSE;
71 SdrView *pSdrView = m_pSh->GetDrawView();
73 pSdrView->SetOrtho(rMEvt.IsShift());
74 pSdrView->SetAngleSnapEnabled(rMEvt.IsShift());
76 if (rMEvt.IsMod2())
78 pSdrView->SetCreate1stPointAsCenter(TRUE);
79 pSdrView->SetResizeAtCenter(TRUE);
81 else
83 pSdrView->SetCreate1stPointAsCenter(FALSE);
84 pSdrView->SetResizeAtCenter(FALSE);
87 SdrViewEvent aVEvt;
88 SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
90 // Nur neues Objekt, wenn nicht im Basismode (bzw reinem Selektionsmode)
91 if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() &&
92 (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate()))
94 bNoInterrupt = TRUE;
95 m_pWin->CaptureMouse();
97 m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
99 m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
100 bReturn = m_pSh->BeginCreate( static_cast< UINT16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, m_aStartPos);
102 if (bReturn)
103 m_pWin->SetDrawAction(TRUE);
105 else
106 bReturn = SwDrawBase::MouseButtonDown(rMEvt);
108 return (bReturn);
111 /*************************************************************************
113 |* Function aktivieren
115 \************************************************************************/
118 void ConstFormControl::Activate(const USHORT nSlotId)
120 m_pWin->SetSdrDrawMode( static_cast<SdrObjKind>(nSlotId) );
121 SwDrawBase::Activate(nSlotId);
122 m_pSh->GetDrawView()->SetCurrentObj(nSlotId);
124 m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT));
126 /* -----------------------------19.04.2002 12:42------------------------------
128 ---------------------------------------------------------------------------*/
129 void ConstFormControl::CreateDefaultObject()
131 Point aStartPos(GetDefaultCenterPos());
132 Point aEndPos(aStartPos);
133 aStartPos.X() -= 2 * MM50;
134 aStartPos.Y() -= MM50;
135 aEndPos.X() += 2 * MM50;
136 aEndPos.Y() += MM50;
138 if(!m_pSh->HasDrawView())
139 m_pSh->MakeDrawView();
141 SdrView *pSdrView = m_pSh->GetDrawView();
142 pSdrView->SetDesignMode(TRUE);
143 m_pSh->BeginCreate( static_cast< UINT16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, aStartPos);
144 m_pSh->MoveCreate(aEndPos);
145 m_pSh->EndCreate(SDRCREATE_FORCEEND);