cui/source/inc/border.hxx | 8 ++- cui/source/tabpages/border.cxx | 88 ++++++++++++++++++++++++------------- include/svtools/ctrlbox.hxx | 9 ++- include/svx/svxids.hrc | 4 + sc/source/ui/view/tabvwsha.cxx | 18 +++++++ svtools/source/control/ctrlbox.cxx | 9 +-- 6 files changed, 96 insertions(+), 40 deletions(-)
New commits: commit 3d9545757246c20d261db0723f70dd91f92d3519 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Wed Jan 22 16:31:49 2014 -0500 Only allow approved border styles in cell borders. Line styles such as inset, outset, embossed etc are not supportable in Calc. So, don't show them in the UI. Change-Id: Ie7be74193d01e13a79132a979e2d9a2e4d06de3f diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx index 793d584..f0bb77b 100644 --- a/cui/source/inc/border.hxx +++ b/cui/source/inc/border.hxx @@ -26,6 +26,9 @@ #include <svtools/valueset.hxx> #include <sfx2/tabdlg.hxx> #include <svx/frmsel.hxx> +#include <svx/flagsdef.hxx> + +#include <set> // forward --------------------------------------------------------------- @@ -34,7 +37,6 @@ namespace editeng class SvxBorderLine; } -#include <svx/flagsdef.hxx> class SvxBorderTabPage : public SfxTabPage { @@ -106,6 +108,8 @@ private: bool mbUseMarginItem; bool mbSync; + std::set<sal_Int16> maUsedBorderStyles; + // Handler DECL_LINK( SelStyleHdl_Impl, ListBox* pLb ); DECL_LINK( SelColHdl_Impl, ListBox* pLb ); @@ -130,6 +134,8 @@ private: void ResetFrameLine_Impl( svx::FrameBorderType eBorder, const editeng::SvxBorderLine* pCurLine, bool bValid ); + + bool IsBorderLineStyleAllowed( sal_Int16 nStyle ) const; }; diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 87c5e24..e54f266 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -39,6 +39,7 @@ #include "svx/flagsdef.hxx" #include <sfx2/request.hxx> #include <svl/intitem.hxx> +#include <svl/ilstitem.hxx> #include <sfx2/itemconnect.hxx> #include <sal/macros.h> #include "borderconn.hxx" @@ -155,6 +156,16 @@ SvxBorderTabPage::SvxBorderTabPage(Window* pParent, const SfxItemSet& rCoreAttrs is needed across various functions... */ mbUseMarginItem = rCoreAttrs.GetItemState(GetWhich(SID_ATTR_ALIGN_MARGIN),sal_True) != SFX_ITEM_UNKNOWN; + const SfxPoolItem* pItem = NULL; + if (rCoreAttrs.HasItem(SID_ATTR_BORDER_STYLES, &pItem)) + { + const SfxIntegerListItem* p = static_cast<const SfxIntegerListItem*>(pItem); + std::vector<sal_Int32> aUsedStyles; + p->GetList(aUsedStyles); + for (size_t i = 0, n = aUsedStyles.size(); i < n; ++i) + maUsedBorderStyles.insert(static_cast<sal_Int16>(aUsedStyles[i])); + } + // set metric FieldUnit eFUnit = GetModuleFieldUnit( rCoreAttrs ); @@ -268,7 +279,7 @@ SvxBorderTabPage::SvxBorderTabPage(Window* pParent, const SfxItemSet& rCoreAttrs if ( pDocSh ) { - const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); + pItem = pDocSh->GetItem( SID_COLOR_TABLE ); if ( pItem != NULL ) pColorTable = ( (SvxColorListItem*)pItem )->GetColorList(); } @@ -348,6 +359,15 @@ void SvxBorderTabPage::ResetFrameLine_Impl( svx::FrameBorderType eBorder, const } } +bool SvxBorderTabPage::IsBorderLineStyleAllowed( sal_Int16 nStyle ) const +{ + if (maUsedBorderStyles.empty()) + // All border styles are allowed. + return true; + + return maUsedBorderStyles.count(nStyle) > 0; +} + // ----------------------------------------------------------------------- void SvxBorderTabPage::Reset( const SfxItemSet& rSet ) @@ -1001,38 +1021,48 @@ void SvxBorderTabPage::FillLineListBox_Impl() { using namespace ::com::sun::star::table::BorderLineStyle; + struct { + sal_Int16 mnStyle; + long mnMinWidth; + LineListBox::ColorFunc mpColor1Fn; + LineListBox::ColorFunc mpColor2Fn; + LineListBox::ColorDistFunc mpColorDistFn; + } aLines[] = { + // Simple lines + { SOLID, 0, &sameColor, &sameColor, &sameDistColor }, + { DOTTED, 0, &sameColor, &sameColor, &sameDistColor }, + { DASHED, 0, &sameColor, &sameColor, &sameDistColor }, + { FINE_DASHED, 0, &sameColor, &sameColor, &sameDistColor }, + + // Double lines + { DOUBLE, 10, &sameColor, &sameColor, &sameDistColor }, + { THINTHICK_SMALLGAP, 20, &sameColor, &sameColor, &sameDistColor }, + { THINTHICK_MEDIUMGAP, 0, &sameColor, &sameColor, &sameDistColor }, + { THINTHICK_LARGEGAP, 0, &sameColor, &sameColor, &sameDistColor }, + { THICKTHIN_SMALLGAP, 20, &sameColor, &sameColor, &sameDistColor }, + { THICKTHIN_MEDIUMGAP, 0, &sameColor, &sameColor, &sameDistColor }, + { THICKTHIN_LARGEGAP, 0, &sameColor, &sameColor, &sameDistColor }, + + { EMBOSSED, 15, &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, &lcl_mediumColor }, + { ENGRAVED, 15, &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, &lcl_mediumColor }, + + { OUTSET, 10, &SvxBorderLine::lightColor, &SvxBorderLine::darkColor, &sameDistColor }, + { INSET, 10, &SvxBorderLine::darkColor, &SvxBorderLine::lightColor, &sameDistColor } + }; + m_pLbLineStyle->SetSourceUnit( FUNIT_TWIP ); m_pLbLineStyle->SetNone( SVX_RESSTR( RID_SVXSTR_NONE ) ); - // Simple lines - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( SOLID ), SOLID ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( DOTTED ), DOTTED ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( DASHED ), DASHED ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( FINE_DASHED ), FINE_DASHED ); - - // Double lines - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( DOUBLE ), DOUBLE ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_SMALLGAP ), THINTHICK_SMALLGAP, 20 ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_MEDIUMGAP ), THINTHICK_MEDIUMGAP ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THINTHICK_LARGEGAP ), THINTHICK_LARGEGAP ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_SMALLGAP ), THICKTHIN_SMALLGAP, 20 ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_MEDIUMGAP ), THICKTHIN_MEDIUMGAP ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( THICKTHIN_LARGEGAP ), THICKTHIN_LARGEGAP ); - - // Engraved / Embossed - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( EMBOSSED ), EMBOSSED, 15, - &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor, - &lcl_mediumColor ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( ENGRAVED ), ENGRAVED, 15, - &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor, - &lcl_mediumColor ); - - // Inset / Outset - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( OUTSET ), OUTSET, 10, - &SvxBorderLine::lightColor, &SvxBorderLine::darkColor ); - m_pLbLineStyle->InsertEntry( SvxBorderLine::getWidthImpl( INSET ), INSET, 10, - &SvxBorderLine::darkColor, &SvxBorderLine::lightColor ); + for (size_t i = 0, n = SAL_N_ELEMENTS(aLines); i < n; ++i) + { + if (!IsBorderLineStyleAllowed(aLines[i].mnStyle)) + continue; + + m_pLbLineStyle->InsertEntry( + SvxBorderLine::getWidthImpl(aLines[i].mnStyle), aLines[i].mnStyle, + aLines[i].mnMinWidth, aLines[i].mpColor1Fn, aLines[i].mpColor2Fn, aLines[i].mpColorDistFn); + } sal_Int64 nVal = static_cast<sal_Int64>(MetricField::ConvertDoubleValue( m_pLineWidthMF->GetValue( ), diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx index 29fee68..6b8cc8f 100644 --- a/include/svtools/ctrlbox.hxx +++ b/include/svtools/ctrlbox.hxx @@ -310,6 +310,9 @@ class SVT_DLLPUBLIC LineListBox : public ListBox sal_uInt16 GetStylePos( sal_uInt16 nListPos, long nWidth ); public: + typedef Color (*ColorFunc)(Color); + typedef Color (*ColorDistFunc)(Color, Color); + LineListBox( Window* pParent, WinBits nWinStyle = WB_BORDER ); virtual ~LineListBox(); @@ -323,9 +326,9 @@ public: /** Insert a listbox entry with all widths in Twips. */ void InsertEntry( BorderWidthImpl aWidthImpl, sal_uInt16 nStyle, long nMinWidth = 0, - Color (*pColor1Fn)(Color) = &sameColor, - Color (*pColor2Fn)( Color ) = &sameColor, - Color (*pColorDistFn)( Color, Color ) = &sameDistColor ); + ColorFunc pColor1Fn = &sameColor, + ColorFunc pColor2Fn = &sameColor, + ColorDistFunc pColorDistFn = &sameDistColor ); using ListBox::RemoveEntry; virtual void RemoveEntry( sal_uInt16 nPos ); diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 307ce14..1e3f829 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -957,9 +957,11 @@ #define SID_SW_ATTR_FILL_STYLE ( SID_SVX_START + 1138 ) #define SID_SW_ATTR_FILL_GRADIENT ( SID_SVX_START + 1139 ) +#define SID_ATTR_BORDER_STYLES ( SID_SVX_START + 1140 ) + // IMPORTANT NOTE: adjust SID_SVX_FIRSTFREE, when adding new slot id -#define SID_SVX_FIRSTFREE (SID_SW_ATTR_FILL_GRADIENT + 1) +#define SID_SVX_FIRSTFREE (SID_ATTR_BORDER_STYLES + 1) // -------------------------------------------------------------------------- // Overflow check for slot IDs diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 9c064bd..a666a3f 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -24,6 +24,7 @@ #include <editeng/boxitem.hxx> #include <svx/numinf.hxx> #include <svl/srchitem.hxx> +#include <svl/ilstitem.hxx> #include <svx/zoomslideritem.hxx> #include <sfx2/bindings.hxx> #include <sfx2/viewfrm.hxx> @@ -53,8 +54,12 @@ #include "cellvalue.hxx" #include "tokenarray.hxx" +#include <com/sun/star/table/BorderLineStyle.hpp> + #include <boost/scoped_ptr.hpp> +using namespace com::sun::star; + sal_Bool ScTabViewShell::GetFunction( OUString& rFuncStr, sal_uInt16 nErrCode ) { OUString aStr; @@ -475,6 +480,19 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName boost::scoped_ptr<SfxItemSet> pOldSet(new SfxItemSet(pOldAttrs->GetItemSet())); boost::scoped_ptr<SvxNumberInfoItem> pNumberInfoItem; + // We only allow these border line types. + std::vector<sal_Int32> aBorderStyles; + aBorderStyles.reserve(5); + aBorderStyles.push_back(table::BorderLineStyle::SOLID); + aBorderStyles.push_back(table::BorderLineStyle::DOTTED); + aBorderStyles.push_back(table::BorderLineStyle::DASHED); + aBorderStyles.push_back(table::BorderLineStyle::FINE_DASHED); + aBorderStyles.push_back(table::BorderLineStyle::DOUBLE); + + SfxIntegerListItem aBorderStylesItem(SID_ATTR_BORDER_STYLES, aBorderStyles); + pOldSet->MergeRange(SID_ATTR_BORDER_STYLES, SID_ATTR_BORDER_STYLES); + pOldSet->Put(aBorderStylesItem); + // Get border items and put them in the set: GetSelectionFrame( aLineOuter, aLineInner ); //Fix border incorrect for RTL fdo#62399 diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 47012cd..36fe26d 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -839,14 +839,11 @@ sal_uInt16 LineListBox::InsertEntry( const OUString& rStr, sal_uInt16 nPos ) // ----------------------------------------------------------------------- void LineListBox::InsertEntry( - BorderWidthImpl aWidthImpl, - sal_uInt16 nStyle, long nMinWidth, - Color ( *pColor1Fn )( Color ), Color ( *pColor2Fn )( Color ), - Color ( *pColorDistFn )( Color, Color ) ) + BorderWidthImpl aWidthImpl, sal_uInt16 nStyle, long nMinWidth, + ColorFunc pColor1Fn, ColorFunc pColor2Fn, ColorDistFunc pColorDistFn ) { ImpLineListData* pData = new ImpLineListData( - aWidthImpl, nStyle, nMinWidth, - pColor1Fn, pColor2Fn, pColorDistFn ); + aWidthImpl, nStyle, nMinWidth, pColor1Fn, pColor2Fn, pColorDistFn); pLineList->push_back( pData ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits