fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / tabledesign / TableDesignControl.cxx
blob5aced5b1d127adc293fb0d27e170d4bfff478fdc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
34 // Defines
35 #define HANDLE_ID 0
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)
41 ,m_nDataPos(-1)
42 ,m_nCurrentPos(-1)
43 ,m_nCurUndoActId(0)
44 ,m_bCurrentModified(false)
45 ,m_bUpdatable(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
60 aFont = GetFont();
61 aFont.SetWeight( WEIGHT_LIGHT );
62 SetFont(aFont);
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;
69 if (IsUpdatable())
70 nMode |= BrowserMode::HIDECURSOR;
72 SetMode(nMode);
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())
83 DeleteRows();
84 return;
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);
112 return;
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()))
128 case SID_CUT:
129 cut();
130 break;
131 case SID_COPY:
132 copy();
133 break;
134 case SID_PASTE:
135 Paste( nRow );
136 SetNoSelection();
137 GoToRow( nRow );
138 SeekRow( nRow );
139 break;
141 case SID_DELETE:
142 DeleteRows();
143 break;
144 case SID_TABLEDESIGN_INSERTROWS:
145 InsertNewRows( nRow );
146 SetNoSelection();
147 GoToRow( nRow );
148 SeekRow( nRow );
149 break;
150 default:
151 break;
156 //fall-through
157 default:
158 EditBrowseBox::Command(rEvt);
163 void OTableRowView::cut()
165 CopyRows();
166 DeleteRows();
169 void OTableRowView::copy()
171 CopyRows();
174 void OTableRowView::paste()
176 OSL_FAIL("OTableRowView::Paste : (pseudo-) abstract method called !");
179 void OTableRowView::Paste( long nRow )
181 InsertRows( nRow );
184 EditBrowseBox::RowStatus OTableRowView::GetRowStatus(long nRow) const
186 if (nRow >= 0 && m_nDataPos == nRow)
187 return CURRENT;
188 else
189 return CLEAN;
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */