Quellcode-Bibliothek createaddresslistdialog.cxx
Sprache: C
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
void SwAddressControl_Impl::SetData(SwCSVData& rDBData)
{
m_pData = &rDBData; //when the address data is updated then remove the controls and build again if (!m_aLines.empty())
{
m_aLines.clear();
m_bNoDataSet = true;
}
// when we have one line, measure it to get the line height to use as // the basis for overall size request if (nLines == 0)
{ auto nLineHeight = m_xWindow->get_preferred_size().Height();
m_xScrollBar->set_size_request(m_xScrollBar->get_approximate_digit_width() * 65,
nLineHeight * 10);
}
weld::Label* pNewFT = m_aLines.back()->m_xLabel.get();
weld::Entry* pNewED = m_aLines.back()->m_xEntry.get(); //set nLines a position identifier - used in the ModifyHdl
m_aEditLines[pNewED] = nLines;
pNewED->connect_focus_in(aFocusLink);
pNewED->connect_changed(aEditModifyLink);
m_bNoDataSet = false;
m_nCurrentDataSet = nSet;
OSL_ENSURE(m_pData->aDBData.size() > m_nCurrentDataSet, "wrong data set index"); if(m_pData->aDBData.size() > m_nCurrentDataSet)
{
sal_uInt32 nIndex = 0; for(auto& rLine : m_aLines)
{
OSL_ENSURE(nIndex < m_pData->aDBData[m_nCurrentDataSet].size(), "number of columns doesn't match number of Edits");
rLine->m_xEntry->set_text(m_pData->aDBData[m_nCurrentDataSet][nIndex]);
++nIndex;
}
}
}
IMPL_LINK(SwAddressControl_Impl, GotFocusHdl_Impl, weld::Widget&, rEdit, void)
{ int x, y, width, height;
rEdit.get_extents_relative_to(*m_xWindow, x, y, width, height); // the container has a border of 3 in the .ui
tools::Rectangle aRect(Point(x - 3, y - 3), Size(width + 6, height + 6));
MakeVisible(aRect);
}
void SwAddressControl_Impl::MakeVisible(const tools::Rectangle & rRect)
{ //determine range of visible positions auto nMinVisiblePos = m_xScrollBar->vadjustment_get_value(); auto nMaxVisiblePos = nMinVisiblePos + m_xScrollBar->vadjustment_get_page_size(); if (rRect.Top() < nMinVisiblePos || rRect.Bottom() > nMaxVisiblePos)
m_xScrollBar->vadjustment_set_value(rRect.Top());
}
// copy data changes into database
IMPL_LINK(SwAddressControl_Impl, EditModifyHdl_Impl, weld::Entry&, rEdit, void)
{ //get the data element number of the current set
sal_Int32 nIndex = m_aEditLines[&rEdit]; //get the index of the set
OSL_ENSURE(m_pData->aDBData.size() > m_nCurrentDataSet, "wrong data set index" ); if (m_pData->aDBData.size() > m_nCurrentDataSet)
{
m_pData->aDBData[m_nCurrentDataSet][nIndex] = rEdit.get_text();
}
}
if (!m_sURL.isEmpty())
{ //file exists, has to be loaded here
SfxMedium aMedium( m_sURL, StreamMode::READ );
SvStream* pStream = aMedium.GetInStream(); if(pStream)
{
pStream->SetLineDelimiter( LINEEND_LF );
pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
IMPL_LINK_NOARG(SwCreateAddressListDialog, DeleteHdl_Impl, weld::Button&, void)
{
sal_uInt32 nCurrent = m_xAddressControl->GetCurrentDataSet(); if (m_pCSVData->aDBData.size() > 1)
{
m_pCSVData->aDBData.erase(m_pCSVData->aDBData.begin() + nCurrent); if (nCurrent)
--nCurrent;
} else
{ // if only one set is available then clear the data
m_pCSVData->aDBData[0].assign(m_pCSVData->aDBData[0].size(), OUString());
m_xDeletePB->set_sensitive(false);
}
m_xAddressControl->CurrentDataSetInvalidated();
m_xAddressControl->SetCurrentDataSet(nCurrent);
m_xSetNoNF->set_max(m_pCSVData->aDBData.size());
UpdateButtons();
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.