21#include <osl/diagnose.h>
24#include <core_resource.hxx>
26#include <bitmaps.hlst>
27#include <com/sun/star/sdbc/DataType.hpp>
29using namespace ::
dbaui;
33 :
OWizardPage(pPage, pWizard,
"dbaccess/ui/namematchingpage.ui",
"NameMatching")
34 , m_xTABLE_LEFT(m_xBuilder->weld_label(
"leftlabel"))
35 , m_xTABLE_RIGHT(m_xBuilder->weld_label(
"rightlabel"))
36 , m_xCTRL_LEFT(m_xBuilder->weld_tree_view(
"left"))
37 , m_xCTRL_RIGHT(m_xBuilder->weld_tree_view(
"right"))
38 , m_xColumn_up(m_xBuilder->weld_button(
"up"))
39 , m_xColumn_down(m_xBuilder->weld_button(
"down"))
40 , m_xColumn_up_right(m_xBuilder->weld_button(
"up_right"))
41 , m_xColumn_down_right(m_xBuilder->weld_button(
"down_right"))
42 , m_xAll(m_xBuilder->weld_button(
"all"))
43 , m_xNone(m_xBuilder->weld_button(
"none"))
45 OUString aImgUp(BMP_UP);
46 OUString aImgDown(BMP_DOWN);
99 m_pParent->EnableNextButton(
false);
109 m_pParent->m_vColumnPositions.clear();
110 m_pParent->m_vColumnTypes.clear();
114 std::unique_ptr<weld::TreeIter> xLeftEntry =
m_xCTRL_LEFT->make_iterator();
115 std::unique_ptr<weld::TreeIter> xRightEntry =
m_xCTRL_RIGHT->make_iterator();
117 sal_Int32 nParamPos = 0;
118 bool bLeftEntry =
m_xCTRL_LEFT->get_iter_first(*xLeftEntry);
119 bool bRightEntry =
m_xCTRL_RIGHT->get_iter_first(*xRightEntry);
120 while (bLeftEntry && bRightEntry)
123 OSL_ENSURE(pSrcField,
"OWizNameMatching: OColumn can not be null!");
126 for (
auto const& column : rSrcColumns)
128 if (column->second == pSrcField)
136 OSL_ENSURE(pDestField,
"OWizNameMatching: OColumn can not be null!");
138 sal_Int32 nPosDest = 1;
139 bool bDestColumnFound =
false;
141 for (
auto const& column : rDestColumns)
143 if (column->second == pDestField)
145 bDestColumnFound =
true;
146 typeInfoSPFound = column->second->getSpecialTypeInfo();
152 OSL_ENSURE((
nPos) <
static_cast<sal_Int32
>(m_pParent->m_vColumnPositions.size()),
"m_pParent->m_vColumnPositions: Illegal index for vector");
153 m_pParent->m_vColumnPositions[
nPos].first = ++nParamPos;
154 m_pParent->m_vColumnPositions[
nPos].second = nPosDest;
158 assert(bDestColumnFound);
159 if (bDestColumnFound)
161 bool bNotConvert =
true;
162 pTypeInfo = m_pParent->convertType(typeInfoSPFound, bNotConvert);
165 sal_Int32
nType = css::sdbc::DataType::VARCHAR;
167 nType = pTypeInfo->nType;
187 int nPos = m_xCTRL_LEFT->get_selected_index();
192 if (&rButton == m_xColumn_up.get() &&
nPos)
194 else if (&rButton == m_xColumn_down.get() && nPos < m_xCTRL_LEFT->n_children() - 1)
197 m_xCTRL_LEFT->swap(nOrigPos,
nPos);
199 m_xCTRL_LEFT->scroll_to_row(
nPos);
201 TableListClickHdl(*m_xCTRL_LEFT);
206 int nPos = m_xCTRL_RIGHT->get_selected_index();
211 if (&rButton == m_xColumn_up_right.get() &&
nPos)
213 else if (&rButton == m_xColumn_down_right.get() && nPos < m_xCTRL_RIGHT->n_children() - 1)
216 m_xCTRL_RIGHT->swap(nOrigPos,
nPos);
218 m_xCTRL_RIGHT->scroll_to_row(
nPos);
220 TableListRightSelectHdl(*m_xCTRL_RIGHT);
227 int nFirstEntryInView = -1;
235 return nFirstEntryInView;
241 int nPos = m_xCTRL_LEFT->get_selected_index();
245 int nOldEntry = m_xCTRL_RIGHT->get_selected_index();
246 if (nOldEntry != -1 &&
nPos != nOldEntry)
248 m_xCTRL_RIGHT->unselect(nOldEntry);
249 if (nPos < m_xCTRL_RIGHT->n_children())
251 int nNewPos = GetFirstEntryInView(*m_xCTRL_LEFT);
252 if ( nNewPos -
nPos == 1 )
254 m_xCTRL_RIGHT->scroll_to_row(nNewPos);
255 m_xCTRL_RIGHT->select(
nPos);
258 else if (nOldEntry == -1)
260 if (nPos < m_xCTRL_RIGHT->n_children())
261 m_xCTRL_RIGHT->select(
nPos);
267 int nPos = m_xCTRL_RIGHT->get_selected_index();
271 OFieldDescription* pColumn = weld::fromId<OFieldDescription*>(m_xCTRL_RIGHT->get_id(
nPos));
272 if (pColumn->IsAutoIncrement())
274 m_xCTRL_RIGHT->unselect(
nPos);
278 int nOldEntry = m_xCTRL_LEFT->get_selected_index();
279 if (nOldEntry != -1 &&
nPos != nOldEntry)
281 m_xCTRL_LEFT->unselect(nOldEntry);
282 if (nPos < m_xCTRL_LEFT->n_children())
284 int nNewPos = GetFirstEntryInView(*m_xCTRL_RIGHT);
285 if ( nNewPos -
nPos == 1 )
287 m_xCTRL_LEFT->scroll_to_row(nNewPos);
288 m_xCTRL_LEFT->select(
nPos);
291 else if (nOldEntry == -1)
293 if (nPos < m_xCTRL_LEFT->n_children())
294 m_xCTRL_LEFT->select(
nPos);
300 bool bAll = &rButton == m_xAll.get();
313 for (
auto const& elem : rList)
318 bool bChecked = !elem->second->IsAutoIncrement();
321 rTreeView.
set_text(nRow, elem->first, 0);
#define COLUMN_POSITION_NOT_FOUND
std::vector< TColumns::const_iterator > TColumnVector
virtual void Reset() override
std::unique_ptr< weld::Button > m_xNone
std::unique_ptr< weld::Button > m_xColumn_down_right
std::unique_ptr< weld::Label > m_xTABLE_LEFT
std::unique_ptr< weld::Label > m_xTABLE_RIGHT
virtual OUString GetTitle() const override
static void FillListBox(weld::TreeView &rTreeView, const ODatabaseExport::TColumnVector &rList, bool bCheckButtons)
std::unique_ptr< weld::Button > m_xColumn_down
std::unique_ptr< weld::TreeView > m_xCTRL_RIGHT
virtual bool LeavePage() override
virtual ~OWizNameMatching() override
std::unique_ptr< weld::Button > m_xColumn_up
virtual void Activate() override
std::unique_ptr< weld::Button > m_xColumn_up_right
std::unique_ptr< weld::TreeView > m_xCTRL_LEFT
std::unique_ptr< weld::Button > m_xAll
virtual int get_iter_index_in_parent(const TreeIter &rIter) const=0
virtual void set_text(int row, const OUString &rText, int col=-1)=0
virtual void visible_foreach(const std::function< bool(TreeIter &)> &func)=0
virtual void set_toggle(int row, TriState eState, int col=-1)=0
virtual int n_children() const=0
void append(TreeIter *pRet=nullptr)
virtual void select(int pos)=0
virtual void set_id(int row, const OUString &rId)=0
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
std::shared_ptr< OTypeInfo > TOTypeInfoSP
OUString toId(const void *pValue)