Kaydet (Commit) 4d7581b9 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Compress Graphic functionallity added (currently only for Draw)

This is a initial commit of "Compress Graphics" functionallity.
Compress Graphics is accesible via pop-up menu option to graphics
objects. Currently this funtionallity is only available in Draw.
When the menu option is triggered, a Compress Graphics modal dialog
opens to define DPI, compression level and type of compression.
When OK is clicked, the graphics in Draw is compressed and exchanged.

The current implementation is not final as it needs handling in case
when the graphics is croped. Additionally cropped areas could be
removed when compressing, depending on a checkbox in the dialog.
Special cases of graphics need to be checked too, and some tests
would not hurt.

Change-Id: I9ec1a71f6ff4364a49b2521e42d88c3ba224dd87
üst 9a7e4eac
......@@ -75,6 +75,11 @@ interface DrawView
ExecMethod = FuTemporary ;
StateMethod = GetMenuState ;
]
SID_COMPRESS_GRAPHIC
[
ExecMethod = FuTemporary ;
StateMethod = GetMenuState ;
]
SID_CUT // ole : no, status : ?
[
ExecMethod = FuSupport ;
......
......@@ -659,6 +659,7 @@
MN_STYLEDT
SEPARATOR
MenuItem { ITEM_SAVE_GRAPHIC };
MenuItem { ITEM_COMPRESS_GRAPHIC };
};
};
......
......@@ -48,6 +48,7 @@
#include <editeng/flditem.hxx>
#include <svx/xlineit0.hxx>
#include <svx/graphichelper.hxx>
#include <svx/compressgraphicdialog.hxx>
#include <svx/svdoutl.hxx>
#include <svx/xlnwtit.hxx>
#include <svx/svdoattr.hxx>
......@@ -949,6 +950,39 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
}
break;
case SID_COMPRESS_GRAPHIC:
{
const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
if( rMarkList.GetMarkCount() == 1 )
{
SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
{
GraphicObject aGraphicObject( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
{
CompressGraphicsDialog dialog( GetParentWindow(), aGraphicObject.GetGraphic(), pObj->GetLogicRect().GetSize(), GetViewFrame()->GetBindings() );
if ( dialog.Execute() == RET_OK )
{
SdrGrafObj* pNewObject = (SdrGrafObj*) pObj->Clone();
const Graphic aNewGraphic = dialog.GetCompressedGraphic();
SdrPageView* pPageView = mpDrawView->GetSdrPageView();
pNewObject->SetEmptyPresObj( sal_False );
pNewObject->SetGraphic( aNewGraphic );
String aUndoString( mpDrawView->GetDescriptionOfMarkedObjects() );
aUndoString += (sal_Unicode) ( ' ' );
aUndoString += String( "Compress" );
mpDrawView->BegUndo( aUndoString );
mpDrawView->ReplaceObjectAtView( pObj, *pPageView, pNewObject );
mpDrawView->EndUndo();
}
}
}
}
Cancel();
rReq.Ignore();
}
break;
default:
{
// switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
......
......@@ -71,9 +71,9 @@ namespace sd {
void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet )
{
// Status der Menueintraege, bzw. Buttons
// Einfachselektion
// Status of menu entries (Buttons,...)
// Single selection
const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
sal_uLong nMarkCount = rMarkList.GetMarkCount();
......@@ -119,6 +119,7 @@ void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet )
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_REVERSE_ORDER ) ||
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ORIGINAL_SIZE ) ||
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SAVE_GRAPHIC ) ||
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_COMPRESS_GRAPHIC ) ||
SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_TEXTATTR_DLG ) )
{
const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
......@@ -140,6 +141,7 @@ void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet )
if ( !( pObj->ISA( SdrGrafObj ) ) )
{
rSet.DisableItem(SID_SAVE_GRAPHIC);
rSet.DisableItem(SID_COMPRESS_GRAPHIC);
}
// Wenn es sich um kein Gruppenobjekt oder 3D-Objekt handelt
......
......@@ -60,6 +60,7 @@ $(eval $(call gb_SrsTarget_add_files,svx/res,\
svx/source/dialog/bmpmask.src \
svx/source/dialog/contdlg.src \
svx/source/dialog/ctredlin.src \
svx/source/dialog/compressgraphicdialog.src \
svx/source/dialog/dlgctrl.src \
svx/source/dialog/docrecovery.src \
svx/source/dialog/fontwork.src \
......
......@@ -2,7 +2,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
#
# Copyright 2000, 2011 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
......@@ -100,6 +100,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/dialog/connctrl \
svx/source/dialog/_contdlg \
svx/source/dialog/contwnd \
svx/source/dialog/compressgraphicdialog \
svx/source/dialog/ctredlin \
svx/source/dialog/databaseregistrationui \
svx/source/dialog/dialcontrol \
......
......@@ -554,5 +554,6 @@ $(eval $(call gb_Package_add_file,svx_inc,inc/svx/fmdpage.hxx,svx/fmdpage.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sxmtpitm.hxx,svx/sxmtpitm.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/extedit.hxx,svx/extedit.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/graphichelper.hxx,svx/graphichelper.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/compressgraphicdialog.hxx,svx/compressgraphicdialog.hxx))
# vim: set noet sw=4 ts=4:
......@@ -262,6 +262,11 @@
Command = ".uno:ExternalEdit" ; \
Text [ en-US ] = "Edit with External Tool..." ; \
#define ITEM_COMPRESS_GRAPHIC \
Identifier = SID_COMPRESS_GRAPHIC ; \
Command = ".uno:CompressGraphic" ; \
Text [ en-US ] = "Compress Graphic..." ; \
#define ITEM_SAVE_GRAPHIC \
Identifier = SID_SAVE_GRAPHIC ; \
Command = ".uno:SaveGraphic" ; \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#ifndef _COMPRESS_GRAPHICS_DIALOG_HXX
#define _COMPRESS_GRAPHICS_DIALOG_HXX
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/field.hxx>
#include <sfx2/bindings.hxx>
#include "svx/svxdllapi.h"
class SVX_DLLPUBLIC CompressGraphicsDialog : public ModalDialog
{
private:
FixedText m_aFixedText2X;
FixedText m_aFixedText2;
FixedText m_aFixedText3X;
FixedText m_aFixedText3;
FixedText m_aFixedText4X;
FixedText m_aFixedText4;
FixedText m_aFixedText5X;
FixedText m_aFixedText5;
FixedText m_aFixedText6X;
FixedText m_aFixedText6;
ComboBox m_aResolutionLB;
MetricField m_aMFQuality;
CheckBox m_aLossless;
OKButton m_aBtnOK;
CancelButton m_aBtnCancel;
HelpButton m_aBtnHelp;
PushButton m_aBtnCalculate;
Graphic m_aGraphic;
Size m_aViewSize100mm;
SfxBindings& m_rBindings;
DECL_LINK( ResolutionModifiedHdl, void* );
DECL_LINK( ClickHdl, void* );
void Update();
public:
CompressGraphicsDialog( Window* pParent, const Graphic& rGraphic, const Size& rViewSize100mm, SfxBindings& rBindings );
virtual ~CompressGraphicsDialog();
Graphic GetCompressedGraphic();
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -243,6 +243,7 @@
#define RID_SVXTBX_STYLE (RID_SVX_START + 120)
#define RID_SVXDLG_PASSWORD (RID_SVX_START + 141)
#define RID_SVXDLG_COMPRESSGRAPHICS (RID_SVX_START + 142)
// Dialog for functions
#define RID_SVXDLG_CALCFUNC (RID_SVX_START + 206)
......
......@@ -936,9 +936,10 @@
#define SID_EXTERNAL_EDIT (SID_SVX_START+1113)
#define SID_ATTR_PAGE_SHARED_FIRST (SID_SVX_START+1114)
#define SID_SAVE_GRAPHIC (SID_SVX_START+1115)
#define SID_COMPRESS_GRAPHIC (SID_SVX_START+1116)
// IMPORTANT NOTE: adjust SID_SVX_FIRSTFREE, when adding new slot id
#define SID_SVX_FIRSTFREE (SID_SAVE_GRAPHIC + 1)
#define SID_SVX_FIRSTFREE (SID_COMPRESS_GRAPHIC + 1)
// --------------------------------------------------------------------------
// Overflow check for slot IDs
......
......@@ -5996,6 +5996,30 @@ SfxVoidItem SaveGraphic SID_SAVE_GRAPHIC
GroupId = GID_MODIFY;
]
SfxVoidItem CompressGraphic SID_COMPRESS_GRAPHIC
()
[
/* flags: */
AutoUpdate = FALSE,
Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
ReadOnlyDoc = TRUE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
Synchron;
/* config: */
AccelConfig = FALSE,
MenuConfig = FALSE,
StatusBarConfig = FALSE,
ToolBoxConfig = FALSE,
GroupId = GID_MODIFY;
]
//--------------------------------------------------------------------------
SfxBoolItem Init3D SID_3D_INIT
......
This diff is collapsed.
/*
* 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 .
*/
#ifndef _COMPRESS_GRAPHICS_DIALOG_HRC
#define _COMPRESS_GRAPHICS_DIALOG_HRC
#define FT_CG_2 2
#define FT_CG_2_X 3
#define FT_CG_3 4
#define FT_CG_3_X 5
#define FT_CG_4 6
#define FT_CG_4_X 7
#define FT_CG_5 8
#define FT_CG_5_X 9
#define FT_CG_6 10
#define FT_CG_6_X 11
#define LB_CG_RESOLUTION 20
#define MF_CG_QUALITY 21
#define CB_CG_LOSSLESS 22
#define BUTTON_CG_OK 30
#define BUTTON_CG_CANCEL 31
#define BUTTON_CG_HELP 32
#define BUTTON_CG_CALCULATE 33
#endif
/*
* 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 .
*/
#include <svx/dialogs.hrc>
#include "helpid.hrc"
#include "compressgraphicdialog.hrc"
ModalDialog RID_SVXDLG_COMPRESSGRAPHICS
{
HelpID = "svx:ModalDialog:RID_SVXDLG_COMPRESSGRAPHICS";
OutputSize = TRUE ;
SVLook = TRUE ;
Size = MAP_APPFONT ( 226 , 200 ) ;
Moveable = TRUE ;
Sizeable = TRUE ;
Closeable = TRUE ;
Hide = TRUE ;
Text [ en-US ] = "Compress Graphics" ;
FixedText FT_CG_2_X
{
Pos = MAP_APPFONT ( 6 , 8 ) ;
Size = MAP_APPFONT ( 50 , 10 ) ;
Text [ en-US ] = "Original Size:" ;
};
FixedText FT_CG_2
{
Pos = MAP_APPFONT ( 56 , 8 ) ;
Size = MAP_APPFONT ( 124 , 10 ) ;
};
FixedText FT_CG_3_X
{
Pos = MAP_APPFONT ( 6 , 20 ) ;
Size = MAP_APPFONT ( 50 , 10 ) ;
Text [ en-US ] = "View Size:" ;
};
FixedText FT_CG_3
{
Pos = MAP_APPFONT ( 56 , 20 ) ;
Size = MAP_APPFONT ( 124 , 10 ) ;
};
FixedText FT_CG_4_X
{
Pos = MAP_APPFONT ( 6 , 32 ) ;
Size = MAP_APPFONT ( 50 , 10 ) ;
Text [ en-US ] = "Compressed Size:" ;
};
FixedText FT_CG_4
{
Pos = MAP_APPFONT ( 56 , 32 ) ;
Size = MAP_APPFONT ( 124 , 10 ) ;
};
FixedText FT_CG_5_X
{
Pos = MAP_APPFONT ( 6 , 44 ) ;
Size = MAP_APPFONT ( 50 , 10 ) ;
Text [ en-US ] = "Image Capacity:" ;
};
FixedText FT_CG_5
{
Pos = MAP_APPFONT ( 56 , 44 ) ;
Size = MAP_APPFONT ( 124 , 10 ) ;
};
FixedText FT_CG_6_X
{
Pos = MAP_APPFONT ( 6 , 56 ) ;
Size = MAP_APPFONT ( 50 , 10 ) ;
Text [ en-US ] = "New Capacity:" ;
};
FixedText FT_CG_6
{
Pos = MAP_APPFONT ( 56 , 56 ) ;
Size = MAP_APPFONT ( 124 , 10 ) ;
};
ComboBox LB_CG_RESOLUTION
{
HelpID = "sfx2:ListBox:TP_COMMONPRINTOPTIONS:LB_REDUCEBITMAPS_RESOLUTION";
TabStop = TRUE;
Border = TRUE ;
Pos = MAP_APPFONT ( 6, 68 ) ;
Size = MAP_APPFONT ( 60, 100 ) ;
DropDown = TRUE;
StringList [ en-US ] =
{
"75 DPI";
"96 DPI";
"150 DPI";
"200 DPI";
"300 DPI";
"600 DPI";
};
};
MetricField MF_CG_QUALITY
{
Border = TRUE ;
Pos = MAP_APPFONT ( 70, 68 ) ;
Size = MAP_APPFONT ( 29 , 12 ) ;
TabStop = TRUE ;
Repeat = TRUE ;
Spin = TRUE ;
Maximum = 99 ;
Last = 99 ;
SpinSize = 1 ;
Unit = FUNIT_PERCENT ;
};
CheckBox CB_CG_LOSSLESS
{
Pos = MAP_APPFONT ( 6 , 80 ) ;
Size = MAP_APPFONT ( 118 , 10 ) ;
Text [ en-US ] = "Lossless";
};
OKButton BUTTON_CG_OK
{
Pos = MAP_APPFONT ( 170 , 6 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
DefButton = TRUE ;
};
CancelButton BUTTON_CG_CANCEL
{
Pos = MAP_APPFONT ( 170 , 23 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
};
HelpButton BUTTON_CG_HELP
{
Pos = MAP_APPFONT ( 170 , 43 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
};
PushButton BUTTON_CG_CALCULATE
{
Pos = MAP_APPFONT ( 170 , 63 ) ;
Size = MAP_APPFONT ( 50 , 14 ) ;
Text [ en-US ] = "Calculate";
};
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment