1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "TableDesignControl.hxx"
21 #include "dbu_tbl.hrc"
22 #include "TableDesignView.hxx"
23 #include "TableController.hxx"
24 #include "browserids.hxx"
25 #include <com/sun/star/util/URL.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include "dbaccess_helpid.hrc"
29 using namespace ::dbaui
;
30 using namespace ::svt
;
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::beans
;
33 using namespace ::com::sun::star::util
;
37 OTableRowView::OTableRowView(vcl::Window
* pParent
)
38 :EditBrowseBox(pParent
, ModuleRes(RID_DB_TAB_EDITOR
),EditBrowseBoxFlags::NONE
,
39 BrowserMode::COLUMNSELECTION
| BrowserMode::MULTISELECTION
| BrowserMode::AUTOSIZE_LASTCOL
|
40 BrowserMode::KEEPHIGHLIGHT
| BrowserMode::HLINES
| BrowserMode::VLINES
)
44 ,m_bCurrentModified(false)
46 ,m_bClipboardFilled(false)
51 void OTableRowView::Init()
53 EditBrowseBox::Init();
55 vcl::Font
aFont( GetDataWindow().GetFont() );
56 aFont
.SetWeight( WEIGHT_NORMAL
);
57 GetDataWindow().SetFont( aFont
);
59 // set font for the headings to light
61 aFont
.SetWeight( WEIGHT_LIGHT
);
64 // set up HandleColumn for at maximum 5 digits
65 InsertHandleColumn(static_cast<sal_uInt16
>(GetTextWidth(OUString('0')) * 4)/*, sal_True */);
67 BrowserMode nMode
= BrowserMode::COLUMNSELECTION
| BrowserMode::MULTISELECTION
| BrowserMode::KEEPHIGHLIGHT
|
68 BrowserMode::HLINES
| BrowserMode::VLINES
| BrowserMode::AUTOSIZE_LASTCOL
;
70 nMode
|= BrowserMode::HIDECURSOR
;
75 void OTableRowView::KeyInput( const KeyEvent
& rEvt
)
77 if (IsDeleteAllowed(0))
79 if (rEvt
.GetKeyCode().GetCode() == KEY_DELETE
&& // Delete rows
80 !rEvt
.GetKeyCode().IsShift() &&
81 !rEvt
.GetKeyCode().IsMod1())
86 if( rEvt
.GetKeyCode().GetCode() == KEY_F2
)
88 ::com::sun::star::util::URL aUrl
;
89 aUrl
.Complete
= ".uno:DSBEditDoc";
90 GetView()->getController().dispatch( aUrl
,Sequence
< PropertyValue
>() );
93 EditBrowseBox::KeyInput(rEvt
);
96 void OTableRowView::SetUpdatable( bool bUpdate
)
98 m_bUpdatable
= bUpdate
;
102 void OTableRowView::Command(const CommandEvent
& rEvt
)
105 switch (rEvt
.GetCommand())
107 case CommandEventId::ContextMenu
:
109 if (!rEvt
.IsMouseEvent())
111 EditBrowseBox::Command(rEvt
);
115 sal_uInt16 nColId
= GetColumnAtXPosPixel(rEvt
.GetMousePosPixel().X());
116 long nRow
= GetRowAtYPosPixel(rEvt
.GetMousePosPixel().Y());
118 if ( nColId
== HANDLE_ID
)
120 PopupMenu
aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU
));
121 long nSelectRowCount
= GetSelectRowCount();
122 aContextMenu
.EnableItem( SID_CUT
, nSelectRowCount
!= 0);
123 aContextMenu
.EnableItem( SID_COPY
, nSelectRowCount
!= 0);
124 aContextMenu
.EnableItem( SID_PASTE
, m_bClipboardFilled
);
125 aContextMenu
.EnableItem( SID_DELETE
, IsUpdatable() && nSelectRowCount
!= 0 );
126 switch (aContextMenu
.Execute(this, rEvt
.GetMousePosPixel()))
144 case SID_TABLEDESIGN_INSERTROWS
:
145 InsertNewRows( nRow
);
158 EditBrowseBox::Command(rEvt
);
163 void OTableRowView::cut()
169 void OTableRowView::copy()
174 void OTableRowView::paste()
176 OSL_FAIL("OTableRowView::Paste : (pseudo-) abstract method called !");
179 void OTableRowView::Paste( long nRow
)
184 EditBrowseBox::RowStatus
OTableRowView::GetRowStatus(long nRow
) const
186 if (nRow
>= 0 && m_nDataPos
== nRow
)
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */