Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
44faceac
Kaydet (Commit)
44faceac
authored
Şub 24, 2013
tarafından
Tomaž Vajngerl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add "Compress Graphic Dialog" to Writer.
Change-Id: Icff16a86d217b2648ce588ca2b90abefcd1634d9
üst
bd502f4d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
29 deletions
+124
-29
compressgraphicdialog.hxx
svx/inc/svx/compressgraphicdialog.hxx
+5
-0
compressgraphicdialog.cxx
svx/source/dialog/compressgraphicdialog.cxx
+67
-28
_grfsh.sdi
sw/sdi/_grfsh.sdi
+6
-1
mn.src
sw/source/ui/app/mn.src
+1
-0
grfsh.cxx
sw/source/ui/shells/grfsh.cxx
+45
-0
No files found.
svx/inc/svx/compressgraphicdialog.hxx
Dosyayı görüntüle @
44faceac
...
...
@@ -80,9 +80,14 @@ private:
public
:
CompressGraphicsDialog
(
Window
*
pParent
,
SdrGrafObj
*
pGraphicObj
,
SfxBindings
&
rBindings
);
CompressGraphicsDialog
(
Window
*
pParent
,
Graphic
&
rGraphic
,
Size
rViewSize100mm
,
Rectangle
&
rCropRectangle
,
SfxBindings
&
rBindings
);
virtual
~
CompressGraphicsDialog
();
SdrGrafObj
*
GetCompressedSdrGrafObj
();
Graphic
GetCompressedGraphic
();
Rectangle
GetScaledCropRectangle
();
};
#endif
...
...
svx/source/dialog/compressgraphicdialog.cxx
Dosyayı görüntüle @
44faceac
...
...
@@ -43,7 +43,21 @@ CompressGraphicsDialog::CompressGraphicsDialog( Window* pParent, SdrGrafObj* pGr
m_pGraphicObj
(
pGraphicObj
),
m_aGraphic
(
pGraphicObj
->
GetGraphicObject
().
GetGraphic
()
),
m_aViewSize100mm
(
pGraphicObj
->
GetLogicRect
().
GetSize
()
),
m_aCropRectangle
(
Rectangle
()
),
m_rBindings
(
rBindings
),
m_dResolution
(
96.0
)
{
const
SdrGrafCropItem
&
rCrop
=
(
const
SdrGrafCropItem
&
)
m_pGraphicObj
->
GetMergedItem
(
SDRATTR_GRAFCROP
);
m_aCropRectangle
=
Rectangle
(
rCrop
.
GetLeft
(),
rCrop
.
GetTop
(),
rCrop
.
GetRight
(),
rCrop
.
GetBottom
());
Initialize
();
}
CompressGraphicsDialog
::
CompressGraphicsDialog
(
Window
*
pParent
,
Graphic
&
rGraphic
,
Size
rViewSize100mm
,
Rectangle
&
rCropRectangle
,
SfxBindings
&
rBindings
)
:
ModalDialog
(
pParent
,
"CompressGraphicDialog"
,
"svx/ui/compressgraphicdialog.ui"
),
m_pGraphicObj
(
NULL
),
m_aGraphic
(
rGraphic
),
m_aViewSize100mm
(
rViewSize100mm
),
m_aCropRectangle
(
rCropRectangle
),
m_rBindings
(
rBindings
),
m_dResolution
(
96.0
)
{
...
...
@@ -184,15 +198,15 @@ sal_uLong CompressGraphicsDialog::GetSelectedInterpolationType()
void
CompressGraphicsDialog
::
Compress
(
SvStream
&
aStream
)
{
BitmapEx
b
itmap
=
m_aGraphic
.
GetBitmapEx
();
BitmapEx
aB
itmap
=
m_aGraphic
.
GetBitmapEx
();
if
(
m_pReduceResolutionCB
->
IsChecked
()
)
{
long
nPixelX
=
(
long
)(
GetViewWidthInch
()
*
m_dResolution
);
long
nPixelY
=
(
long
)(
GetViewHeightInch
()
*
m_dResolution
);
b
itmap
.
Scale
(
Size
(
nPixelX
,
nPixelY
),
GetSelectedInterpolationType
()
);
aB
itmap
.
Scale
(
Size
(
nPixelX
,
nPixelY
),
GetSelectedInterpolationType
()
);
}
Graphic
aScaledGraphic
=
Graphic
(
b
itmap
);
Graphic
aScaledGraphic
(
aB
itmap
);
GraphicFilter
&
rFilter
=
GraphicFilter
::
GetGraphicFilter
();
Sequence
<
PropertyValue
>
aFilterData
(
3
);
...
...
@@ -206,7 +220,7 @@ void CompressGraphicsDialog::Compress(SvStream& aStream)
String
aGraphicFormatName
=
m_pLosslessRB
->
IsChecked
()
?
String
(
"png"
)
:
String
(
"jpg"
);
sal_uInt16
nFilterFormat
=
rFilter
.
GetExportFormatNumberForShortName
(
aGraphicFormatName
);
rFilter
.
ExportGraphic
(
aScaledGraphic
,
String
(
"test
"
),
aStream
,
nFilterFormat
,
&
aFilterData
);
rFilter
.
ExportGraphic
(
aScaledGraphic
,
OUString
(
"none
"
),
aStream
,
nFilterFormat
,
&
aFilterData
);
}
IMPL_LINK_NOARG
(
CompressGraphicsDialog
,
NewWidthModifiedHdl
)
...
...
@@ -266,7 +280,7 @@ IMPL_LINK_NOARG( CompressGraphicsDialog, CalculateClickHdl )
{
sal_Int32
aSize
=
0
;
if
(
m_dResolution
>
0
)
if
(
m_dResolution
>
0
.0
)
{
SvMemoryStream
aMemStream
;
aMemStream
.
SetVersion
(
SOFFICE_FILEFORMAT_CURRENT
);
...
...
@@ -286,38 +300,63 @@ IMPL_LINK_NOARG( CompressGraphicsDialog, CalculateClickHdl )
return
0L
;
}
SdrGrafObj
*
CompressGraphicsDialog
::
GetCompressedSdrGrafObj
()
Rectangle
CompressGraphicsDialog
::
GetScaledCropRectangle
()
{
if
(
m_
dResolution
>
0
)
if
(
m_
pReduceResolutionCB
->
IsChecked
()
)
{
SdrGrafObj
*
pNewObject
=
(
SdrGrafObj
*
)
m_pGraphicObj
->
Clone
();
if
(
m_pReduceResolutionCB
->
IsChecked
()
)
{
const
SdrGrafCropItem
&
rCrop
=
(
const
SdrGrafCropItem
&
)
m_pGraphicObj
->
GetMergedItem
(
SDRATTR_GRAFCROP
);
long
nPixelX
=
(
long
)(
GetViewWidthInch
()
*
m_dResolution
);
long
nPixelY
=
(
long
)(
GetViewHeightInch
()
*
m_dResolution
);
Size
size
=
m_aGraphic
.
GetBitmapEx
().
GetSizePixel
();
double
aScaleX
=
nPixelX
/
(
double
)
size
.
Width
();
double
aScaleY
=
nPixelY
/
(
double
)
size
.
Height
();
SdrGrafCropItem
aNewCrop
(
rCrop
.
GetLeft
()
*
aScaleX
,
rCrop
.
GetTop
()
*
aScaleY
,
rCrop
.
GetRight
()
*
aScaleX
,
rCrop
.
GetBottom
()
*
aScaleY
);
pNewObject
->
SetMergedItem
(
aNewCrop
);
}
long
nPixelX
=
(
long
)(
GetViewWidthInch
()
*
m_dResolution
);
long
nPixelY
=
(
long
)(
GetViewHeightInch
()
*
m_dResolution
);
Size
aSize
=
m_aGraphic
.
GetBitmapEx
().
GetSizePixel
();
double
aScaleX
=
nPixelX
/
(
double
)
aSize
.
Width
();
double
aScaleY
=
nPixelY
/
(
double
)
aSize
.
Height
();
return
Rectangle
(
m_aCropRectangle
.
Left
()
*
aScaleX
,
m_aCropRectangle
.
Top
()
*
aScaleY
,
m_aCropRectangle
.
Right
()
*
aScaleX
,
m_aCropRectangle
.
Bottom
()
*
aScaleY
);
}
else
{
return
m_aCropRectangle
;
}
}
Graphic
CompressGraphicsDialog
::
GetCompressedGraphic
()
{
if
(
m_dResolution
>
0.0
)
{
SvMemoryStream
aMemStream
;
aMemStream
.
SetVersion
(
SOFFICE_FILEFORMAT_CURRENT
);
Compress
(
aMemStream
);
aMemStream
.
Seek
(
STREAM_SEEK_TO_BEGIN
);
Graphic
aResultGraphic
;
GraphicFilter
&
rFilter
=
GraphicFilter
::
GetGraphicFilter
();
rFilter
.
ImportGraphic
(
aResultGraphic
,
String
(
"import"
),
aMemStream
);
rFilter
.
ImportGraphic
(
aResultGraphic
,
OU
String
(
"import"
),
aMemStream
);
pNewObject
->
SetGraphic
(
aResultGraphic
);
return
aResultGraphic
;
}
return
Graphic
();
}
SdrGrafObj
*
CompressGraphicsDialog
::
GetCompressedSdrGrafObj
()
{
if
(
m_dResolution
>
0.0
)
{
SdrGrafObj
*
pNewObject
=
(
SdrGrafObj
*
)
m_pGraphicObj
->
Clone
();
if
(
m_pReduceResolutionCB
->
IsChecked
()
)
{
Rectangle
aScaledCropedRectangle
=
GetScaledCropRectangle
();
SdrGrafCropItem
aNewCrop
(
aScaledCropedRectangle
.
Left
(),
aScaledCropedRectangle
.
Top
(),
aScaledCropedRectangle
.
Right
(),
aScaledCropedRectangle
.
Bottom
());
pNewObject
->
SetMergedItem
(
aNewCrop
);
}
pNewObject
->
SetGraphic
(
GetCompressedGraphic
()
);
return
pNewObject
;
}
...
...
sw/sdi/_grfsh.sdi
Dosyayı görüntüle @
44faceac
...
...
@@ -42,13 +42,18 @@ interface BaseTextGraphic
DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR";
]
SID_SAVE_GRAPHIC
[
ExecMethod = Execute ;
StateMethod = GetAttrState ;
]
SID_COMPRESS_GRAPHIC
[
ExecMethod = Execute ;
StateMethod = GetAttrState ;
]
SID_EXTERNAL_EDIT
[
ExecMethod = Execute ;
...
...
sw/source/ui/app/mn.src
Dosyayı görüntüle @
44faceac
...
...
@@ -1286,6 +1286,7 @@ Menu MN_GRF_POPUPMENU
MN_FRM_CAPTION_ITEM
SEPARATOR;
MenuItem { ITEM_SAVE_GRAPHIC };
MenuItem { ITEM_COMPRESS_GRAPHIC };
MenuItem { ITEM_EXTERNAL_EDIT };
SEPARATOR;
MenuItem
...
...
sw/source/ui/shells/grfsh.cxx
Dosyayı görüntüle @
44faceac
...
...
@@ -41,6 +41,7 @@
#include <svx/sdgmoitm.hxx>
#include <editeng/brushitem.hxx>
#include <svx/grfflt.hxx>
#include <svx/compressgraphicdialog.hxx>
#include <svx/tbxcolor.hxx>
#include <fmturl.hxx>
#include <view.hxx>
...
...
@@ -115,6 +116,50 @@ void SwGrfShell::Execute(SfxRequest &rReq)
}
}
break
;
case
SID_COMPRESS_GRAPHIC
:
{
const
Graphic
*
pGraphic
=
rSh
.
GetGraphic
();
if
(
pGraphic
)
{
Size
aSize
(
TWIP_TO_MM100
(
rSh
.
GetAnyCurRect
(
RECT_FLY_EMBEDDED
).
Width
()),
TWIP_TO_MM100
(
rSh
.
GetAnyCurRect
(
RECT_FLY_EMBEDDED
).
Height
()));
SfxItemSet
aSet
(
rSh
.
GetAttrPool
(),
RES_GRFATR_CROPGRF
,
RES_GRFATR_CROPGRF
);
rSh
.
GetCurAttr
(
aSet
);
SwCropGrf
aCrop
(
(
const
SwCropGrf
&
)
aSet
.
Get
(
RES_GRFATR_CROPGRF
)
);
Rectangle
aCropRectangle
(
TWIP_TO_MM100
(
aCrop
.
GetLeft
()),
TWIP_TO_MM100
(
aCrop
.
GetTop
()),
TWIP_TO_MM100
(
aCrop
.
GetRight
()),
TWIP_TO_MM100
(
aCrop
.
GetBottom
())
);
Graphic
aGraphic
=
Graphic
(
*
pGraphic
);
CompressGraphicsDialog
aDialog
(
GetView
().
GetWindow
(),
aGraphic
,
aSize
,
aCropRectangle
,
GetView
().
GetViewFrame
()
->
GetBindings
()
);
if
(
aDialog
.
Execute
()
==
RET_OK
)
{
rSh
.
StartAllAction
();
rSh
.
StartUndo
(
UNDO_START
);
Rectangle
aScaledCropedRectangle
=
aDialog
.
GetScaledCropRectangle
();
aCrop
.
SetLeft
(
MM100_TO_TWIP
(
aScaledCropedRectangle
.
Left
()
));
aCrop
.
SetTop
(
MM100_TO_TWIP
(
aScaledCropedRectangle
.
Top
()
));
aCrop
.
SetRight
(
MM100_TO_TWIP
(
aScaledCropedRectangle
.
Right
()
));
aCrop
.
SetBottom
(
MM100_TO_TWIP
(
aScaledCropedRectangle
.
Bottom
()
));
Graphic
aCompressedGraphic
(
aDialog
.
GetCompressedGraphic
()
);
rSh
.
ReRead
(
aEmptyStr
,
aEmptyStr
,
(
const
Graphic
*
)
&
aCompressedGraphic
);
rSh
.
SetAttr
(
aCrop
);
rSh
.
EndUndo
(
UNDO_END
);
rSh
.
EndAllAction
();
}
}
}
break
;
case
SID_EXTERNAL_EDIT
:
{
/* When the graphic is selected to be opened via some external tool
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment