Kaydet (Commit) 98ffb94d authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Extract QueryBox rotation string and InsertGraphic cleanup.

Change-Id: I46bb4b2436407cc2cb084f502ff8fb5ff7754400
üst 922d8753
...@@ -789,4 +789,9 @@ WarningBox MSG_DISABLE_READLINE_QUESTION ...@@ -789,4 +789,9 @@ WarningBox MSG_DISABLE_READLINE_QUESTION
Message [ en-US ] = "In the current document, changes are being recorded but not shown as such. In large documents, delays can occur when the document is edited. Do you want to show the changes to avoid delays?"; Message [ en-US ] = "In the current document, changes are being recorded but not shown as such. In large documents, delays can occur when the document is edited. Do you want to show the changes to avoid delays?";
}; };
String STR_ROTATE_TO_STANDARD_ORIENTATION
{
Text [ en-US ] = "This image is rotated. Would you like to rotate it into standard orientation?";
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -118,7 +118,9 @@ ...@@ -118,7 +118,9 @@
#define STR_AUTHMRK_EDIT (RC_APP_BEGIN + 130) #define STR_AUTHMRK_EDIT (RC_APP_BEGIN + 130)
#define STR_AUTHMRK_INSERT (RC_APP_BEGIN + 131) #define STR_AUTHMRK_INSERT (RC_APP_BEGIN + 131)
#define APP_ACT_END STR_AUTHMRK_INSERT #define STR_ROTATE_TO_STANDARD_ORIENTATION (RC_APP_BEGIN + 132)
#define APP_ACT_END STR_ROTATE_TO_STANDARD_ORIENTATION
#if APP_ACT_END > RC_APP_END #if APP_ACT_END > RC_APP_END
#error Resource-Id Ueberlauf in #file, #line #error Resource-Id Ueberlauf in #file, #line
......
...@@ -199,44 +199,45 @@ String SwView::GetPageStr( sal_uInt16 nPg, sal_uInt16 nLogPg, ...@@ -199,44 +199,45 @@ String SwView::GetPageStr( sal_uInt16 nPg, sal_uInt16 nLogPg,
} }
int SwView::InsertGraphic( const String &rPath, const String &rFilter, int SwView::InsertGraphic( const String &rPath, const String &rFilter,
sal_Bool bLink, GraphicFilter *pFlt, sal_Bool bLink, GraphicFilter *pFilter,
Graphic* pPreviewGrf, sal_Bool bRule ) Graphic* pPreviewGrf, sal_Bool bRule )
{ {
SwWait aWait( *GetDocShell(), sal_True ); SwWait aWait( *GetDocShell(), true );
Graphic aGrf; Graphic aGraphic;
int nRes = GRFILTER_OK; int aResult = GRFILTER_OK;
if ( pPreviewGrf ) if ( pPreviewGrf )
aGrf = *pPreviewGrf; aGraphic = *pPreviewGrf;
else else
{ {
if( !pFlt ) if( !pFilter )
pFlt = &GraphicFilter::GetGraphicFilter(); {
nRes = GraphicFilter::LoadGraphic( rPath, rFilter, aGrf, pFlt ); pFilter = &GraphicFilter::GetGraphicFilter();
}
aResult = GraphicFilter::LoadGraphic( rPath, rFilter, aGraphic, pFilter );
} }
if( GRFILTER_OK == nRes ) if( GRFILTER_OK == aResult )
{ {
GraphicNativeMetadata aMetadata; GraphicNativeMetadata aMetadata;
if (aMetadata.read(aGrf)) if ( aMetadata.read(aGraphic) )
{ {
sal_uInt16 aRotation = aMetadata.getRotation(); sal_uInt16 aRotation = aMetadata.getRotation();
if (aRotation != 0) if (aRotation != 0)
{ {
OUString aMessage("This image is rotated. Would you like LibreOffice to rotate it into standard orientation?"); QueryBox aQueryBox(GetWindow(), WB_YES_NO | WB_DEF_YES, SW_RES(STR_ROTATE_TO_STANDARD_ORIENTATION) );
QueryBox aQueryBox(GetWindow(), WB_YES_NO | WB_DEF_YES, aMessage);
if (aQueryBox.Execute() == RET_YES) if (aQueryBox.Execute() == RET_YES)
{ {
GraphicNativeTransform aTransform(aGrf); GraphicNativeTransform aTransform( aGraphic );
aTransform.rotate( aRotation ); aTransform.rotate( aRotation );
} }
} }
} }
SwFlyFrmAttrMgr aFrmMgr( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF ); SwFlyFrmAttrMgr aFrameManager( sal_True, GetWrtShellPtr(), FRMMGR_TYPE_GRF );
SwWrtShell &rSh = GetWrtShell(); SwWrtShell& rShell = GetWrtShell();
rSh.StartAction(); rShell.StartAction();
if( bLink ) if( bLink )
{ {
SwDocShell* pDocSh = GetDocShell(); SwDocShell* pDocSh = GetDocShell();
...@@ -245,18 +246,19 @@ int SwView::InsertGraphic( const String &rPath, const String &rFilter, ...@@ -245,18 +246,19 @@ int SwView::InsertGraphic( const String &rPath, const String &rFilter,
pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) : pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) :
OUString()); OUString());
String sURL = URIHelper::SmartRel2Abs( String sURL = URIHelper::SmartRel2Abs( aTemp, rPath, URIHelper::GetMaybeFileHdl() );
aTemp, rPath, URIHelper::GetMaybeFileHdl() );
rSh.Insert( sURL, rShell.Insert( sURL, rFilter, aGraphic, &aFrameManager, bRule );
rFilter, aGrf, &aFrmMgr, bRule );
} }
else else
rSh.Insert( aEmptyStr, aEmptyStr, aGrf, &aFrmMgr ); {
// nach dem EndAction ist es zu spaet, weil die Shell dann schon zerstoert sein kann rShell.Insert( aEmptyStr, aEmptyStr, aGraphic, &aFrameManager );
rSh.EndAction(); }
// it is too late after "EndAction" because the Shell can already be destroyed.
rShell.EndAction();
} }
return nRes; return aResult;
} }
sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq ) sal_Bool SwView::InsertGraphicDlg( SfxRequest& rReq )
......
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