summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2009-05-22 07:24:11 +0000
committerPhilipp Lohmann <pl@openoffice.org>2009-05-22 07:24:11 +0000
commit5b99d44a1176b803e1db3e0bfa23fb63105e703a (patch)
treea87bb5cd0483b6f6c0cee49823f9b727a3baada7 /basctl
parent04e36071737ccca11f77d2c943248b08d66e76d6 (diff)
#i92516# move printing to XRenderable
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/basicrenderable.cxx125
-rw-r--r--basctl/source/basicide/basicrenderable.hxx79
2 files changed, 204 insertions, 0 deletions
diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
new file mode 100644
index 000000000000..175404d0dd25
--- /dev/null
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * 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: basidesh.hxx,v $
+ * $Revision: 1.10 $
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "basicrenderable.hxx"
+#include "bastypes.hxx"
+
+#include "com/sun/star/awt/XDevice.hpp"
+#include "toolkit/awt/vclxdevice.hxx"
+#include "vcl/print.hxx"
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace basicide;
+
+BasicRenderable::~BasicRenderable()
+{
+}
+
+Printer* BasicRenderable::getPrinter ( const Sequence<beans::PropertyValue >& i_xOptions )
+{
+ Printer* pPrinter = NULL;
+ sal_Int32 nProps = i_xOptions.getLength();
+ const beans::PropertyValue* pProps = i_xOptions.getConstArray();
+ for( sal_Int32 i = 0; i < nProps; i++ )
+ {
+ if( pProps[i].Name.equalsAscii( "RenderDevice" ) )
+ {
+ Reference<awt::XDevice> xRenderDevice;
+
+ if( pProps[i].Value >>= xRenderDevice )
+ {
+ VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice);
+ OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
+ pPrinter = dynamic_cast<Printer*>(pOut);
+ break;
+ }
+ }
+ }
+ return pPrinter;
+}
+
+sal_Int32 SAL_CALL BasicRenderable::getRendererCount (
+ const Any& i_rSelection, const Sequence<beans::PropertyValue >& i_xOptions
+ ) throw (lang::IllegalArgumentException, RuntimeException)
+{
+ sal_Int32 nCount = 0;
+ if( mpWindow )
+ {
+ Printer* pPrinter = getPrinter( i_xOptions );
+ if( pPrinter )
+ nCount = mpWindow->countPages( pPrinter );
+ else
+ throw lang::IllegalArgumentException();
+ }
+
+ return nCount;
+}
+
+Sequence<beans::PropertyValue> SAL_CALL BasicRenderable::getRenderer (
+ sal_Int32 nRenderer, const Any& rSelection, const Sequence<beans::PropertyValue>& i_xOptions
+ ) throw (lang::IllegalArgumentException, RuntimeException)
+{
+ Sequence< beans::PropertyValue > aVals;
+ // insert page size here
+ Printer* pPrinter = getPrinter( i_xOptions );
+ // no renderdevice is legal; the first call is to get our print ui options
+ if( pPrinter )
+ {
+ Size aPageSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
+
+ aVals.realloc( 1 );
+ aVals[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
+ awt::Size aSize;
+ aSize.Width = aPageSize.Width();
+ aSize.Height = aPageSize.Height();
+ aVals[0].Value <<= aSize;
+ }
+
+ return aVals;
+}
+
+void SAL_CALL BasicRenderable::render (
+ sal_Int32 nRenderer, const Any& rSelection,
+ const Sequence<beans::PropertyValue>& i_xOptions
+ ) throw (lang::IllegalArgumentException, RuntimeException)
+{
+ if( mpWindow )
+ {
+ Printer* pPrinter = getPrinter( i_xOptions );
+ if( pPrinter )
+ mpWindow->printPage( nRenderer, pPrinter );
+ else
+ throw lang::IllegalArgumentException();
+ }
+}
+
+
diff --git a/basctl/source/basicide/basicrenderable.hxx b/basctl/source/basicide/basicrenderable.hxx
new file mode 100644
index 000000000000..1275f0071782
--- /dev/null
+++ b/basctl/source/basicide/basicrenderable.hxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * 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: basidesh.hxx,v $
+ * $Revision: 1.10 $
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BASICRENDERABLE_HXX
+#define _BASICRENDERABLE_HXX
+
+#include "com/sun/star/view/XRenderable.hpp"
+#include "cppuhelper/compbase1.hxx"
+
+class IDEBaseWindow;
+class Printer;
+
+namespace basicide
+{
+class BasicRenderable :
+ public cppu::WeakComponentImplHelper1< com::sun::star::view::XRenderable >
+{
+ IDEBaseWindow* mpWindow;
+ osl::Mutex maMutex;
+
+ Printer* getPrinter( const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue >& xOptions );
+public:
+ BasicRenderable( IDEBaseWindow* pWin )
+ : cppu::WeakComponentImplHelper1< com::sun::star::view::XRenderable >( maMutex )
+ , mpWindow( pWin )
+ {
+ }
+
+ virtual ~BasicRenderable();
+
+ // XRenderable
+ virtual sal_Int32 SAL_CALL getRendererCount (
+ const com::sun::star::uno::Any& aSelection,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue >& xOptions)
+ throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException);
+
+ virtual com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> SAL_CALL getRenderer (
+ sal_Int32 nRenderer,
+ const com::sun::star::uno::Any& rSelection,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rxOptions)
+ throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL render (
+ sal_Int32 nRenderer,
+ const com::sun::star::uno::Any& rSelection,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rxOptions)
+ throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException);
+
+};
+
+} // namespace
+
+#endif