diff options
author | Gulsah Kose <gulsah.1004@gmail.com> | 2016-09-19 12:43:34 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2016-09-25 06:59:32 +0000 |
commit | 7b8832ff972a4e9f3e03fd7d96882b2a78c03b3e (patch) | |
tree | 2e92f8b101d2e81dad3c1755d2120864c2b26ca0 | |
parent | 1a4555f3b3572f398c33bffd1ed2a40705431733 (diff) |
tdf#101390 Add Arrows toolbox functions on calc drawingbar.
Calc arrows toolbox includes following commands
.uno:LineArrowEnd
.uno:LineCircleArrow
.uno:LineSquareArrow
.uno:LineArrows
.uno:LineArrowStart
.uno:LineArrowCircle
.uno:LineArrowSquare
.uno:Line
Change-Id: I09c93447baeafd3f7d4993117458d4585d21cbaf
Signed-off-by: Gulsah Kose <gulsah.1004@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/29021
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu | 11 | ||||
-rw-r--r-- | sc/UIConfig_scalc.mk | 1 | ||||
-rw-r--r-- | sc/sdi/tabvwsh.sdi | 8 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/fuconrec.cxx | 199 | ||||
-rw-r--r-- | sc/source/ui/inc/fuconrec.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh2.cxx | 14 | ||||
-rw-r--r-- | sc/uiconfig/scalc/toolbar/arrowsbar.xml | 30 | ||||
-rw-r--r-- | sc/uiconfig/scalc/toolbar/drawbar.xml | 1 |
8 files changed, 265 insertions, 0 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu index ddb27a84abc9..0a797cdd0e07 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu @@ -717,6 +717,17 @@ <value>false</value> </prop> </node> + <node oor:name="private:resource/toolbar/arrowsbar" oor:op="replace"> + <prop oor:name="Docked" oor:type="xs:boolean"> + <value>false</value> + </prop> + <prop oor:name="UIName" oor:type="xs:string"> + <value xml:lang="en-US">Arrows</value> + </prop> + <prop oor:name="Visible" oor:type="xs:boolean"> + <value>false</value> + </prop> + </node> </node> </node> </oor:component-data> diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 707936d01cfb..d05aa663ab80 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -50,6 +50,7 @@ $(eval $(call gb_UIConfig_add_statusbarfiles,modules/scalc,\ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/scalc,\ sc/uiconfig/scalc/toolbar/alignmentbar \ + sc/uiconfig/scalc/toolbar/arrowsbar \ sc/uiconfig/scalc/toolbar/arrowshapes \ sc/uiconfig/scalc/toolbar/basicshapes \ sc/uiconfig/scalc/toolbar/calloutshapes \ diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi index 46859c5807f3..91e92c9a4fd1 100644 --- a/sc/sdi/tabvwsh.sdi +++ b/sc/sdi/tabvwsh.sdi @@ -88,6 +88,14 @@ interface BaseSelection SID_OBJECT_SELECT [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] SID_DRAW_LINE [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] + SID_LINE_ARROW_END [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] + SID_LINE_ARROW_CIRCLE [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] + SID_LINE_ARROW_SQUARE [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] + SID_LINE_ARROW_START [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] + SID_LINE_CIRCLE_ARROW [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] + SID_LINE_SQUARE_ARROW [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] + SID_LINE_ARROWS [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] + SID_DRAWTBX_ARROWS [ StateMethod = GetDrawState; ] SID_DRAW_RECT [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] SID_DRAW_ELLIPSE [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ] SID_DRAWTBX_LINES [ StateMethod = GetDrawState; ] diff --git a/sc/source/ui/drawfunc/fuconrec.cxx b/sc/source/ui/drawfunc/fuconrec.cxx index c7563cd91e50..310b114f5961 100644 --- a/sc/source/ui/drawfunc/fuconrec.cxx +++ b/sc/source/ui/drawfunc/fuconrec.cxx @@ -26,6 +26,15 @@ // Create default drawing objects via keyboard #include <svx/svdopath.hxx> #include <svx/svdocapt.hxx> +#include <svx/dialogs.hrc> +#include <svx/xlnwtit.hxx> +#include <svx/xlnstwit.hxx> +#include <svx/xlnedwit.hxx> +#include <svx/xlnedit.hxx> +#include <svx/xlnstit.hxx> +#include <svx/dialmgr.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> + #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/point/b2dpoint.hxx> @@ -53,6 +62,38 @@ FuConstRectangle::~FuConstRectangle() { } +/** + * set line starts and ends for the object to be created + */ + +namespace { + +::basegfx::B2DPolyPolygon getPolygon( sal_uInt16 nResId, SdrModel* pDoc ) +{ + ::basegfx::B2DPolyPolygon aRetval; + XLineEndListRef pLineEndList = pDoc->GetLineEndList(); + + if( pLineEndList.is() ) + { + OUString aArrowName( SVX_RES(nResId) ); + long nCount = pLineEndList->Count(); + long nIndex; + for( nIndex = 0L; nIndex < nCount; nIndex++ ) + { + const XLineEndEntry* pEntry = pLineEndList->GetLineEnd(nIndex); + if( pEntry->GetName() == aArrowName ) + { + aRetval = pEntry->GetLineEnd(); + break; + } + } + } + + return aRetval; +} + +} + /************************************************************************* |* |* MouseButtonDown-event @@ -86,6 +127,16 @@ bool FuConstRectangle::MouseButtonDown(const MouseEvent& rMEvt) } else bReturn = pView->BegCreateObj(aPos); + + SdrObject* pObj = pView->GetCreateObj(); + + if (pObj) + { + SfxItemSet aAttr(pObj->GetModel()->GetItemPool()); + SetLineEnds(aAttr, pObj, aSfxRequest.GetSlot()); + pObj->SetMergedItemSet(aAttr); + } + if ( bReturn ) pView->GetCreateObj()->SetGridOffset( aGridOff ); } @@ -144,6 +195,13 @@ void FuConstRectangle::Activate() switch (aSfxRequest.GetSlot() ) { case SID_DRAW_LINE: + case SID_LINE_ARROW_END: + case SID_LINE_ARROW_CIRCLE: + case SID_LINE_ARROW_SQUARE: + case SID_LINE_ARROW_START: + case SID_LINE_CIRCLE_ARROW: + case SID_LINE_SQUARE_ARROW: + case SID_LINE_ARROWS: aNewPointer = Pointer( PointerStyle::DrawLine ); aObjKind = OBJ_LINE; break; @@ -178,6 +236,139 @@ void FuConstRectangle::Activate() FuConstruct::Activate(); } +void FuConstRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject* pObj, sal_uInt16 nSlotId) +{ + SdrModel *pDoc = pObj->GetModel(); + + if ( nSlotId == SID_LINE_ARROW_START || + nSlotId == SID_LINE_ARROW_END || + nSlotId == SID_LINE_ARROWS || + nSlotId == SID_LINE_ARROW_CIRCLE || + nSlotId == SID_LINE_CIRCLE_ARROW || + nSlotId == SID_LINE_ARROW_SQUARE || + nSlotId == SID_LINE_SQUARE_ARROW ) + { + + // set attributes of line start and ends + + // arrowhead + ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDoc ) ); + if( !aArrow.count() ) + { + ::basegfx::B2DPolygon aNewArrow; + aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0)); + aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0)); + aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0)); + aNewArrow.setClosed(true); + aArrow.append(aNewArrow); + } + + // Circles + ::basegfx::B2DPolyPolygon aCircle( getPolygon( RID_SVXSTR_CIRCLE, pDoc ) ); + if( !aCircle.count() ) + { + ::basegfx::B2DPolygon aNewCircle; + aNewCircle = ::basegfx::tools::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0); + aNewCircle.setClosed(true); + aCircle.append(aNewCircle); + } + + // Square + ::basegfx::B2DPolyPolygon aSquare( getPolygon( RID_SVXSTR_SQUARE, pDoc ) ); + if( !aSquare.count() ) + { + ::basegfx::B2DPolygon aNewSquare; + aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0)); + aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0)); + aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0)); + aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0)); + aNewSquare.setClosed(true); + aSquare.append(aNewSquare); + } + + SfxItemSet aSet( pDoc->GetItemPool() ); + long nWidth = 200; // (1/100th mm) + + // determine line width and calculate with it the line end width + if( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE ) + { + long nValue = static_cast<const XLineWidthItem&>( aSet.Get( XATTR_LINEWIDTH ) ).GetValue(); + if( nValue > 0 ) + nWidth = nValue * 3; + } + + switch (nSlotId) + { + case SID_LINE_ARROWS: + { + // connector with arrow ends + rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow)); + rAttr.Put(XLineStartWidthItem(nWidth)); + rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow)); + rAttr.Put(XLineEndWidthItem(nWidth)); + } + break; + + case SID_LINE_ARROW_START: + case SID_LINE_ARROW_CIRCLE: + case SID_LINE_ARROW_SQUARE: + { + // connector with arrow start + rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow)); + rAttr.Put(XLineStartWidthItem(nWidth)); + } + break; + + case SID_LINE_ARROW_END: + case SID_LINE_CIRCLE_ARROW: + case SID_LINE_SQUARE_ARROW: + { + // connector with arrow end + rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_ARROW), aArrow)); + rAttr.Put(XLineEndWidthItem(nWidth)); + } + break; + } + + // and again, for the still missing ends + switch (nSlotId) + { + case SID_LINE_ARROW_CIRCLE: + { + // circle end + rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle)); + rAttr.Put(XLineEndWidthItem(nWidth)); + } + break; + + case SID_LINE_CIRCLE_ARROW: + { + // circle start + rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_CIRCLE), aCircle)); + rAttr.Put(XLineStartWidthItem(nWidth)); + } + break; + + case SID_LINE_ARROW_SQUARE: + { + // square end + rAttr.Put(XLineEndItem(SVX_RESSTR(RID_SVXSTR_SQUARE), aSquare)); + rAttr.Put(XLineEndWidthItem(nWidth)); + } + break; + + case SID_LINE_SQUARE_ARROW: + { + // square start + rAttr.Put(XLineStartItem(SVX_RESSTR(RID_SVXSTR_SQUARE), aSquare)); + rAttr.Put(XLineStartWidthItem(nWidth)); + } + break; + } + } +} + + /************************************************************************* |* |* Function deaktivieren @@ -206,6 +397,13 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const Rec switch(nID) { case SID_DRAW_LINE: + case SID_LINE_ARROW_END: + case SID_LINE_ARROW_CIRCLE: + case SID_LINE_ARROW_SQUARE: + case SID_LINE_ARROW_START: + case SID_LINE_CIRCLE_ARROW: + case SID_LINE_SQUARE_ARROW: + case SID_LINE_ARROWS: { if(dynamic_cast<const SdrPathObj*>( pObj) != nullptr) { @@ -264,6 +462,7 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const Rec } SfxItemSet aAttr(pDrDoc->GetItemPool()); + SetLineEnds(aAttr, pObj, nID); pObj->SetMergedItemSet(aAttr); } diff --git a/sc/source/ui/inc/fuconrec.hxx b/sc/source/ui/inc/fuconrec.hxx index 72885d307b88..d69d0e3def20 100644 --- a/sc/source/ui/inc/fuconrec.hxx +++ b/sc/source/ui/inc/fuconrec.hxx @@ -36,6 +36,7 @@ class FuConstRectangle : public FuConstruct virtual void Activate() override; virtual void Deactivate() override; + static void SetLineEnds(SfxItemSet& rAttr, SdrObject* pObj, sal_uInt16 nSlotId); // Create default drawing objects via keyboard virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle) override; diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx index b81fc422d355..f1a0f48b967a 100644 --- a/sc/source/ui/view/tabvwsh2.cxx +++ b/sc/source/ui/view/tabvwsh2.cxx @@ -218,6 +218,13 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) break; case SID_DRAW_LINE: + case SID_LINE_ARROW_END: + case SID_LINE_ARROW_CIRCLE: + case SID_LINE_ARROW_SQUARE: + case SID_LINE_ARROW_START: + case SID_LINE_CIRCLE_ARROW: + case SID_LINE_SQUARE_ARROW: + case SID_LINE_ARROWS: case SID_DRAW_RECT: case SID_DRAW_ELLIPSE: pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, rReq)); @@ -361,6 +368,13 @@ void ScTabViewShell::GetDrawState(SfxItemSet &rSet) break; case SID_DRAW_LINE: + case SID_LINE_ARROW_END: + case SID_LINE_ARROW_CIRCLE: + case SID_LINE_ARROW_SQUARE: + case SID_LINE_ARROW_START: + case SID_LINE_CIRCLE_ARROW: + case SID_LINE_SQUARE_ARROW: + case SID_LINE_ARROWS: case SID_DRAW_RECT: case SID_DRAW_ELLIPSE: case SID_DRAW_POLYGON: diff --git a/sc/uiconfig/scalc/toolbar/arrowsbar.xml b/sc/uiconfig/scalc/toolbar/arrowsbar.xml new file mode 100644 index 000000000000..5ec4d8a8ec35 --- /dev/null +++ b/sc/uiconfig/scalc/toolbar/arrowsbar.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd"> +<!-- + * This file is part of the LibreOffice project. + * + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * 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 . +--> +<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar"> + <toolbar:toolbaritem xlink:href=".uno:LineArrowEnd"/> + <toolbar:toolbaritem xlink:href=".uno:LineCircleArrow"/> + <toolbar:toolbaritem xlink:href=".uno:LineSquareArrow"/> + <toolbar:toolbaritem xlink:href=".uno:LineArrows"/> + <toolbar:toolbarbreak/> + <toolbar:toolbaritem xlink:href=".uno:LineArrowStart"/> + <toolbar:toolbaritem xlink:href=".uno:LineArrowCircle"/> + <toolbar:toolbaritem xlink:href=".uno:LineArrowSquare"/> + <toolbar:toolbaritem xlink:href=".uno:Line"/> +</toolbar:toolbar> diff --git a/sc/uiconfig/scalc/toolbar/drawbar.xml b/sc/uiconfig/scalc/toolbar/drawbar.xml index fef6c7efe85b..3c6ba264dbbe 100644 --- a/sc/uiconfig/scalc/toolbar/drawbar.xml +++ b/sc/uiconfig/scalc/toolbar/drawbar.xml @@ -21,6 +21,7 @@ <toolbar:toolbaritem xlink:href=".uno:SelectObject" toolbar:helpid="10128"/> <toolbar:toolbarseparator/> <toolbar:toolbaritem xlink:href=".uno:Line" toolbar:helpid="10102"/> + <toolbar:toolbaritem xlink:href=".uno:ArrowsToolbox"/> <toolbar:toolbaritem xlink:href=".uno:LineToolbox"/> <toolbar:toolbaritem xlink:href=".uno:Freeline" toolbar:visible="false"/> <toolbar:toolbaritem xlink:href=".uno:Bezier_Unfilled" toolbar:helpid="10397" toolbar:visible="false"/> |