diff options
author | Gulsah Kose <gulsah.1004@gmail.com> | 2016-08-11 10:40:19 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2016-09-07 21:31:27 +0300 |
commit | 37a3fc1ca2a08e41dcf39946d891e7e315106d64 (patch) | |
tree | 409636f6aafd802d9d810513f533804e900f2787 /sw | |
parent | f10549961983b10148ba9ffe91a5e6c19bde909f (diff) |
tdf#101390 Add Arrows toolbox functions on writer drawingbar.
Writer arrows toolbox includes following commands
.uno:LineArrowEnd
.uno:LineCircleArrow
.uno:LineSquareArrow
.uno:LineArrows
.uno:LineArrowStart
.uno:LineArrowCircle
.uno:LineArrowSquare
.uno:Line
Change-Id: I91af27826ea411eabfa61c11962cfb85d2d2aab2
Reviewed-on: https://gerrit.libreoffice.org/28363
Signed-off-by: Gulsah Kose <gulsah.1004@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/UIConfig_swriter.mk | 1 | ||||
-rw-r--r-- | sw/inc/fesh.hxx | 1 | ||||
-rw-r--r-- | sw/sdi/viewsh.sdi | 39 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 176 | ||||
-rw-r--r-- | sw/source/uibase/ribbar/conrect.cxx | 31 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewdraw.cxx | 7 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewstat.cxx | 8 | ||||
-rw-r--r-- | sw/uiconfig/swriter/toolbar/arrowsbar.xml | 30 | ||||
-rw-r--r-- | sw/uiconfig/swriter/toolbar/drawbar.xml | 1 |
9 files changed, 288 insertions, 6 deletions
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index ad698ec57b0d..b91c4ddc57e9 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -36,6 +36,7 @@ $(eval $(call gb_UIConfig_add_statusbarfiles,modules/swriter,\ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/swriter,\ sw/uiconfig/swriter/toolbar/alignmentbar \ + sw/uiconfig/swriter/toolbar/arrowsbar \ sw/uiconfig/swriter/toolbar/arrowshapes \ sw/uiconfig/swriter/toolbar/basicshapes \ sw/uiconfig/swriter/toolbar/bezierobjectbar \ diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 2a868a0b6f91..20eb7c903e77 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -814,6 +814,7 @@ public: const Point& _rDocPos ); void ToggleHeaderFooterEdit( ); + static void SetLineEnds(SfxItemSet& rAttr, SdrObject* pObj, sal_uInt16 nSlotId); }; void ClearFEShellTabCols(); diff --git a/sw/sdi/viewsh.sdi b/sw/sdi/viewsh.sdi index d43ffb8f8c6d..e93cad9f66db 100644 --- a/sw/sdi/viewsh.sdi +++ b/sw/sdi/viewsh.sdi @@ -82,6 +82,45 @@ interface TextEditView : BaseTextEditView 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 ; diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 66302da6e940..5adc6cd9dc8a 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -30,12 +30,19 @@ #include <svx/sxciaitm.hxx> #include <svx/xfillit.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 <sfx2/app.hxx> #include <editeng/boxitem.hxx> #include <editeng/opaqitem.hxx> #include <editeng/protitem.hxx> #include <svx/svdpage.hxx> #include <svx/svdpagv.hxx> +#include <svx/dialmgr.hxx> #include <tools/globname.hxx> #include <IDocumentSettingAccess.hxx> #include <DocumentSettingManager.hxx> @@ -86,6 +93,7 @@ #include <sfx2/lokhelper.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <calbck.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> #include <com/sun/star/embed/EmbedMisc.hpp> #include <com/sun/star/embed/Aspects.hpp> @@ -94,6 +102,38 @@ using namespace com::sun::star; +/** + * 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; +} + +} + SwFlyFrame *GetFlyFromMarked( const SdrMarkList *pLst, SwViewShell *pSh ) { if ( !pLst ) @@ -848,6 +888,138 @@ static void lcl_NotifyNeighbours( const SdrMarkList *pLst ) } } +void SwFEShell::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 = 100; // (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; + } + } +} + void SwFEShell::SelectionToTop( bool bTop ) { OSL_ENSURE( Imp()->HasDrawView(), "SelectionToTop without DrawView?" ); @@ -2839,6 +3011,10 @@ long SwFEShell::GetSectionWidth( SwFormat const & rFormat ) const aTempPoly.append(basegfx::B2DPoint(aRect.TopLeft().getX(), nYMiddle)); aTempPoly.append(basegfx::B2DPoint(aRect.BottomRight().getX(), nYMiddle)); aPoly.append(aTempPoly); + + SfxItemSet aAttr(pObj->GetModel()->GetItemPool()); + SetLineEnds(aAttr, pObj, nSlotId); + pObj->SetMergedItemSet(aAttr); } break; } diff --git a/sw/source/uibase/ribbar/conrect.cxx b/sw/source/uibase/ribbar/conrect.cxx index 14465603fcca..aef87a5c4c20 100644 --- a/sw/source/uibase/ribbar/conrect.cxx +++ b/sw/source/uibase/ribbar/conrect.cxx @@ -49,16 +49,28 @@ bool ConstRectangle::MouseButtonDown(const MouseEvent& rMEvt) { bool bReturn; - if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) - && m_pWin->GetSdrDrawMode() == OBJ_CAPTION) + if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt))) { - m_pView->NoRotate(); - if (m_pView->IsDrawSelMode()) + if (m_pWin->GetSdrDrawMode() == OBJ_CAPTION) { - m_pView->FlipDrawSelMode(); - m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode()); + m_pView->NoRotate(); + if (m_pView->IsDrawSelMode()) + { + m_pView->FlipDrawSelMode(); + m_pSh->GetDrawView()->SetFrameDragSingles(m_pView->IsDrawSelMode()); + } + } + + SdrObject* pObj = m_pView->GetDrawView()->GetCreateObj(); + + if (pObj) + { + SfxItemSet aAttr(pObj->GetModel()->GetItemPool()); + m_pSh->SetLineEnds(aAttr, pObj, m_nSlotId); + pObj->SetMergedItemSet(aAttr); } } + return bReturn; } @@ -146,6 +158,13 @@ void ConstRectangle::Activate(const sal_uInt16 nSlotId) switch (nSlotId) { + 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_LINE: m_pWin->SetSdrDrawMode(OBJ_LINE); break; diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx index 44483341efad..c45467254110 100644 --- a/sw/source/uibase/uiview/viewdraw.cxx +++ b/sw/source/uibase/uiview/viewdraw.cxx @@ -245,6 +245,13 @@ void SwView::ExecDraw(SfxRequest& rReq) m_sDrawCustom.clear(); break; + 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_LINE: case SID_DRAW_RECT: case SID_DRAW_ELLIPSE: diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx index b14e3f2de30a..e468c7eaa3f9 100644 --- a/sw/source/uibase/uiview/viewstat.cxx +++ b/sw/source/uibase/uiview/viewstat.cxx @@ -483,6 +483,13 @@ void SwView::GetDrawState(SfxItemSet &rSet) switch(nWhich) { 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_XPOLYGON_NOFILL: @@ -525,6 +532,7 @@ void SwView::GetDrawState(SfxItemSet &rSet) case SID_INSERT_DRAW: case SID_FONTWORK_GALLERY_FLOATER : + case SID_DRAWTBX_ARROWS: { if ( bWeb ) rSet.DisableItem( nWhich ); diff --git a/sw/uiconfig/swriter/toolbar/arrowsbar.xml b/sw/uiconfig/swriter/toolbar/arrowsbar.xml new file mode 100644 index 000000000000..5ec4d8a8ec35 --- /dev/null +++ b/sw/uiconfig/swriter/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/sw/uiconfig/swriter/toolbar/drawbar.xml b/sw/uiconfig/swriter/toolbar/drawbar.xml index cb002a4ca0a8..e37821d8fd8d 100644 --- a/sw/uiconfig/swriter/toolbar/drawbar.xml +++ b/sw/uiconfig/swriter/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_Unfilled" toolbar:helpid="10464" toolbar:visible="false"/> <toolbar:toolbaritem xlink:href=".uno:Freeline" toolbar:visible="false"/> |