Hi Mikhail,
After our last meeting I did some modification to set the mapmode and
size for the graphic, but afterwards paintbrush objects still prints
incorrectly small. I debugged a little bit and find the values of size
and mapmode normal ( compared to that of a similar sized DOC object ).
I'm not sure if there's something wrong in my patch, could you review it
for me please?
Best Regards,
Felix.
Index: ipclient.cxx
===================================================================
--- ipclient.cxx (revision 269064)
+++ ipclient.cxx (working copy)
@@ -50,6 +50,8 @@
#include <com/sun/star/embed/EmbedMisc.hpp>
#include <svtools/embedhlp.hxx>
+#include <svtools/filter.hxx>
+#include <unotools/ucbstreamhelper.hxx>
#include <vcl/svapp.hxx>
#include <sfx2/ipclient.hxx>
@@ -57,6 +59,7 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/dispatch.hxx>
+#include <sfx2/printer.hxx>
#include "workwin.hxx"
#include "guisaveas.hxx"
#include <sfx2/topfrm.hxx>
@@ -927,7 +930,7 @@
if ( m_pImp->m_xObject.is() )
{
sal_Bool bSaveCopyAs = sal_False;
- if ( nVerb == -8 ) // "Save Copy as..."
+ if ( nVerb == embed::EmbedVerbs::OLEVERB_SAVECOPYAS ) // "Save
Copy as..."
{
svt::EmbeddedObjectRef::TryRunningState( m_pImp->m_xObject );
// TODO/LATER: this special verb should disappear when
outplace activation is completely available
@@ -986,12 +989,12 @@
}
catch ( embed::UnreachableStateException& )
{
- if ( nVerb == 0 || nVerb ==
embed::EmbedVerbs::MS_OLEVERB_OPEN )
+ if ( nVerb ==
embed::EmbedVerbs::MS_OLEVERB_PRIMARY || nVerb ==
embed::EmbedVerbs::MS_OLEVERB_OPEN )
{
// a workaround for the default
verb, usually makes sence for alien objects
try
{
-
m_pImp->m_xObject->doVerb( -9 ); // open own view, a workaround verb that is
not visible
+
m_pImp->m_xObject->doVerb( embed::EmbedVerbs::OLEVERB_VIEWIMPORT ); // open own
view, a workaround verb that is not visible
if ( m_pImp->m_xObject->getCurrentState() ==
embed::EmbedStates::UI_ACTIVE )
{
@@ -1012,6 +1015,76 @@
nError =
ERRCODE_SO_GENERALERROR;
}
}
+ if ( nVerb == embed::EmbedVerbs::OLEVERB_PRINT )
+ {
+ try
+ {
+ nError = ERRCODE_SO_GENERALERROR;
+
+ SfxViewShell* pViewShell = GetViewShell();
+ if ( pViewShell )
+ {
+ SfxPrinter* pPrinter = pViewShell->GetPrinter(
TRUE );
+
+ if ( pPrinter && pPrinter->IsValid() )
+ {
+ if ( pPrinter->IsPrinting() )
+ nError = ERRCODE_SO_CANNOT_DOVERB_NOW;
+ else
+ {
+ SfxObjectShell* pObjectShell =
pViewShell->GetObjectShell();
+ if ( pObjectShell )
+ {
+ uno::Reference < io::XInputStream
> xStream = pObjectShell->GetEmbeddedObjectContainer().GetGraphicStream(
m_pImp->m_xObject );
+ if ( xStream.is() )
+ {
+ const sal_Int32
nConstBufferSize = 32000;
+ SvStream *pStream = new
SvMemoryStream( 32000, 32000 );
+ sal_Int32 nRead=0;
+ uno::Sequence < sal_Int8 >
aSequence ( nConstBufferSize );
+ do
+ {
+ nRead = xStream->readBytes
( aSequence, nConstBufferSize );
+ pStream->Write(
aSequence.getConstArray(), nRead );
+ }
+ while ( nRead ==
nConstBufferSize );
+ pStream->Seek(0);
+ if ( pStream )
+ {
+ awt::Size aSize =
m_pImp->m_xObject->getVisualAreaSize( m_pImp->m_nAspect );
+ MapMode aMap(
VCLUnoHelper::UnoEmbed2VCLMapUnit( m_pImp->m_xObject->getMapUnit(
m_pImp->m_nAspect ) ) );
+
+ GraphicFilter* pGF =
GraphicFilter::GetGraphicFilter();
+ Graphic* pGraphic = new
Graphic;
+ pGF->ImportGraphic(
*pGraphic, String(), *pStream );
+ pGraphic->SetPrefSize(
Size( aSize.Width, aSize.Height ) );
+ pGraphic->SetPrefMapMode(
aMap );
+
+ pPrinter->SetMapMode( aMap
);
+
+ String aTitle =
pObjectShell->GetTitle(0); // ToDo: doc title + object name
+ pPrinter->StartJob( aTitle
);
+ pPrinter->StartPage();
+ pGraphic->Draw(
(OutputDevice*)pPrinter, Point( 0, 0 ) );
+ pPrinter->EndPage();
+ pPrinter->EndJob();
+
+ DELETEZ( pGraphic );
+ DELETEZ( pStream );
+
+ nError = ERRCODE_NONE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ nError = ERRCODE_SO_GENERALERROR;
+ }
+ }
}
catch ( embed::StateChangeInProgressException& )
{
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@framework.openoffice.org
For additional commands, e-mail: dev-h...@framework.openoffice.org