2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2011-03-31 10:05:04 +02:00
|
|
|
* 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/.
|
2005-11-16 08:48:55 +00:00
|
|
|
*
|
2011-03-31 10:05:04 +02:00
|
|
|
* This file incorporates work covered by the following license notice:
|
2005-11-16 08:48:55 +00:00
|
|
|
*
|
2011-03-31 10:05:04 +02:00
|
|
|
* 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 .
|
|
|
|
*/
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-10-20 15:36:15 +01:00
|
|
|
#include <osl/diagnose.h>
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <unotools/charclass.hxx>
|
|
|
|
#include <swtypes.hxx>
|
|
|
|
#include <swlbox.hxx>
|
|
|
|
|
2010-10-20 15:36:15 +01:00
|
|
|
// Description: ListboxElement
|
2000-09-18 16:15:01 +00:00
|
|
|
SwBoxEntry::SwBoxEntry() :
|
2014-04-25 14:00:35 +02:00
|
|
|
bModified(false),
|
|
|
|
bNew(false),
|
2014-03-01 03:13:28 +01:00
|
|
|
nId(COMBOBOX_APPEND)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-03-01 03:13:28 +01:00
|
|
|
SwBoxEntry::SwBoxEntry(const OUString& aNam, sal_Int32 nIdx) :
|
2014-04-25 14:00:35 +02:00
|
|
|
bModified(false),
|
|
|
|
bNew(false),
|
2000-09-18 16:15:01 +00:00
|
|
|
aName(aNam),
|
|
|
|
nId(nIdx)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwBoxEntry::SwBoxEntry(const SwBoxEntry& rOld) :
|
2007-09-27 09:18:38 +00:00
|
|
|
bModified(rOld.bModified),
|
2000-09-18 16:15:01 +00:00
|
|
|
bNew(rOld.bNew),
|
2007-09-27 09:18:38 +00:00
|
|
|
aName(rOld.aName),
|
|
|
|
nId(rOld.nId)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
SwComboBox::SwComboBox(vcl::Window* pParent, WinBits nStyle)
|
2013-10-14 13:48:34 +01:00
|
|
|
: ComboBox(pParent, nStyle)
|
2012-11-29 21:44:20 +00:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwComboBox::Init()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-02-21 22:28:46 +01:00
|
|
|
// create administration for the resource's Stringlist
|
2014-03-01 03:13:28 +01:00
|
|
|
sal_Int32 nSize = GetEntryCount();
|
|
|
|
for( sal_Int32 i=0; i < nSize; ++i )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-04-25 11:55:08 +02:00
|
|
|
SwBoxEntry* pTmp = new SwBoxEntry(ComboBox::GetEntry(i), i);
|
|
|
|
aEntryLst.push_back(pTmp);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-20 15:36:15 +01:00
|
|
|
// Basic class Dtor
|
2000-09-18 16:15:01 +00:00
|
|
|
SwComboBox::~SwComboBox()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-07 22:09:06 +02:00
|
|
|
void SwComboBox::InsertSwEntry(const SwBoxEntry& rEntry)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
InsertSorted(new SwBoxEntry(rEntry));
|
|
|
|
}
|
|
|
|
|
2014-03-01 03:13:28 +01:00
|
|
|
sal_Int32 SwComboBox::InsertEntry(const OUString& rStr, sal_Int32)
|
2013-08-07 22:09:06 +02:00
|
|
|
{
|
|
|
|
InsertSwEntry(SwBoxEntry(rStr));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-01 03:13:28 +01:00
|
|
|
void SwComboBox::RemoveEntryAt(sal_Int32 const nPos)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2014-03-01 03:13:28 +01:00
|
|
|
if(nPos < 0 || static_cast<size_t>(nPos) >= aEntryLst.size())
|
2000-09-18 16:15:01 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-20 15:36:15 +01:00
|
|
|
// Remove old element
|
2012-04-25 11:55:08 +02:00
|
|
|
SwBoxEntry* pEntry = &aEntryLst[nPos];
|
2013-08-07 22:09:06 +02:00
|
|
|
ComboBox::RemoveEntryAt(nPos);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-10-20 15:36:15 +01:00
|
|
|
// Don't add new entries to the list
|
2000-09-18 16:15:01 +00:00
|
|
|
if(pEntry->bNew)
|
2012-04-25 11:55:09 +02:00
|
|
|
{
|
|
|
|
aEntryLst.erase(aEntryLst.begin() + nPos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// add to DelEntryLst
|
|
|
|
aDelEntryLst.transfer(aDelEntryLst.end(),
|
|
|
|
aEntryLst.begin() + nPos, aEntryLst);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2014-03-01 03:13:28 +01:00
|
|
|
sal_Int32 SwComboBox::GetSwEntryPos(const SwBoxEntry& rEntry) const
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
return ComboBox::GetEntryPos(rEntry.aName);
|
|
|
|
}
|
|
|
|
|
2014-03-01 03:13:28 +01:00
|
|
|
const SwBoxEntry& SwComboBox::GetSwEntry(sal_Int32 const nPos) const
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2014-03-01 03:13:28 +01:00
|
|
|
if(0 <= nPos && static_cast<size_t>(nPos) < aEntryLst.size())
|
2012-04-25 11:55:08 +02:00
|
|
|
return aEntryLst[nPos];
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
return aDefault;
|
|
|
|
}
|
|
|
|
|
2014-03-01 03:13:28 +01:00
|
|
|
sal_Int32 SwComboBox::GetRemovedCount() const
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2014-03-01 03:13:28 +01:00
|
|
|
return static_cast<sal_Int32>(aDelEntryLst.size());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2014-03-01 03:13:28 +01:00
|
|
|
const SwBoxEntry& SwComboBox::GetRemovedEntry(sal_Int32 nPos) const
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2014-03-01 03:13:28 +01:00
|
|
|
if(0 <= nPos && static_cast<size_t>(nPos) < aDelEntryLst.size())
|
2012-04-25 11:55:08 +02:00
|
|
|
return aDelEntryLst[nPos];
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
return aDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwComboBox::InsertSorted(SwBoxEntry* pEntry)
|
|
|
|
{
|
|
|
|
ComboBox::InsertEntry(pEntry->aName);
|
2014-03-01 03:13:28 +01:00
|
|
|
sal_Int32 nPos = ComboBox::GetEntryPos(pEntry->aName);
|
2012-04-25 11:55:08 +02:00
|
|
|
aEntryLst.insert( aEntryLst.begin() + nPos, pEntry );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|