fdo#30944 Add popup menu function to charts to export them as a graphic
Add popup menu function "Export as Graphic" to charts to export the chart as a graphic. Currently it works only with raster formats like PNG and JPG but not with vector formats like SVG. Change-Id: Ieeda21ff971f2ad31bab2248e8b509883b5cbcd0
This commit is contained in:
parent
fa30508fd3
commit
cbb0babb67
6 changed files with 98 additions and 15 deletions
|
@ -529,6 +529,9 @@
|
||||||
#define SID_NEW_SLOTS (SID_KEYFUNC_END)
|
#define SID_NEW_SLOTS (SID_KEYFUNC_END)
|
||||||
|
|
||||||
#define SID_NEW_TABLENAME (SID_NEW_SLOTS+1)
|
#define SID_NEW_TABLENAME (SID_NEW_SLOTS+1)
|
||||||
|
|
||||||
|
#define SID_EXPORT_AS_GRAPHIC (SID_NEW_SLOTS+2)
|
||||||
|
|
||||||
#define FID_MERGE_TOGGLE (SID_NEW_SLOTS+10)
|
#define FID_MERGE_TOGGLE (SID_NEW_SLOTS+10)
|
||||||
#define SID_ATTR_ROWHEADERS (SID_NEW_SLOTS+11)
|
#define SID_ATTR_ROWHEADERS (SID_NEW_SLOTS+11)
|
||||||
#define SID_ATTR_COLHEADERS (SID_NEW_SLOTS+12)
|
#define SID_ATTR_COLHEADERS (SID_NEW_SLOTS+12)
|
||||||
|
@ -1126,4 +1129,3 @@
|
||||||
#define RID_SCPAGE_DEFAULTS (SC_OOO_BUILD_START + 10)
|
#define RID_SCPAGE_DEFAULTS (SC_OOO_BUILD_START + 10)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,16 @@
|
||||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ===========================================================================
|
interface ChartSelection
|
||||||
|
{
|
||||||
|
SID_EXPORT_AS_GRAPHIC
|
||||||
|
[
|
||||||
|
ExecMethod = ExecuteExportAsGraphic;
|
||||||
|
StateMethod = GetExportAsGraphicState;
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
shell ScChartShell : ScDrawShell
|
shell ScChartShell : ScDrawShell
|
||||||
{
|
{
|
||||||
|
import ChartSelection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* for a copy of the LGPLv3 License.
|
* for a copy of the LGPLv3 License.
|
||||||
*
|
*
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
SfxVoidItem AcceptChanges FID_CHG_ACCEPT
|
SfxVoidItem AcceptChanges FID_CHG_ACCEPT
|
||||||
()
|
()
|
||||||
[
|
[
|
||||||
|
@ -2919,10 +2919,10 @@ SfxVoidItem SolverDialog SID_OPENDLG_OPTSOLVER
|
||||||
Synchron;
|
Synchron;
|
||||||
|
|
||||||
/* config: */
|
/* config: */
|
||||||
AccelConfig = FALSE,
|
AccelConfig = FALSE,
|
||||||
MenuConfig = FALSE,
|
MenuConfig = FALSE,
|
||||||
StatusBarConfig = FALSE,
|
StatusBarConfig = FALSE,
|
||||||
ToolBoxConfig = FALSE,
|
ToolBoxConfig = FALSE,
|
||||||
GroupId = GID_OPTIONS;
|
GroupId = GID_OPTIONS;
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -8342,3 +8342,27 @@ SfxVoidItem EnterString SID_ENTER_STRING
|
||||||
ToolBoxConfig = FALSE,
|
ToolBoxConfig = FALSE,
|
||||||
GroupId = GID_INTERN;
|
GroupId = GID_INTERN;
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SfxVoidItem ExportAsGraphic SID_EXPORT_AS_GRAPHIC
|
||||||
|
()
|
||||||
|
[
|
||||||
|
/* flags: */
|
||||||
|
AutoUpdate = FALSE,
|
||||||
|
Cachable = Cachable,
|
||||||
|
FastCall = FALSE,
|
||||||
|
HasCoreId = FALSE,
|
||||||
|
HasDialog = FALSE,
|
||||||
|
ReadOnlyDoc = TRUE,
|
||||||
|
Toggle = FALSE,
|
||||||
|
Container = FALSE,
|
||||||
|
RecordAbsolute = FALSE,
|
||||||
|
RecordPerSet;
|
||||||
|
Synchron;
|
||||||
|
|
||||||
|
/* config: */
|
||||||
|
AccelConfig = TRUE,
|
||||||
|
MenuConfig = TRUE,
|
||||||
|
StatusBarConfig = FALSE,
|
||||||
|
ToolBoxConfig = TRUE,
|
||||||
|
GroupId = GID_CHART;
|
||||||
|
]
|
||||||
|
|
|
@ -17,8 +17,10 @@
|
||||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <editeng/eeitem.hxx>
|
#include <svx/svdoole2.hxx>
|
||||||
#include <svx/fontwork.hxx>
|
#include <svx/svdobj.hxx>
|
||||||
|
#include <svx/graphichelper.hxx>
|
||||||
|
|
||||||
#include <svl/srchitem.hxx>
|
#include <svl/srchitem.hxx>
|
||||||
#include <sfx2/app.hxx>
|
#include <sfx2/app.hxx>
|
||||||
#include <sfx2/objface.hxx>
|
#include <sfx2/objface.hxx>
|
||||||
|
@ -34,15 +36,13 @@
|
||||||
#include "docpool.hxx"
|
#include "docpool.hxx"
|
||||||
#include "drawview.hxx"
|
#include "drawview.hxx"
|
||||||
#include "scresid.hxx"
|
#include "scresid.hxx"
|
||||||
#include <svx/svdobj.hxx>
|
|
||||||
|
|
||||||
#define ScChartShell
|
#define ScChartShell
|
||||||
#include "scslots.hxx"
|
#include "scslots.hxx"
|
||||||
|
|
||||||
|
|
||||||
SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL) )
|
SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL) )
|
||||||
{
|
{
|
||||||
SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
|
SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_SERVER,
|
||||||
ScResId(RID_DRAW_OBJECTBAR) );
|
ScResId(RID_DRAW_OBJECTBAR) );
|
||||||
SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_CHART) );
|
SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_CHART) );
|
||||||
}
|
}
|
||||||
|
@ -52,14 +52,55 @@ TYPEINIT1( ScChartShell, ScDrawShell );
|
||||||
ScChartShell::ScChartShell(ScViewData* pData) :
|
ScChartShell::ScChartShell(ScViewData* pData) :
|
||||||
ScDrawShell(pData)
|
ScDrawShell(pData)
|
||||||
{
|
{
|
||||||
SetHelpId(HID_SCSHELL_CHARTSH);
|
SetHelpId( HID_SCSHELL_CHARTSH );
|
||||||
SetName(rtl::OUString("ChartObject"));
|
SetName( OUString("ChartObject") );
|
||||||
}
|
}
|
||||||
|
|
||||||
ScChartShell::~ScChartShell()
|
ScChartShell::~ScChartShell()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScChartShell::GetExportAsGraphicState( SfxItemSet& rSet )
|
||||||
|
{
|
||||||
|
ScDrawView* pView = GetViewData()->GetScDrawView();
|
||||||
|
const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
|
||||||
|
bool bEnable = false;
|
||||||
|
if( rMarkList.GetMarkCount() == 1 )
|
||||||
|
{
|
||||||
|
SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
|
||||||
|
|
||||||
|
if( pObj && pObj->ISA( SdrOle2Obj ) )
|
||||||
|
bEnable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !bEnable )
|
||||||
|
rSet.DisableItem( SID_EXPORT_AS_GRAPHIC );
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScChartShell::ExecuteExportAsGraphic( SfxRequest& )
|
||||||
|
{
|
||||||
|
ScDrawView* pView = GetViewData()->GetScDrawView();
|
||||||
|
const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
|
||||||
|
|
||||||
|
if( rMarkList.GetMarkCount() == 1 )
|
||||||
|
{
|
||||||
|
SdrObject* pObject = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
|
||||||
|
|
||||||
|
if( pObject && pObject->ISA( SdrOle2Obj ) )
|
||||||
|
{
|
||||||
|
SdrOle2Obj* aOle2Object = ((SdrOle2Obj*) pObject)->Clone();
|
||||||
|
aOle2Object->NbcResize(Point(), Fraction(1,1), Fraction(1,1));
|
||||||
|
Graphic* pGraphic = aOle2Object->GetGraphic();
|
||||||
|
if( pGraphic != NULL )
|
||||||
|
{
|
||||||
|
String sGrfNm, sFilterNm;
|
||||||
|
GraphicHelper::ExportGraphic( *pGraphic, String("") );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
|
|
@ -619,6 +619,12 @@ Menu RID_POPUP_CHART
|
||||||
MenuItem { Separator = TRUE ; };
|
MenuItem { Separator = TRUE ; };
|
||||||
//------------------------------
|
//------------------------------
|
||||||
ITEM_GROUP_MENU
|
ITEM_GROUP_MENU
|
||||||
|
MenuItem
|
||||||
|
{
|
||||||
|
Identifier = SID_EXPORT_AS_GRAPHIC ;
|
||||||
|
Command = ".uno:ExportAsGraphic" ;
|
||||||
|
Text [ en-US ] = "Export as graphic.." ;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <sfx2/shell.hxx>
|
#include <sfx2/shell.hxx>
|
||||||
#include "shellids.hxx"
|
#include "shellids.hxx"
|
||||||
#include <sfx2/module.hxx>
|
#include <sfx2/module.hxx>
|
||||||
#include <svx/svdmark.hxx>
|
|
||||||
|
|
||||||
class ScViewData;
|
class ScViewData;
|
||||||
|
|
||||||
|
@ -39,6 +38,8 @@ public:
|
||||||
ScChartShell(ScViewData* pData);
|
ScChartShell(ScViewData* pData);
|
||||||
virtual ~ScChartShell();
|
virtual ~ScChartShell();
|
||||||
|
|
||||||
|
void ExecuteExportAsGraphic(SfxRequest& rReq);
|
||||||
|
void GetExportAsGraphicState(SfxItemSet &rSet);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue