Files
libreoffice/sw/source/ui/cctrl/swlbox.cxx

175 lines
4.0 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
2000-09-18 16:15:01 +00:00
*
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
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/.
*
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
* This file incorporates work covered by the following license notice:
*
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
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>
using namespace nsSwComboBoxStyle;
2000-09-18 16:15:01 +00:00
2010-10-20 15:36:15 +01:00
// Description: ListboxElement
2000-09-18 16:15:01 +00:00
SwBoxEntry::SwBoxEntry() :
bModified(sal_False),
bNew(sal_False),
2000-09-18 16:15:01 +00:00
nId(LISTBOX_APPEND)
{
}
SwBoxEntry::SwBoxEntry(const String& aNam, sal_uInt16 nIdx) :
bModified(sal_False),
bNew(sal_False),
2000-09-18 16:15:01 +00:00
aName(aNam),
nId(nIdx)
{
}
SwBoxEntry::SwBoxEntry(const SwBoxEntry& rOld) :
bModified(rOld.bModified),
2000-09-18 16:15:01 +00:00
bNew(rOld.bNew),
aName(rOld.aName),
nId(rOld.nId)
2000-09-18 16:15:01 +00:00
{
}
SwComboBox::SwComboBox(Window* pParent, sal_uInt16 nStyleBits) :
ComboBox(pParent),
nStyle(nStyleBits)
{
Init();
}
SwComboBox::SwComboBox(Window* pParent, const ResId& rId, sal_uInt16 nStyleBits) :
2000-09-18 16:15:01 +00:00
ComboBox(pParent, rId),
nStyle(nStyleBits)
{
Init();
}
void SwComboBox::Init()
2000-09-18 16:15:01 +00:00
{
// create administration for the resource's Stringlist
sal_uInt16 nSize = GetEntryCount();
for( sal_uInt16 i=0; i < nSize; ++i )
2000-09-18 16:15:01 +00: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()
{
}
void SwComboBox::InsertEntry(const SwBoxEntry& rEntry)
{
InsertSorted(new SwBoxEntry(rEntry));
}
void SwComboBox::RemoveEntry(sal_uInt16 nPos)
2000-09-18 16:15:01 +00:00
{
if(nPos >= aEntryLst.size())
2000-09-18 16:15:01 +00:00
return;
2010-10-20 15:36:15 +01:00
// Remove old element
SwBoxEntry* pEntry = &aEntryLst[nPos];
2000-09-18 16:15:01 +00:00
ComboBox::RemoveEntry(nPos);
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)
{
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
}
sal_uInt16 SwComboBox::GetEntryPos(const SwBoxEntry& rEntry) const
2000-09-18 16:15:01 +00:00
{
return ComboBox::GetEntryPos(rEntry.aName);
}
const SwBoxEntry& SwComboBox::GetEntry(sal_uInt16 nPos) const
2000-09-18 16:15:01 +00:00
{
if(nPos < aEntryLst.size())
return aEntryLst[nPos];
2000-09-18 16:15:01 +00:00
return aDefault;
}
sal_uInt16 SwComboBox::GetRemovedCount() const
2000-09-18 16:15:01 +00:00
{
return aDelEntryLst.size();
2000-09-18 16:15:01 +00:00
}
const SwBoxEntry& SwComboBox::GetRemovedEntry(sal_uInt16 nPos) const
2000-09-18 16:15:01 +00:00
{
if(nPos < aDelEntryLst.size())
return aDelEntryLst[nPos];
2000-09-18 16:15:01 +00:00
return aDefault;
}
void SwComboBox::InsertSorted(SwBoxEntry* pEntry)
{
ComboBox::InsertEntry(pEntry->aName);
sal_uInt16 nPos = ComboBox::GetEntryPos(pEntry->aName);
aEntryLst.insert( aEntryLst.begin() + nPos, pEntry );
2000-09-18 16:15:01 +00:00
}
void SwComboBox::KeyInput( const KeyEvent& rKEvt )
{
sal_uInt16 nChar = rKEvt.GetCharCode();
2000-09-18 16:15:01 +00:00
if(nStyle & CBS_FILENAME)
{
#if defined UNX
2000-09-18 16:15:01 +00:00
if(nChar == '/' || nChar == ' ' )
return;
#else
if(nChar == ':' || nChar == '\\' || nChar == '.' || nChar == ' ')
return;
#endif
}
ComboBox::KeyInput(rKEvt);
}
2010-10-20 15:36:15 +01:00
// Convert text according to option
OUString SwComboBox::GetText() const
2000-09-18 16:15:01 +00:00
{
OUString aTxt( ComboBox::GetText() );
2000-09-18 16:15:01 +00:00
if(nStyle & CBS_LOWER)
aTxt = GetAppCharClass().lowercase( aTxt );
2000-09-18 16:15:01 +00:00
else if( nStyle & CBS_UPPER )
aTxt = GetAppCharClass().uppercase( aTxt );
2000-09-18 16:15:01 +00:00
return aTxt;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */