/************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: fuins1.cxx,v $ * $Revision: 1.12.128.1 $ * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 * only, as published by the Free Software Foundation. * * OpenOffice.org is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License version 3 for more details * (a copy is included in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU Lesser General Public License * version 3 along with OpenOffice.org. If not, see * * for a copy of the LGPLv3 License. * ************************************************************************/ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "fuinsert.hxx" #include "tabvwsh.hxx" #include "drwlayer.hxx" #include "drawview.hxx" #include "document.hxx" #include "scresid.hxx" #include "progress.hxx" #include "sc.hrc" ////======================================================================== //// class ImportProgress //// //// Bemerkung: //// Diese Klasse stellt lediglich den Handler fuer den ImportProgress des //// Grafikfilters bereit. ////======================================================================== // //class ImportProgress //{ //public: // ImportProgress( GraphicFilter& rFilter ); // ~ImportProgress(); // // DECL_LINK( Update, GraphicFilter* ); // //private: // ScProgress aProgress; //}; // ////------------------------------------------------------------------------ // //ImportProgress::ImportProgress( GraphicFilter& rFilter ) // : aProgress( NULL, // SfxViewFrame*, NULL == alle Docs locken // String( ScResId(STR_INSERTGRAPHIC) ), // 100 ) //{ // rFilter.SetUpdatePercentHdl( LINK( this, ImportProgress, Update) ); //} // ////------------------------------------------------------------------------ // //__EXPORT ImportProgress::~ImportProgress() //{ // aProgress.SetState( 100 ); //} // ////------------------------------------------------------------------------ // //IMPL_LINK( ImportProgress, Update, GraphicFilter*, pGraphicFilter ) //{ // aProgress.SetState( pGraphicFilter->GetPercent() ); // return 0; //} //------------------------------------------------------------------------ void SC_DLLPUBLIC ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage ) { if ( !rPage.Width() || !rPage.Height() ) return; Size aPageSize = rPage; BOOL bNegative = aPageSize.Width() < 0; if ( bNegative ) { // make everything positive temporarily aPageSize.Width() = -aPageSize.Width(); rPos.X() = -rPos.X() - rSize.Width(); } if ( rSize.Width() > aPageSize.Width() || rSize.Height() > aPageSize.Height() ) { double fX = aPageSize.Width() / (double) rSize.Width(); double fY = aPageSize.Height() / (double) rSize.Height(); if ( fX < fY ) { rSize.Width() = aPageSize.Width(); rSize.Height() = (long) ( rSize.Height() * fX ); } else { rSize.Height() = aPageSize.Height(); rSize.Width() = (long) ( rSize.Width() * fY ); } if (!rSize.Width()) rSize.Width() = 1; if (!rSize.Height()) rSize.Height() = 1; } if ( rPos.X() + rSize.Width() > aPageSize.Width() ) rPos.X() = aPageSize.Width() - rSize.Width(); if ( rPos.Y() + rSize.Height() > aPageSize.Height() ) rPos.Y() = aPageSize.Height() - rSize.Height(); if ( bNegative ) rPos.X() = -rPos.X() - rSize.Width(); // back to real position } //------------------------------------------------------------------------ void lcl_InsertGraphic( const Graphic& rGraphic, const String& rFileName, const String& rFilterName, BOOL bAsLink, BOOL bApi, ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView ) { // #74778# set the size so the graphic has its original pixel size // at 100% view scale (as in SetMarkedOriginalSize), // instead of respecting the current view scale ScDrawView* pDrawView = pViewSh->GetScDrawView(); MapMode aSourceMap = rGraphic.GetPrefMapMode(); MapMode aDestMap( MAP_100TH_MM ); if ( aSourceMap.GetMapUnit() == MAP_PIXEL && pDrawView ) { Fraction aScaleX, aScaleY; pDrawView->CalcNormScale( aScaleX, aScaleY ); aDestMap.SetScaleX(aScaleX); aDestMap.SetScaleY(aScaleY); } Size aLogicSize = pWindow->LogicToLogic( rGraphic.GetPrefSize(), &aSourceMap, &aDestMap ); // Limit size SdrPageView* pPV = pView->GetSdrPageView(); SdrPage* pPage = pPV->GetPage(); Point aInsertPos = pViewSh->GetInsertPos(); ScViewData* pData = pViewSh->GetViewData(); if ( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) ) aInsertPos.X() -= aLogicSize.Width(); // move position to left edge ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() ); Rectangle aRect ( aInsertPos, aLogicSize ); SdrGrafObj* pObj = new SdrGrafObj( rGraphic, aRect ); // #118522# calling SetGraphicLink here doesn't work // #49961# Path is no longer used as name for the graphics object ScDrawLayer* pLayer = (ScDrawLayer*) pView->GetModel(); String aName = pLayer->GetNewGraphicName(); // "Grafik x" pObj->SetName(aName); // don't select if from (dispatch) API, to allow subsequent cell operations ULONG nInsOptions = bApi ? SDRINSERT_DONTMARK : 0; pView->InsertObjectAtView( pObj, *pPV, nInsOptions ); // #118522# SetGraphicLink has to be used after inserting the object, // otherwise an empty graphic is swapped in and the contact stuff crashes. // See #i37444#. if ( bAsLink ) pObj->SetGraphicLink( rFileName, rFilterName ); } //------------------------------------------------------------------------ void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi, ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView, const Size& rPrefSize ) { SdrPageView* pPV = pView->GetSdrPageView(); SdrPage* pPage = pPV->GetPage(); ScViewData* pData = pViewSh->GetViewData(); Point aInsertPos( pViewSh->GetInsertPos() ); Size aSize; if( rPrefSize.Width() && rPrefSize.Height() ) { if( pWindow ) aSize = pWindow->PixelToLogic( rPrefSize, MAP_100TH_MM ); else aSize = Application::GetDefaultDevice()->PixelToLogic( rPrefSize, MAP_100TH_MM ); } else aSize = Size( 5000, 5000 ); ScLimitSizeOnDrawPage( aSize, aInsertPos, pPage->GetSize() ); if( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) ) aInsertPos.X() -= aSize.Width(); SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aInsertPos, aSize ) ); pObj->setURL( rMediaURL ); pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 ); } /************************************************************************* |* |* FuInsertGraphic::Konstruktor |* \************************************************************************/ #ifdef _MSC_VER #pragma optimize("",off) #endif FuInsertGraphic::FuInsertGraphic( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, SdrModel* pDoc, SfxRequest& rReq ) : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq) { const SfxItemSet* pReqArgs = rReq.GetArgs(); const SfxPoolItem* pItem; if ( pReqArgs && pReqArgs->GetItemState( SID_INSERT_GRAPHIC, TRUE, &pItem ) == SFX_ITEM_SET ) { String aFileName = ((const SfxStringItem*)pItem)->GetValue(); String aFilterName; if ( pReqArgs->GetItemState( FN_PARAM_FILTER, TRUE, &pItem ) == SFX_ITEM_SET ) aFilterName = ((const SfxStringItem*)pItem)->GetValue(); BOOL bAsLink = FALSE; if ( pReqArgs->GetItemState( FN_PARAM_1, TRUE, &pItem ) == SFX_ITEM_SET ) bAsLink = ((const SfxBoolItem*)pItem)->GetValue(); Graphic aGraphic; int nError = ::LoadGraphic( aFileName, aFilterName, aGraphic, ::GetGrfFilter() ); if ( nError == GRFILTER_OK ) { lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, TRUE, pViewSh, pWindow, pView ); } } else { SvxOpenGraphicDialog aDlg(ScResId(STR_INSERTGRAPHIC)); if( aDlg.Execute() == GRFILTER_OK ) { Graphic aGraphic; int nError = aDlg.GetGraphic(aGraphic); if( nError == GRFILTER_OK ) { String aFileName = aDlg.GetPath(); String aFilterName = aDlg.GetCurrentFilter(); BOOL bAsLink = aDlg.IsAsLink(); lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, FALSE, pViewSh, pWindow, pView ); // append items for recording rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) ); rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) ); rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) ); rReq.Done(); } else { // error is handled in SvxOpenGraphicDialog::GetGraphic #if 0 USHORT nRes = 0; switch ( nError ) { case GRFILTER_OPENERROR: nRes = SCSTR_GRFILTER_OPENERROR; break; case GRFILTER_IOERROR: nRes = SCSTR_GRFILTER_IOERROR; break; case GRFILTER_FORMATERROR: nRes = SCSTR_GRFILTER_FORMATERROR; break; case GRFILTER_VERSIONERROR: nRes = SCSTR_GRFILTER_VERSIONERROR; break; case GRFILTER_FILTERERROR: nRes = SCSTR_GRFILTER_FILTERERROR; break; case GRFILTER_TOOBIG: nRes = SCSTR_GRFILTER_TOOBIG; break; } if ( nRes ) { InfoBox aInfoBox( pWindow, String(ScResId(nRes)) ); aInfoBox.Execute(); } else { ULONG nStreamError = GetGrfFilter()->GetLastError().nStreamError; if( ERRCODE_NONE != nStreamError ) ErrorHandler::HandleError( nStreamError ); } #endif } } } } /************************************************************************* |* |* FuInsertGraphic::Destruktor |* \************************************************************************/ FuInsertGraphic::~FuInsertGraphic() { } /************************************************************************* |* |* FuInsertGraphic::Function aktivieren |* \************************************************************************/ void FuInsertGraphic::Activate() { FuPoor::Activate(); } /************************************************************************* |* |* FuInsertGraphic::Function deaktivieren |* \************************************************************************/ void FuInsertGraphic::Deactivate() { FuPoor::Deactivate(); } /************************************************************************* |* |* FuInsertMedia::Konstruktor |* \************************************************************************/ FuInsertMedia::FuInsertMedia( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, SdrModel* pDoc, SfxRequest& rReq ) : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq) { ::rtl::OUString aURL; const SfxItemSet* pReqArgs = rReq.GetArgs(); bool bAPI = false; if( pReqArgs ) { const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) ); if( pStringItem ) { aURL = pStringItem->GetValue(); bAPI = aURL.getLength(); } } if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( pWindow, aURL ) ) { Size aPrefSize; if( pWin ) pWin->EnterWait(); if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) ) { if( pWin ) pWin->LeaveWait(); if( !bAPI ) ::avmedia::MediaWindow::executeFormatErrorBox( pWindow ); } else { lcl_InsertMedia( aURL, bAPI, pViewSh, pWindow, pView, aPrefSize ); if( pWin ) pWin->LeaveWait(); } } } /************************************************************************* |* |* FuInsertMedia::Destruktor |* \************************************************************************/ FuInsertMedia::~FuInsertMedia() { } /************************************************************************* |* |* FuInsertMedia::Function aktivieren |* \************************************************************************/ void FuInsertMedia::Activate() { FuPoor::Activate(); } /************************************************************************* |* |* FuInsertMedia::Function deaktivieren |* \************************************************************************/ void FuInsertMedia::Deactivate() { FuPoor::Deactivate(); } ption> LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-10-23com::sun::star->css in include/sot to include/typelibNoel Grandin
Change-Id: I9cd92b53370a6b6018d2f7c648890f9c014a27de
2015-10-12Replace "SAL_OVERRIDE" with "override" in LIBO_INTERNAL_ONLY codeStephan Bergmann
Change-Id: I2ea407acd763ef2d7dae2d3b8f32525523ac8274
2015-09-14boost->stdCaolán McNamara
Change-Id: I3fd9e1599c5ad812879a58cf1dabbcd393105e1c Reviewed-on: https://gerrit.libreoffice.org/18564 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2015-09-12Use forward declaration and reduce include scopeMatteo Casalin
Change-Id: I4456629dfc242d78f2c63c0b83d00afc3cdd23e7
2015-07-10vcl: remove boost/signal2/signal.hpp from headerMichael Stahl
The most relevant signal member function appears to be connect(), so let's create a wrapper function for that now, without the more esoteric ordering features for now. Move the signal member itself to a new pImpl. The benefits are worth it: preprocessor input reduced by 2.8GB, that's 9% of the total (excluding system headers which are not counted because they don't generate dependencies). Change-Id: I0aaeda51a5630a348bb12c81a83f67afbd508a14
2015-04-09svtools: apply vcl::window refcounting changesNoel Grandin
Change-Id: I308f045eaf5c50de26175a2f00f8b0791cdd8ab9 Conflicts: svtools/source/control/tabbar.cxx
2015-02-16boost::foo_ptr->std::foo_ptrCaolán McNamara
Change-Id: I9219619b538b6530a89f5932ac51eb3b62eb396a
2014-09-23fdo#82577: Handle WindowNoel Grandin
Put the VCL Window class in the vcl namespace. Avoids clash with the X11 Window typedef. Change-Id: Ib1beb7ab4ad75562a42aeb252732a073d25eff1a
2014-03-26First batch of adding SAL_OVERRRIDE to overriding function declarationsStephan Bergmann
...mostly done with a rewriting Clang plugin, with just some manual tweaking necessary to fix poor macro usage. Change-Id: I71fa20213e86be10de332ece0aa273239df7b61a
2013-11-09fdo#65108 inter-module includes <> include/svtoolsNorbert Thiebaud
Change-Id: I7e004e1e4fbc2141ff421af6be0e8bf5a026b189
2013-10-23fixincludeguards.sh: include/s*Thomas Arnhold
Change-Id: I57fcfd442d2b5815e7c07a9cbd660f3698168dee
2013-04-23execute move of global headersBjoern Michaelsen
see https://gerrit.libreoffice.org/#/c/3367/ and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a