diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2016-11-05 13:28:17 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2016-11-05 13:42:40 -0500 |
commit | db380aab1063e8a5e40111c40ee9f7921aa82601 (patch) | |
tree | f5057dfb205a7d7409251742888dfeaf4bfbee61 /extensions/source/propctrlr/standardcontrol.cxx | |
parent | ee2144aafc5b4be14630f723be9a2bb674671412 (diff) |
Reverts a commit series that cripple windows ci.
Revert "SvxShadowTabPage::Construct was removed"
f9a2c1c12ecad833c63b894c89d6008907477eb5.
Revert "replace OColorPopup with SvxColorWindow"
f300754bb1c6a347c92bb9548be7a65237176542.
Revert "drop AutoColorInvalid/SID_ATTR_AUTO_COLOR_INVALID"
347c2c334589b18cc62af292674bb3df1dd54b71.
Revert "replace last ColorLB use with a listbox of colors"
604b35bf55351751a396e34dcca3f85e75860fd5.
Revert "simplify, its just a vector of colors"
351a97ce6bda3075677b59fa1387ba3d1ab17d7a.
Revert "replace user draw with an Image of the color"
df738e0f8ceedb4bad756960be14d9c41adc165d.
Revert "strip down to the used pieces"
commit 08d6cd788f2584ce10ab8fa10665245e953c59d9.
Revert "move now combined ColorLB to location of last user"
a19b18ad7c9eb0197c10e6d7e451ec4542e4bc9e.
Revert "fold ColorListBox and ColorLB together"
a989a0b1f2b425f05b58d0e44ce2de31c842ed65.
Revert "move ColorListBox beside sole thing that uses it"
760a198e697f3070a5e0e029e4eff7be220eb9cd.
Revert "extensions leaks out details of Color Selector, patch it up"
8bea644d6117a49405e6426dc97214220fc869d1.
Revert "inherit FillAttrLB from ListBox not ColorListBox"
d2ce812f1d3a7a2aad89ca0bd11948b63d2db7b0.
Revert "unify color selectors"
43bc3031483d172eccd72c3804e2d4fc2ef37de4.
Diffstat (limited to 'extensions/source/propctrlr/standardcontrol.cxx')
-rw-r--r-- | extensions/source/propctrlr/standardcontrol.cxx | 109 |
1 files changed, 100 insertions, 9 deletions
diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx index 7d422966aff4..ca2412f9dbad 100644 --- a/extensions/source/propctrlr/standardcontrol.cxx +++ b/extensions/source/propctrlr/standardcontrol.cxx @@ -657,50 +657,141 @@ namespace pcr return aStr.makeStringAndClear(); } + OColorControl::OColorControl(vcl::Window* pParent, WinBits nWinStyle) - : OColorControl_Base(PropertyControlType::ColorListBox, pParent, nWinStyle) + :OColorControl_Base( PropertyControlType::ColorListBox, pParent, nWinStyle ) { + // initialize the color listbox + XColorListRef pColorList; + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SfxPoolItem* pItem = pDocSh ? pDocSh->GetItem( SID_COLOR_TABLE ) : nullptr; + if ( pItem ) + { + DBG_ASSERT(dynamic_cast< const SvxColorListItem* >(pItem) != nullptr, "OColorControl::OColorControl: invalid color item!"); + pColorList = static_cast<const SvxColorListItem*>( pItem )->GetColorList(); + } + + if ( !pColorList.is() ) + pColorList = XColorList::GetStdColorList(); + + + DBG_ASSERT(pColorList.is(), "OColorControl::OColorControl: no color table!"); + + if ( pColorList.is() ) + { + for (long i = 0; i < pColorList->Count(); ++i) + { + const XColorEntry* pEntry = pColorList->GetColor(i); + getTypedControlWindow()->InsertEntry( pEntry->GetColor(), pEntry->GetName() ); + } + } + + getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT ); + if ( ( nWinStyle & WB_READONLY ) != 0 ) + { + getTypedControlWindow()->SetReadOnly(); + getTypedControlWindow()->Enable(); + } } + void SAL_CALL OColorControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException, std::exception) { if ( _rValue.hasValue() ) { css::util::Color nColor = COL_TRANSPARENT; - _rValue >>= nColor; - ::Color aRgbCol((ColorData)nColor); - getTypedControlWindow()->SelectEntry(std::make_pair(aRgbCol, MakeHexStr(nColor, 8))); + if ( _rValue >>= nColor ) + { + ::Color aRgbCol((ColorData)nColor); + + getTypedControlWindow()->SelectEntry( aRgbCol ); + if ( !getTypedControlWindow()->IsEntrySelected( aRgbCol ) ) + { // the given color is not part of the list -> insert a new entry with the hex code of the color + OUString aStr("0x"); + aStr += MakeHexStr(nColor,8); + getTypedControlWindow()->InsertEntry( aRgbCol, aStr ); + getTypedControlWindow()->SelectEntry( aRgbCol ); + } + } + else + { + OUString sNonColorValue; + if ( !( _rValue >>= sNonColorValue ) ) + throw IllegalTypeException(); + getTypedControlWindow()->SelectEntry( sNonColorValue ); + if ( !getTypedControlWindow()->IsEntrySelected( sNonColorValue ) ) + getTypedControlWindow()->SetNoSelection(); + } } else getTypedControlWindow()->SetNoSelection(); } + Any SAL_CALL OColorControl::getValue() throw (RuntimeException, std::exception) { Any aPropValue; - if (!getTypedControlWindow()->IsNoSelection()) + if ( getTypedControlWindow()->GetSelectEntryCount() > 0 ) { - ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor(); - aPropValue <<= (css::util::Color)aRgbCol.GetColor(); + OUString sSelectedEntry = getTypedControlWindow()->GetSelectEntry(); + if ( m_aNonColorEntries.find( sSelectedEntry ) != m_aNonColorEntries.end() ) + aPropValue <<= sSelectedEntry; + else + { + ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor(); + aPropValue <<= (css::util::Color)aRgbCol.GetColor(); + } } return aPropValue; } + Type SAL_CALL OColorControl::getValueType() throw (RuntimeException, std::exception) { return ::cppu::UnoType<sal_Int32>::get(); } + + void SAL_CALL OColorControl::clearList() throw (RuntimeException, std::exception) + { + getTypedControlWindow()->Clear(); + } + + + void SAL_CALL OColorControl::prependListEntry( const OUString& NewEntry ) throw (RuntimeException, std::exception) + { + getTypedControlWindow()->InsertEntry( NewEntry, 0 ); + m_aNonColorEntries.insert( NewEntry ); + } + + + void SAL_CALL OColorControl::appendListEntry( const OUString& NewEntry ) throw (RuntimeException, std::exception) + { + getTypedControlWindow()->InsertEntry( NewEntry ); + m_aNonColorEntries.insert( NewEntry ); + } + + Sequence< OUString > SAL_CALL OColorControl::getListEntries( ) throw (RuntimeException, std::exception) + { + if ( !m_aNonColorEntries.empty() ) + return Sequence< OUString >(&(*m_aNonColorEntries.begin()),m_aNonColorEntries.size()); + return Sequence< OUString >(); + } + + void OColorControl::setModified() { OColorControl_Base::setModified(); - // fire a commit - notifyModifiedValue(); + if ( !getTypedControlWindow()->IsTravelSelect() ) + // fire a commit + notifyModifiedValue(); } + //= OListboxControl + OListboxControl::OListboxControl( vcl::Window* pParent, WinBits nWinStyle) :OListboxControl_Base( PropertyControlType::ListBox, pParent, nWinStyle ) { |