2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 20:25:33 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2004-10-12 12:09:56 +00:00
|
|
|
|
|
|
|
#include "fuconcs.hxx"
|
|
|
|
#include <svx/svdpagv.hxx>
|
|
|
|
|
|
|
|
#include <svx/svxids.hrc>
|
|
|
|
#include <svx/dialogs.hrc>
|
|
|
|
#include <svx/dialmgr.hxx>
|
|
|
|
|
|
|
|
#include "app.hrc"
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/aeitem.hxx>
|
2004-10-12 12:09:56 +00:00
|
|
|
#include <svx/xlnstwit.hxx>
|
|
|
|
#include <svx/xlnedwit.hxx>
|
|
|
|
#include <svx/xlnedit.hxx>
|
|
|
|
#include <svx/xlnstit.hxx>
|
|
|
|
#include <svx/xlnwtit.hxx>
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#include <svx/sdtmfitm.hxx>
|
|
|
|
#include <svx/sxekitm.hxx>
|
|
|
|
#include <svx/sderitm.hxx>
|
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#include <svx/svdopath.hxx>
|
|
|
|
#include <svx/svdocirc.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/intitem.hxx>
|
2004-10-12 12:09:56 +00:00
|
|
|
#include <sfx2/request.hxx>
|
2013-02-12 13:41:53 -05:00
|
|
|
#include <editeng/adjustitem.hxx>
|
2004-10-12 12:09:56 +00:00
|
|
|
#include <svx/xtable.hxx>
|
|
|
|
#include <svx/sdasitm.hxx>
|
|
|
|
#include <svx/svdoashp.hxx>
|
|
|
|
#include <svx/sdtagitm.hxx>
|
|
|
|
|
|
|
|
#include <svx/svdocapt.hxx>
|
|
|
|
|
|
|
|
#include <svx/svdomeas.hxx>
|
|
|
|
#include "ViewShell.hxx"
|
2006-03-21 16:16:40 +00:00
|
|
|
#include "ViewShellBase.hxx"
|
|
|
|
#include "ToolBarManager.hxx"
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/writingmodeitem.hxx>
|
2004-10-12 12:09:56 +00:00
|
|
|
#include <svx/gallery.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itempool.hxx>
|
2004-10-12 12:09:56 +00:00
|
|
|
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "View.hxx"
|
|
|
|
#include "sdpage.hxx"
|
|
|
|
#include "Window.hxx"
|
|
|
|
#include "stlpool.hxx"
|
|
|
|
#include "drawdoc.hxx"
|
|
|
|
#include "res_bmp.hrc"
|
|
|
|
#include "glob.hrc"
|
|
|
|
|
|
|
|
namespace sd {
|
|
|
|
|
|
|
|
|
|
|
|
FuConstructCustomShape::FuConstructCustomShape (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq ) :
|
|
|
|
FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
|
|
|
|
{
|
2005-12-14 15:55:59 +00:00
|
|
|
}
|
|
|
|
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> FuConstructCustomShape::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
|
2005-12-14 15:55:59 +00:00
|
|
|
{
|
|
|
|
FuConstructCustomShape* pFunc;
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructCustomShape( pViewSh, pWin, pView, pDoc, rReq ) );
|
2005-12-14 15:55:59 +00:00
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
pFunc->SetPermanent( bPermanent );
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuConstructCustomShape::DoExecute( SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
FuConstruct::DoExecute( rReq );
|
|
|
|
|
2004-10-12 12:09:56 +00:00
|
|
|
const SfxItemSet* pArgs = rReq.GetArgs();
|
|
|
|
if ( pArgs )
|
|
|
|
{
|
2014-10-29 11:04:25 +02:00
|
|
|
const SfxStringItem& rItm = static_cast<const SfxStringItem&>(pArgs->Get( rReq.GetSlot() ));
|
2004-10-12 12:09:56 +00:00
|
|
|
aCustomShape = rItm.GetValue();
|
|
|
|
}
|
2006-03-21 16:16:40 +00:00
|
|
|
|
2007-06-27 14:41:56 +00:00
|
|
|
mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
|
2006-03-21 16:16:40 +00:00
|
|
|
ToolBarManager::TBG_FUNCTION,
|
|
|
|
ToolBarManager::msDrawingObjectToolBar);
|
2004-10-12 12:09:56 +00:00
|
|
|
}
|
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
bool FuConstructCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
|
2004-10-12 12:09:56 +00:00
|
|
|
|
2006-12-12 16:15:21 +00:00
|
|
|
if ( rMEvt.IsLeft() && !mpView->IsAction() )
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2006-12-12 16:15:21 +00:00
|
|
|
Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
|
2004-10-12 12:09:56 +00:00
|
|
|
|
2006-12-12 16:15:21 +00:00
|
|
|
mpWindow->CaptureMouse();
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
|
2004-10-12 12:09:56 +00:00
|
|
|
|
2015-06-08 16:27:49 +02:00
|
|
|
mpView->BegCreateObj(aPnt, nullptr, nDrgLog);
|
2004-10-12 12:09:56 +00:00
|
|
|
|
2006-12-12 16:15:21 +00:00
|
|
|
SdrObject* pObj = mpView->GetCreateObj();
|
2004-10-12 12:09:56 +00:00
|
|
|
if ( pObj )
|
|
|
|
{
|
|
|
|
SetAttributes( pObj );
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bForceFillStyle = true;
|
|
|
|
bool bForceNoFillStyle = false;
|
2014-10-29 11:04:25 +02:00
|
|
|
if ( static_cast<SdrObjCustomShape*>(pObj)->UseNoFillStyle() )
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bForceFillStyle = false;
|
|
|
|
bForceNoFillStyle = true;
|
2004-10-12 12:09:56 +00:00
|
|
|
}
|
2006-12-12 16:15:21 +00:00
|
|
|
SfxItemSet aAttr(mpDoc->GetPool());
|
2004-10-12 12:09:56 +00:00
|
|
|
SetStyleSheet( aAttr, pObj, bForceFillStyle, bForceNoFillStyle );
|
|
|
|
pObj->SetMergedItemSet(aAttr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bReturn;
|
|
|
|
}
|
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
bool FuConstructCustomShape::MouseMove(const MouseEvent& rMEvt)
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
|
|
|
return FuConstruct::MouseMove(rMEvt);
|
|
|
|
}
|
|
|
|
|
2014-04-24 10:52:02 +02:00
|
|
|
bool FuConstructCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bReturn(false);
|
2004-10-12 12:09:56 +00:00
|
|
|
|
2006-12-12 16:15:21 +00:00
|
|
|
if(mpView->IsCreateObj() && rMEvt.IsLeft())
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2006-12-12 16:15:21 +00:00
|
|
|
SdrObject* pObj = mpView->GetCreateObj();
|
|
|
|
if( pObj && mpView->EndCreateObj( SDRCREATE_FORCEEND ) )
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bReturn = true;
|
2004-10-12 12:09:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
|
|
|
|
|
|
|
|
if (!bPermanent)
|
2014-10-11 16:01:26 +02:00
|
|
|
mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
|
2004-10-12 12:09:56 +00:00
|
|
|
|
|
|
|
return bReturn;
|
|
|
|
}
|
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
/**
|
|
|
|
* Process keyboard input
|
|
|
|
* @returns sal_True if a KeyEvent is being processed, sal_False otherwise
|
|
|
|
*/
|
2014-04-24 10:52:02 +02:00
|
|
|
bool FuConstructCustomShape::KeyInput(const KeyEvent& rKEvt)
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
return FuConstruct::KeyInput(rKEvt);
|
2004-10-12 12:09:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FuConstructCustomShape::Activate()
|
|
|
|
{
|
2006-12-12 16:15:21 +00:00
|
|
|
mpView->SetCurrentObj( OBJ_CUSTOMSHAPE );
|
2004-10-12 12:09:56 +00:00
|
|
|
FuConstruct::Activate();
|
|
|
|
}
|
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
/**
|
|
|
|
* set attribute for the object to be created
|
|
|
|
*/
|
2004-10-12 12:09:56 +00:00
|
|
|
void FuConstructCustomShape::SetAttributes( SdrObject* pObj )
|
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bAttributesAppliedFromGallery = false;
|
2004-10-12 12:09:56 +00:00
|
|
|
|
|
|
|
if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
std::vector< OUString > aObjList;
|
2004-10-12 12:09:56 +00:00
|
|
|
if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
|
|
|
|
{
|
|
|
|
sal_uInt16 i;
|
|
|
|
for ( i = 0; i < aObjList.size(); i++ )
|
|
|
|
{
|
|
|
|
if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
|
|
|
|
{
|
|
|
|
FmFormModel aFormModel;
|
|
|
|
SfxItemPool& rPool = aFormModel.GetItemPool();
|
|
|
|
rPool.FreezeIdRanges();
|
|
|
|
if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
|
|
|
|
{
|
2005-07-12 12:28:41 +00:00
|
|
|
const SdrPage* pPage = aFormModel.GetPage( 0 );
|
|
|
|
if ( pPage )
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2005-07-12 12:28:41 +00:00
|
|
|
const SdrObject* pSourceObj = pPage->GetObj( 0 );
|
|
|
|
if( pSourceObj )
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
2005-07-12 12:28:41 +00:00
|
|
|
const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
|
|
|
|
SfxItemSet aDest( pObj->GetModel()->GetItemPool(), // ranges from SdrAttrObj
|
|
|
|
SDRATTR_START, SDRATTR_SHADOW_LAST,
|
|
|
|
SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
|
|
|
|
SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
|
|
|
|
// Graphic Attributes
|
|
|
|
SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
|
|
|
|
// 3d Properties
|
|
|
|
SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
|
|
|
|
// CustomShape properties
|
|
|
|
SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
|
|
|
|
// range from SdrTextObj
|
|
|
|
EE_ITEMS_START, EE_ITEMS_END,
|
|
|
|
// end
|
|
|
|
0, 0);
|
|
|
|
aDest.Set( rSource );
|
|
|
|
pObj->SetMergedItemSet( aDest );
|
|
|
|
sal_Int32 nAngle = pSourceObj->GetRotateAngle();
|
|
|
|
if ( nAngle )
|
|
|
|
{
|
|
|
|
double a = nAngle * F_PI18000;
|
|
|
|
pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
|
|
|
|
}
|
2014-04-24 10:52:02 +02:00
|
|
|
bAttributesAppliedFromGallery = true;
|
2004-10-12 12:09:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !bAttributesAppliedFromGallery )
|
|
|
|
{
|
2007-05-10 14:29:19 +00:00
|
|
|
pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
|
2005-03-29 14:27:41 +00:00
|
|
|
pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
|
|
|
|
pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
|
2014-08-04 19:22:55 +02:00
|
|
|
pObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( false ) );
|
2014-10-29 11:04:25 +02:00
|
|
|
static_cast<SdrObjCustomShape*>(pObj)->MergeDefaultAttributes( &aCustomShape );
|
2004-10-12 12:09:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-13 15:37:03 +02:00
|
|
|
const OUString& FuConstructCustomShape::GetShapeType() const
|
tdf#36796 Status updates for custom shapes buttons
We're dealing here with 2 bugs:
1. Single shape buttons (like rectangle, ellipse etc.) don't get
the pressed state when active. The cause is that all commands of
the same kind (Basic Shapes, Symbol Shapes etc.) are handled as
one internally, allowing only one type of status updates. It used
to transport the current active shape, but it was changed to a
boolean value in the fix for i#41753, and since then used for
the pressed state of the group buttons.
2. The pressed state of a group button shows always, even when a
user activates a shape from a place other than the drop-down
of that button. But in this case the image of the group button
doesn't update with the current shape, thus confusing the user on
what is currently active. The cause here is that we use (since
i#41753) the XSubToolbarController interface to update the last
selected function (instead of the old-style status based update),
and ToolBarManager notifies a controller about a new selection
only if it was made from a particular toolbar that the controller
claimed to use in the getSubToolbarName method.
Since 7352a7c17875e5adcc4226c45f4a03e11c44ff49 there is a similar
regression for other group buttons in sd (like lines, 3D Objects
and other), with the same cause. This is also fixed now.
Change-Id: Ida074a001ff78bf5bd5bcb8151516daa6e27cbce
2015-07-21 10:58:39 +03:00
|
|
|
{
|
|
|
|
return aCustomShape;
|
|
|
|
}
|
|
|
|
|
2006-12-12 16:15:21 +00:00
|
|
|
SdrObject* FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const Rectangle& rRectangle)
|
2004-10-12 12:09:56 +00:00
|
|
|
{
|
|
|
|
SdrObject* pObj = SdrObjFactory::MakeNewObject(
|
2006-12-12 16:15:21 +00:00
|
|
|
mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
|
2015-11-10 10:23:02 +01:00
|
|
|
nullptr, mpDoc);
|
2004-10-12 12:09:56 +00:00
|
|
|
|
|
|
|
if( pObj )
|
|
|
|
{
|
2005-01-07 08:05:04 +00:00
|
|
|
Rectangle aRect( rRectangle );
|
|
|
|
if ( doConstructOrthogonal() )
|
|
|
|
ImpForceQuadratic( aRect );
|
|
|
|
pObj->SetLogicRect( aRect );
|
2004-10-12 12:09:56 +00:00
|
|
|
SetAttributes( pObj );
|
2006-12-12 16:15:21 +00:00
|
|
|
SfxItemSet aAttr(mpDoc->GetPool());
|
2004-10-12 12:09:56 +00:00
|
|
|
SetStyleSheet(aAttr, pObj);
|
|
|
|
pObj->SetMergedItemSet(aAttr);
|
|
|
|
}
|
|
|
|
return pObj;
|
|
|
|
}
|
|
|
|
|
2004-11-17 08:19:45 +00:00
|
|
|
// #i33136#
|
|
|
|
bool FuConstructCustomShape::doConstructOrthogonal() const
|
|
|
|
{
|
|
|
|
return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
|
|
|
|
}
|
|
|
|
|
2004-10-12 12:09:56 +00:00
|
|
|
} // end of namespace sd
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|