1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TableDesignControl.cxx,v $
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_dbaccess.hxx"
34 #ifndef DBAUI_TABLEDESIGNCONTROL_HXX
35 #include "TableDesignControl.hxx"
38 #include "dbu_tbl.hrc"
40 #ifndef DBAUI_TABLEDESIGNVIEW_HXX
41 #include "TableDesignView.hxx"
43 #ifndef DBUI_TABLECONTROLLER_HXX
44 #include "TableController.hxx"
46 #ifndef DBACCESS_UI_BROWSER_ID_HXX
47 #include "browserids.hxx"
49 #ifndef _COM_SUN_STAR_UTIL_URL_HPP_
50 #include <com/sun/star/util/URL.hpp>
52 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
53 #include <com/sun/star/beans/PropertyValue.hpp>
55 #ifndef _DBA_DBACCESS_HELPID_HRC_
56 #include "dbaccess_helpid.hrc"
59 using namespace ::dbaui
;
60 using namespace ::svt
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::beans
;
63 using namespace ::com::sun::star::util
;
67 DBG_NAME(OTableRowView
)
68 //------------------------------------------------------------------------
69 OTableRowView::OTableRowView(Window
* pParent
)
70 :EditBrowseBox(pParent
, ModuleRes(RID_DB_TAB_EDITOR
),EBBF_NONE
,
71 BROWSER_COLUMNSELECTION
| BROWSER_MULTISELECTION
| BROWSER_AUTOSIZE_LASTCOL
|
72 BROWSER_KEEPSELECTION
| BROWSER_HLINESFULL
| BROWSER_VLINESFULL
)
76 ,m_bCurrentModified(FALSE
)
78 ,m_bClipboardFilled(FALSE
)
80 DBG_CTOR(OTableRowView
,NULL
);
84 //------------------------------------------------------------------------
85 OTableRowView::~OTableRowView()
88 DBG_DTOR(OTableRowView
,NULL
);
91 //------------------------------------------------------------------------
92 void OTableRowView::Init()
94 EditBrowseBox::Init();
96 // SetMapMode( MapMode(MAP_TWIP) );
97 // GetDataWindow().SetMapMode( GetMapMode() );
99 Font
aFont( GetDataWindow().GetFont() );
100 aFont
.SetWeight( WEIGHT_NORMAL
);
101 GetDataWindow().SetFont( aFont
);
103 // Font fuer die Ueberschriften auf Light setzen
105 aFont
.SetWeight( WEIGHT_LIGHT
);
108 // HandleColumn, fuer maximal fuenf Ziffern einrichten
109 InsertHandleColumn(static_cast<USHORT
>(GetTextWidth('0') * 4)/*, TRUE */);
111 BrowserMode nMode
= BROWSER_COLUMNSELECTION
| BROWSER_MULTISELECTION
| BROWSER_KEEPSELECTION
|
112 BROWSER_HLINESFULL
| BROWSER_VLINESFULL
| BROWSER_AUTOSIZE_LASTCOL
;
114 nMode
|= BROWSER_HIDECURSOR
;
119 //------------------------------------------------------------------------
120 void OTableRowView::KeyInput( const KeyEvent
& rEvt
)
122 if (IsDeleteAllowed(0))
124 if (rEvt
.GetKeyCode().GetCode() == KEY_DELETE
&& // Delete rows
125 !rEvt
.GetKeyCode().IsShift() &&
126 !rEvt
.GetKeyCode().IsMod1())
131 if( rEvt
.GetKeyCode().GetCode() == KEY_F2
)
133 ::com::sun::star::util::URL aUrl
;
134 aUrl
.Complete
=::rtl::OUString::createFromAscii(".uno:DSBEditDoc");
135 GetView()->getController().dispatch( aUrl
,Sequence
< PropertyValue
>() );
138 EditBrowseBox::KeyInput(rEvt
);
141 //------------------------------------------------------------------------
142 void OTableRowView::SetUpdatable( BOOL bUpdate
)
144 m_bUpdatable
= bUpdate
;
148 //------------------------------------------------------------------------
149 void OTableRowView::Command(const CommandEvent
& rEvt
)
152 switch (rEvt
.GetCommand())
154 case COMMAND_CONTEXTMENU
:
156 if (!rEvt
.IsMouseEvent())
158 EditBrowseBox::Command(rEvt
);
162 USHORT nColId
= GetColumnAtXPosPixel(rEvt
.GetMousePosPixel().X());
163 long nRow
= GetRowAtYPosPixel(rEvt
.GetMousePosPixel().Y());
165 if ( nColId
== HANDLE_ID
)
167 PopupMenu
aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU
));
168 long nSelectRowCount
= GetSelectRowCount();
169 aContextMenu
.EnableItem( SID_CUT
, nSelectRowCount
!= 0);
170 aContextMenu
.EnableItem( SID_COPY
, nSelectRowCount
!= 0);
171 aContextMenu
.EnableItem( SID_PASTE
, m_bClipboardFilled
);
172 aContextMenu
.EnableItem( SID_DELETE
, IsUpdatable() && nSelectRowCount
!= 0 );
173 switch (aContextMenu
.Execute(this, rEvt
.GetMousePosPixel()))
191 case SID_TABLEDESIGN_INSERTROWS
:
192 InsertNewRows( nRow
);
204 EditBrowseBox::Command(rEvt
);
209 //------------------------------------------------------------------------------
210 void OTableRowView::cut()
216 //------------------------------------------------------------------------------
217 void OTableRowView::copy()
222 //------------------------------------------------------------------------------
223 void OTableRowView::paste()
225 OSL_ENSURE(0,"OTableRowView::Paste : (pseudo-) abstract method called !");
228 //------------------------------------------------------------------------------
229 void OTableRowView::Paste( long nRow
)
234 //------------------------------------------------------------------------------
235 EditBrowseBox::RowStatus
OTableRowView::GetRowStatus(long nRow
) const
237 if (nRow
>= 0 && m_nDataPos
== nRow
)