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 .
21 #include "TableDesignControl.hxx"
22 #include "dbu_tbl.hrc"
23 #include "TableDesignView.hxx"
24 #include "TableController.hxx"
25 #include "browserids.hxx"
26 #include <com/sun/star/util/URL.hpp>
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include "dbaccess_helpid.hrc"
30 using namespace ::dbaui
;
31 using namespace ::svt
;
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::beans
;
34 using namespace ::com::sun::star::util
;
38 DBG_NAME(OTableRowView
)
39 //------------------------------------------------------------------------
40 OTableRowView::OTableRowView(Window
* pParent
)
41 :EditBrowseBox(pParent
, ModuleRes(RID_DB_TAB_EDITOR
),EBBF_NONE
,
42 BROWSER_COLUMNSELECTION
| BROWSER_MULTISELECTION
| BROWSER_AUTOSIZE_LASTCOL
|
43 BROWSER_KEEPSELECTION
| BROWSER_HLINESFULL
| BROWSER_VLINESFULL
)
47 ,m_bCurrentModified(sal_False
)
48 ,m_bUpdatable(sal_False
)
49 ,m_bClipboardFilled(sal_False
)
51 DBG_CTOR(OTableRowView
,NULL
);
55 //------------------------------------------------------------------------
56 OTableRowView::~OTableRowView()
59 DBG_DTOR(OTableRowView
,NULL
);
62 //------------------------------------------------------------------------
63 void OTableRowView::Init()
65 EditBrowseBox::Init();
67 Font
aFont( GetDataWindow().GetFont() );
68 aFont
.SetWeight( WEIGHT_NORMAL
);
69 GetDataWindow().SetFont( aFont
);
71 // Font fuer die Ueberschriften auf Light setzen
73 aFont
.SetWeight( WEIGHT_LIGHT
);
76 // HandleColumn, fuer maximal fuenf Ziffern einrichten
77 InsertHandleColumn(static_cast<sal_uInt16
>(GetTextWidth(OUString('0')) * 4)/*, sal_True */);
79 BrowserMode nMode
= BROWSER_COLUMNSELECTION
| BROWSER_MULTISELECTION
| BROWSER_KEEPSELECTION
|
80 BROWSER_HLINESFULL
| BROWSER_VLINESFULL
| BROWSER_AUTOSIZE_LASTCOL
;
82 nMode
|= BROWSER_HIDECURSOR
;
87 //------------------------------------------------------------------------
88 void OTableRowView::KeyInput( const KeyEvent
& rEvt
)
90 if (IsDeleteAllowed(0))
92 if (rEvt
.GetKeyCode().GetCode() == KEY_DELETE
&& // Delete rows
93 !rEvt
.GetKeyCode().IsShift() &&
94 !rEvt
.GetKeyCode().IsMod1())
99 if( rEvt
.GetKeyCode().GetCode() == KEY_F2
)
101 ::com::sun::star::util::URL aUrl
;
102 aUrl
.Complete
=OUString(".uno:DSBEditDoc");
103 GetView()->getController().dispatch( aUrl
,Sequence
< PropertyValue
>() );
106 EditBrowseBox::KeyInput(rEvt
);
109 //------------------------------------------------------------------------
110 void OTableRowView::SetUpdatable( sal_Bool bUpdate
)
112 m_bUpdatable
= bUpdate
;
116 //------------------------------------------------------------------------
117 void OTableRowView::Command(const CommandEvent
& rEvt
)
120 switch (rEvt
.GetCommand())
122 case COMMAND_CONTEXTMENU
:
124 if (!rEvt
.IsMouseEvent())
126 EditBrowseBox::Command(rEvt
);
130 sal_uInt16 nColId
= GetColumnAtXPosPixel(rEvt
.GetMousePosPixel().X());
131 long nRow
= GetRowAtYPosPixel(rEvt
.GetMousePosPixel().Y());
133 if ( nColId
== HANDLE_ID
)
135 PopupMenu
aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU
));
136 long nSelectRowCount
= GetSelectRowCount();
137 aContextMenu
.EnableItem( SID_CUT
, nSelectRowCount
!= 0);
138 aContextMenu
.EnableItem( SID_COPY
, nSelectRowCount
!= 0);
139 aContextMenu
.EnableItem( SID_PASTE
, m_bClipboardFilled
);
140 aContextMenu
.EnableItem( SID_DELETE
, IsUpdatable() && nSelectRowCount
!= 0 );
141 switch (aContextMenu
.Execute(this, rEvt
.GetMousePosPixel()))
159 case SID_TABLEDESIGN_INSERTROWS
:
160 InsertNewRows( nRow
);
172 EditBrowseBox::Command(rEvt
);
177 //------------------------------------------------------------------------------
178 void OTableRowView::cut()
184 //------------------------------------------------------------------------------
185 void OTableRowView::copy()
190 //------------------------------------------------------------------------------
191 void OTableRowView::paste()
193 OSL_FAIL("OTableRowView::Paste : (pseudo-) abstract method called !");
196 //------------------------------------------------------------------------------
197 void OTableRowView::Paste( long nRow
)
202 //------------------------------------------------------------------------------
203 EditBrowseBox::RowStatus
OTableRowView::GetRowStatus(long nRow
) const
205 if (nRow
>= 0 && m_nDataPos
== nRow
)
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */