diff options
-rw-r--r-- | include/svx/strings.hrc | 40 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 50 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 156 |
3 files changed, 106 insertions, 140 deletions
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index 1b30c31fa1a0..0091baaaa44b 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -1774,26 +1774,26 @@ // strings related to borders -#define RID_SVXSTR_TABLE_PRESET_NONE NC_("RID_SVXSTR_TABLE_PRESET_NONE", "Set No Borders") -#define RID_SVXSTR_TABLE_PRESET_ONLYOUTER NC_("RID_SVXSTR_TABLE_PRESET_ONLYOUTER", "Set Outer Border Only") -#define RID_SVXSTR_TABLE_PRESET_OUTERHORI NC_("RID_SVXSTR_TABLE_PRESET_OUTERHORI", "Set Outer Border and Horizontal Lines") -#define RID_SVXSTR_TABLE_PRESET_OUTERALL NC_("RID_SVXSTR_TABLE_PRESET_OUTERALL", "Set Outer Border and All Inner Lines") -#define RID_SVXSTR_TABLE_PRESET_OUTERVERI NC_("RID_SVXSTR_TABLE_PRESET_OUTERVERI", "Set Outer Border and Vertical Lines") -#define RID_SVXSTR_TABLE_PRESET_OUTERINNER NC_("RID_SVXSTR_TABLE_PRESET_OUTERINNER", "Set Outer Border Without Changing Inner Lines") -#define RID_SVXSTR_PARA_PRESET_DIAGONAL NC_("RID_SVXSTR_PARA_PRESET_DIAGONAL", "Set Diagonal Lines Only") -#define RID_SVXSTR_PARA_PRESET_DIAGONALLEFT NC_("RID_SVXSTR_PARA_PRESET_DIAGONALLEFT", "Set Diagonal Left Border") -#define RID_SVXSTR_PARA_PRESET_DIAGONALRIGHT NC_("RID_SVXSTR_PARA_PRESET_DIAGONALRIGHT", "Set Diagonal Right Border") -#define RID_SVXSTR_PARA_PRESET_CRISSCROSS NC_("RID_SVXSTR_PARA_PRESET_CRISSCROSS", "Set Criss-Cross Border") -#define RID_SVXSTR_PARA_PRESET_ALL NC_("RID_SVXSTR_PARA_PRESET_ALL", "Set All Four Borders") -#define RID_SVXSTR_PARA_PRESET_LEFTRIGHT NC_("RID_SVXSTR_PARA_PRESET_LEFTRIGHT", "Set Left and Right Borders Only") -#define RID_SVXSTR_PARA_PRESET_TOPBOTTOM NC_("RID_SVXSTR_PARA_PRESET_TOPBOTTOM", "Set Top and Bottom Borders Only") -#define RID_SVXSTR_PARA_PRESET_TOPBOTTOMHORI NC_("RID_SVXSTR_PARA_PRESET_TOPBOTTOMHORI", "Set Top and Bottom Borders, and All Horizontal Lines") -#define RID_SVXSTR_PARA_PRESET_ONLYLEFT NC_("RID_SVXSTR_PARA_PRESET_ONLYLEFT", "Set Left Border Only") -#define RID_SVXSTR_PARA_PRESET_ONLYRIGHT NC_("RID_SVXSTR_PARA_PRESET_ONLYRIGHT", "Set Right Border Only") -#define RID_SVXSTR_PARA_PRESET_ONLYTOP NC_("RID_SVXSTR_PARA_PRESET_ONLYTOP", "Set Top Border Only") -#define RID_SVXSTR_PARA_PRESET_ONLYTBOTTOM NC_("RID_SVXSTR_PARA_PRESET_ONLYTBOTTOM", "Set Bottom Border Only") -#define RID_SVXSTR_HOR_PRESET_ONLYHOR NC_("RID_SVXSTR_HOR_PRESET_ONLYHOR", "Set Top and Bottom Borders, and All Inner Lines") -#define RID_SVXSTR_VER_PRESET_ONLYVER NC_("RID_SVXSTR_VER_PRESET_ONLYVER", "Set Left and Right Borders, and All Inner Lines") +#define RID_SVXSTR_TABLE_PRESET_NONE NC_("RID_SVXSTR_TABLE_PRESET_NONE", "No Borders") +#define RID_SVXSTR_TABLE_PRESET_ONLYOUTER NC_("RID_SVXSTR_TABLE_PRESET_ONLYOUTER", "Outer Border Only") +#define RID_SVXSTR_TABLE_PRESET_OUTERHORI NC_("RID_SVXSTR_TABLE_PRESET_OUTERHORI", "Outer Border and Horizontal Lines") +#define RID_SVXSTR_TABLE_PRESET_OUTERALL NC_("RID_SVXSTR_TABLE_PRESET_OUTERALL", "Outer Border and All Inner Lines") +#define RID_SVXSTR_TABLE_PRESET_OUTERVERI NC_("RID_SVXSTR_TABLE_PRESET_OUTERVERI", "Outer Border and Vertical Lines") +#define RID_SVXSTR_TABLE_PRESET_OUTERINNER NC_("RID_SVXSTR_TABLE_PRESET_OUTERINNER", "Outer Border Without Changing Inner Lines") +#define RID_SVXSTR_PARA_PRESET_DIAGONAL NC_("RID_SVXSTR_PARA_PRESET_DIAGONAL", "Diagonal Lines Only") +#define RID_SVXSTR_PARA_PRESET_DIAGONALDOWN NC_("RID_SVXSTR_PARA_PRESET_DIAGONALDOWN", "Diagonal Down Border") +#define RID_SVXSTR_PARA_PRESET_DIAGONALUP NC_("RID_SVXSTR_PARA_PRESET_DIAGONALUP", "Diagonal Up Border") +#define RID_SVXSTR_PARA_PRESET_CRISSCROSS NC_("RID_SVXSTR_PARA_PRESET_CRISSCROSS", "Criss-Cross Border") +#define RID_SVXSTR_PARA_PRESET_ALL NC_("RID_SVXSTR_PARA_PRESET_ALL", "All Four Borders") +#define RID_SVXSTR_PARA_PRESET_LEFTRIGHT NC_("RID_SVXSTR_PARA_PRESET_LEFTRIGHT", "Left and Right Borders Only") +#define RID_SVXSTR_PARA_PRESET_TOPBOTTOM NC_("RID_SVXSTR_PARA_PRESET_TOPBOTTOM", "Top and Bottom Borders Only") +#define RID_SVXSTR_PARA_PRESET_TOPBOTTOMHORI NC_("RID_SVXSTR_PARA_PRESET_TOPBOTTOMHORI", "Top and Bottom Borders, and All Horizontal Lines") +#define RID_SVXSTR_PARA_PRESET_ONLYLEFT NC_("RID_SVXSTR_PARA_PRESET_ONLYLEFT", "Left Border Only") +#define RID_SVXSTR_PARA_PRESET_ONLYRIGHT NC_("RID_SVXSTR_PARA_PRESET_ONLYRIGHT", "Right Border Only") +#define RID_SVXSTR_PARA_PRESET_ONLYTOP NC_("RID_SVXSTR_PARA_PRESET_ONLYTOP", "Top Border Only") +#define RID_SVXSTR_PARA_PRESET_ONLYTBOTTOM NC_("RID_SVXSTR_PARA_PRESET_ONLYTBOTTOM", "Bottom Border Only") +#define RID_SVXSTR_HOR_PRESET_ONLYHOR NC_("RID_SVXSTR_HOR_PRESET_ONLYHOR", "Top and Bottom Borders, and All Inner Lines") +#define RID_SVXSTR_VER_PRESET_ONLYVER NC_("RID_SVXSTR_VER_PRESET_ONLYVER", "Left and Right Borders, and All Inner Lines") #endif diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 87c5d297002a..9626071fd0b1 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5920,39 +5920,39 @@ void Test::testDiagonalBorders() const editeng::SvxBorderLine* pLine; const ScPatternAttr* pPat; - // diagonal left border - ::editeng::SvxBorderLine dLeftBorderLine( nullptr, 1 ); - SvxLineItem dLeftLineItem( ATTR_BORDER_TLBR ); - dLeftLineItem.SetLine(&dLeftBorderLine); + // diagonal down border + ::editeng::SvxBorderLine dDownBorderLine(nullptr, 1); + SvxLineItem dDownLineItem(ATTR_BORDER_TLBR); + dDownLineItem.SetLine(&dDownBorderLine); - // set diagonal left border to cell(A1) - m_pDoc->ApplyAttr(0, 0, 0, dLeftLineItem); + // set diagonal down border to cell(A1) + m_pDoc->ApplyAttr(0, 0, 0, dDownLineItem); aPos = { 0, 0, 0 }; pPat = m_pDoc->GetPattern(aPos); CPPUNIT_ASSERT(pPat); pLine = pPat->GetItem(ATTR_BORDER_TLBR).GetLine(); - CPPUNIT_ASSERT_MESSAGE("Diagonal left border was expected, but not found!", pLine); + CPPUNIT_ASSERT_MESSAGE("Diagonal down border was expected, but not found!", pLine); - // diagonal right border - ::editeng::SvxBorderLine dRightBorderLine( nullptr, 1 ); - SvxLineItem dRightLineItem( ATTR_BORDER_BLTR ); - dRightLineItem.SetLine(&dRightBorderLine); + // diagonal up border + ::editeng::SvxBorderLine dUpBorderLine(nullptr, 1); + SvxLineItem dUpLineItem(ATTR_BORDER_BLTR); + dUpLineItem.SetLine(&dUpBorderLine); - // set diagonal right border to cell(A2) - m_pDoc->ApplyAttr(0, 1, 0, dRightLineItem); + // set diagonal up border to cell(A2) + m_pDoc->ApplyAttr(0, 1, 0, dUpLineItem); aPos = { 0, 1, 0 }; pPat = m_pDoc->GetPattern(aPos); CPPUNIT_ASSERT(pPat); pLine = pPat->GetItem(ATTR_BORDER_BLTR).GetLine(); - CPPUNIT_ASSERT_MESSAGE("Diagonal right border was expected, but not found!", pLine); + CPPUNIT_ASSERT_MESSAGE("Diagonal up border was expected, but not found!", pLine); - // diagonal left and right border in the same cell (A5) - m_pDoc->ApplyAttr(0, 4, 0, dLeftLineItem); - m_pDoc->ApplyAttr(0, 4, 0, dRightLineItem); + // diagonal down and up border in the same cell (A5) + m_pDoc->ApplyAttr(0, 4, 0, dDownLineItem); + m_pDoc->ApplyAttr(0, 4, 0, dUpLineItem); // test if both borders are applied successfully in the same cell (A5) aPos = { 0, 4, 0 }; @@ -5960,25 +5960,25 @@ void Test::testDiagonalBorders() CPPUNIT_ASSERT(pPat); pLine = pPat->GetItem(ATTR_BORDER_TLBR).GetLine(); - CPPUNIT_ASSERT_MESSAGE("Diagonal left border was expected, but not found!", pLine); + CPPUNIT_ASSERT_MESSAGE("Diagonal down border was expected, but not found!", pLine); pLine = pPat->GetItem(ATTR_BORDER_BLTR).GetLine(); - CPPUNIT_ASSERT_MESSAGE("Diagonal right border was expected, but not found!", pLine); + CPPUNIT_ASSERT_MESSAGE("Diagonal up border was expected, but not found!", pLine); // test if both borders are removed successfully - dLeftLineItem.SetLine(nullptr); - dRightLineItem.SetLine(nullptr); + dDownLineItem.SetLine(nullptr); + dUpLineItem.SetLine(nullptr); // SetLine(nullptr) should remove the lines from (A5) - m_pDoc->ApplyAttr(0, 4, 0, dLeftLineItem); - m_pDoc->ApplyAttr(0, 4, 0, dRightLineItem); + m_pDoc->ApplyAttr(0, 4, 0, dDownLineItem); + m_pDoc->ApplyAttr(0, 4, 0, dUpLineItem); pPat = m_pDoc->GetPattern(aPos); CPPUNIT_ASSERT(pPat); pLine = pPat->GetItem(ATTR_BORDER_TLBR).GetLine(); - CPPUNIT_ASSERT_MESSAGE("Diagonal left border was not expected, but is found!", !pLine); + CPPUNIT_ASSERT_MESSAGE("Diagonal down border was not expected, but is found!", !pLine); pLine = pPat->GetItem(ATTR_BORDER_BLTR).GetLine(); - CPPUNIT_ASSERT_MESSAGE("Diagonal right border was not expected, but is found!", !pLine); + CPPUNIT_ASSERT_MESSAGE("Diagonal up border was not expected, but is found!", !pLine); m_pDoc->DeleteTab(0); } diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index a65e3281bd54..6dd380b31883 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -461,6 +461,9 @@ private: void CalcSizeValueSet(); DECL_LINK( SelectHdl, ValueSet*, void ); + void SetDiagonalDownBorder(const SvxLineItem& dDownLineItem); + void SetDiagonalUpBorder(const SvxLineItem& dUpLineItem); + public: SvxFrameWindow_Impl(SvxFrameToolBoxControl* pControl, weld::Widget* pParent); virtual void GrabFocus() override @@ -2171,8 +2174,8 @@ SvxFrameWindow_Impl::SvxFrameWindow_Impl(SvxFrameToolBoxControl* pControl, weld: /* * 1 2 3 4 5 * ------------------------------------------------------ - * NONE LEFT RIGHT LEFTRIGHT DIAGONALLEFT - * TOP BOTTOM TOPBOTTOM OUTER DIAGONALRIGHT + * NONE LEFT RIGHT LEFTRIGHT DIAGONALDOWN + * TOP BOTTOM TOPBOTTOM OUTER DIAGONALUP * ------------------------------------------------------ * HOR HORINNER VERINNER ALL CRISSCROSS <- can be switched of via bParagraphMode */ @@ -2223,13 +2226,15 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void) SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER ); SvxBorderLine theDefLine; - // diagonal left border - SvxBorderLine dLeftBorderLine( nullptr, 1 ); - SvxLineItem dLeftLineItem( SID_ATTR_BORDER_DIAG_TLBR ); + // diagonal down border + SvxBorderLine dDownBorderLine(nullptr, 1); + SvxLineItem dDownLineItem(SID_ATTR_BORDER_DIAG_TLBR); + + // diagonal up border + SvxBorderLine dUpBorderLine(nullptr, 1); + SvxLineItem dUpLineItem(SID_ATTR_BORDER_DIAG_BLTR); - // diagonal right border - SvxBorderLine dRightBorderLine( nullptr, 1 ); - SvxLineItem dRightLineItem( SID_ATTR_BORDER_DIAG_BLTR ); + bool bIsDiagonalBorder = false; SvxBorderLine *pLeft = nullptr, *pRight = nullptr, @@ -2245,8 +2250,10 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void) { case 1: nValidFlags |= FrmValidFlags::AllMask; // set nullptr to remove diagonal lines - dLeftLineItem.SetLine(nullptr); - dRightLineItem.SetLine(nullptr); + dDownLineItem.SetLine(nullptr); + dUpLineItem.SetLine(nullptr); + SetDiagonalDownBorder(dDownLineItem); + SetDiagonalUpBorder(dUpLineItem); break; // NONE case 2: pLeft = &theDefLine; nValidFlags |= FrmValidFlags::Left; @@ -2257,8 +2264,10 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void) case 4: pLeft = pRight = &theDefLine; nValidFlags |= FrmValidFlags::Right|FrmValidFlags::Left; break; // LEFTRIGHT - case 5: dLeftLineItem.SetLine(&dLeftBorderLine); - break; // DIAGONAL LEFT + case 5: dDownLineItem.SetLine(&dDownBorderLine); + SetDiagonalDownBorder(dDownLineItem); + bIsDiagonalBorder = true; + break; // DIAGONAL DOWN case 6: pTop = &theDefLine; nValidFlags |= FrmValidFlags::Top; break; // TOP @@ -2272,8 +2281,10 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void) nValidFlags |= FrmValidFlags::Left | FrmValidFlags::Right | FrmValidFlags::Top | FrmValidFlags::Bottom; break; // OUTER case 10: - dRightLineItem.SetLine(&dRightBorderLine); - break; // DIAGONAL RIGHT + dUpLineItem.SetLine(&dUpBorderLine); + SetDiagonalUpBorder(dUpLineItem); + bIsDiagonalBorder = true; + break; // DIAGONAL UP // Inner Table: case 11: // HOR @@ -2306,61 +2317,21 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void) case 15: // set both diagonal lines to draw criss-cross line - dLeftLineItem.SetLine(&dLeftBorderLine); - dRightLineItem.SetLine(&dRightBorderLine); - break; // CRISS-CROSS + dDownLineItem.SetLine(&dDownBorderLine); + dUpLineItem.SetLine(&dUpBorderLine); + + SetDiagonalDownBorder(dDownLineItem); + SetDiagonalUpBorder(dUpLineItem); + bIsDiagonalBorder = true; + break; // CRISS-CROSS default: break; } - if (nSel == 5) - { - // apply diagonal left border - Any a; - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = "BorderTLBR"; - dLeftLineItem.QueryValue( a ); - aArgs[0].Value = a; - - mxControl->dispatchCommand( ".uno:BorderTLBR", aArgs ); - } - else if (nSel == 10) - { - // apply diagonal right border - Any a; - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = "BorderBLTR"; - dRightLineItem.QueryValue( a ); - aArgs[0].Value = a; - - mxControl->dispatchCommand( ".uno:BorderBLTR", aArgs ); - } - else if (nSel == 15) - { - // to draw criss-cross line, - // we need to set diagonal left and - // diagonal right border together - - // apply diagonal left border (TLBR) - Any aLeft; - Sequence< PropertyValue > aArgsTLBR( 1 ); - aArgsTLBR[0].Name = "BorderTLBR"; - dLeftLineItem.QueryValue( aLeft ); - aArgsTLBR[0].Value = aLeft; - - // apply diagonal right border (BLTR) - Any aRight; - Sequence< PropertyValue > aArgsBLTR( 1 ); - aArgsBLTR[0].Name = "BorderBLTR"; - dRightLineItem.QueryValue( aRight ); - aArgsBLTR[0].Value = aRight; - - // execute dispatchCommand for both of them - mxControl->dispatchCommand( ".uno:BorderTLBR", aArgsTLBR ); - mxControl->dispatchCommand( ".uno:BorderBLTR", aArgsBLTR ); - } - else + // if diagonal borders selected, + // no need to execute this block + if (!bIsDiagonalBorder) { aBorderOuter.SetLine( pLeft, SvxBoxItemLine::LEFT ); aBorderOuter.SetLine( pRight, SvxBoxItemLine::RIGHT ); @@ -2378,35 +2349,6 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void) aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISTANCE ); aBorderInner.SetValid( SvxBoxInfoItemValidFlags::DISABLE, false ); - // if nSel == 1, we should remove all lines from the cell. - // additionally, we should remove diagonal borders here, - // because diagonal left and right borders are NOT - // the member of aBorderOuter and aBorderInner. - if (nSel == 1) - { - // remove left diagonal line - { - Any a; - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = "BorderTLBR"; - dLeftLineItem.QueryValue( a ); - aArgs[0].Value = a; - - mxControl->dispatchCommand( ".uno:BorderTLBR", aArgs ); - } - - // remove right diagonal line - { - Any a; - Sequence< PropertyValue > aArgs( 1 ); - aArgs[0].Name = "BorderBLTR"; - dRightLineItem.QueryValue( a ); - aArgs[0].Value = a; - - mxControl->dispatchCommand( ".uno:BorderBLTR", aArgs ); - } - } - Any a; Sequence< PropertyValue > aArgs( 2 ); aArgs[0].Name = "OuterBorder"; @@ -2430,6 +2372,30 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void) mxControl->EndPopupMode(); } +void SvxFrameWindow_Impl::SetDiagonalDownBorder(const SvxLineItem& dDownLineItem) +{ + // apply diagonal down border + Any a; + Sequence<PropertyValue> aArgs(1); + aArgs[0].Name = "BorderTLBR"; + dDownLineItem.QueryValue(a); + aArgs[0].Value = a; + + mxControl->dispatchCommand(".uno:BorderTLBR", aArgs); +} + +void SvxFrameWindow_Impl::SetDiagonalUpBorder(const SvxLineItem& dUpLineItem) +{ + // apply diagonal up border + Any a; + Sequence<PropertyValue> aArgs(1); + aArgs[0].Name = "BorderBLTR"; + dUpLineItem.QueryValue(a); + aArgs[0].Value = a; + + mxControl->dispatchCommand(".uno:BorderBLTR", aArgs); +} + void SvxFrameWindow_Impl::statusChanged( const css::frame::FeatureStateEvent& rEvent ) { if ( rEvent.FeatureURL.Complete != ".uno:BorderReducedMode" ) @@ -2483,13 +2449,13 @@ void SvxFrameWindow_Impl::InitImageList() {BitmapEx(RID_SVXBMP_FRAME2), SvxResId(RID_SVXSTR_PARA_PRESET_ONLYLEFT)}, {BitmapEx(RID_SVXBMP_FRAME3), SvxResId(RID_SVXSTR_PARA_PRESET_ONLYRIGHT)}, {BitmapEx(RID_SVXBMP_FRAME4), SvxResId(RID_SVXSTR_PARA_PRESET_LEFTRIGHT)}, - {BitmapEx(RID_SVXBMP_FRAME14), SvxResId(RID_SVXSTR_PARA_PRESET_DIAGONALLEFT)}, // diagonal left border + {BitmapEx(RID_SVXBMP_FRAME14), SvxResId(RID_SVXSTR_PARA_PRESET_DIAGONALDOWN)}, // diagonal down border {BitmapEx(RID_SVXBMP_FRAME5), SvxResId(RID_SVXSTR_PARA_PRESET_ONLYTOP)}, {BitmapEx(RID_SVXBMP_FRAME6), SvxResId(RID_SVXSTR_PARA_PRESET_ONLYTBOTTOM)}, {BitmapEx(RID_SVXBMP_FRAME7), SvxResId(RID_SVXSTR_PARA_PRESET_TOPBOTTOM)}, {BitmapEx(RID_SVXBMP_FRAME8), SvxResId(RID_SVXSTR_TABLE_PRESET_ONLYOUTER)}, - {BitmapEx(RID_SVXBMP_FRAME13), SvxResId(RID_SVXSTR_PARA_PRESET_DIAGONALRIGHT)}, // diagonal right border + {BitmapEx(RID_SVXBMP_FRAME13), SvxResId(RID_SVXSTR_PARA_PRESET_DIAGONALUP)}, // diagonal up border {BitmapEx(RID_SVXBMP_FRAME9), SvxResId(RID_SVXSTR_PARA_PRESET_TOPBOTTOMHORI)}, {BitmapEx(RID_SVXBMP_FRAME10), SvxResId(RID_SVXSTR_TABLE_PRESET_OUTERHORI)}, |