Commits

Philipp Lohmann [pl]  committed 4997762

vcl120: #i115695# respond to a PrinterName property used by the application

  • Participants
  • Parent commits 75579af

Comments (0)

Files changed (1)

File sfx2/source/view/viewprn.cxx

 	sal_Bool		m_bOrigStatus;
 	sal_Bool		m_bNeedsChange;
 	sal_Bool		m_bApi;
+	sal_Bool        m_bTempPrinter;
 	util::DateTime	m_aLastPrinted;
 	::rtl::OUString	m_aLastPrintedBy;
 
     Sequence< beans::PropertyValue > getMergedOptions() const;
     const Any& getSelectionObject() const;
 public:
-    SfxPrinterController( const Any& i_rComplete,
+    SfxPrinterController( const boost::shared_ptr<Printer>& i_rPrinter,
+                          const Any& i_rComplete,
                           const Any& i_rSelection,
                           const Any& i_rViewProp,
                           const Reference< view::XRenderable >& i_xRender,
     virtual void jobFinished( com::sun::star::view::PrintableState );
 };
 
-SfxPrinterController::SfxPrinterController( const Any& i_rComplete,
+SfxPrinterController::SfxPrinterController( const boost::shared_ptr<Printer>& i_rPrinter,
+                                            const Any& i_rComplete,
                                             const Any& i_rSelection,
                                             const Any& i_rViewProp,
                                             const Reference< view::XRenderable >& i_xRender,
 										    SfxViewShell* pView,
                                             const uno::Sequence< beans::PropertyValue >& rProps
                                           )
-    : maCompleteSelection( i_rComplete )
+    : PrinterController( i_rPrinter)
+    , maCompleteSelection( i_rComplete )
     , maSelection( i_rSelection )
     , mxRenderable( i_xRender )
     , mpLastPrinter( NULL )
 	, m_bOrigStatus( sal_False )
 	, m_bNeedsChange( sal_False )
 	, m_bApi(i_bApi)
+	, m_bTempPrinter( i_rPrinter.get() != NULL )
 {
 	if ( mpViewShell )
 	{
 				rBind.Invalidate( SID_PRINTDOC );
 				rBind.Invalidate( SID_PRINTDOCDIRECT );
 				rBind.Invalidate( SID_SETUPPRINTER );
-				bCopyJobSetup = true;
+				bCopyJobSetup = ! m_bTempPrinter;
 				break;
 			}
 
         aSelection <<= GetObjectShell()->GetModel();
     Any aComplete( makeAny( GetObjectShell()->GetModel() ) );
     Any aViewProp( makeAny( xController ) );
+    boost::shared_ptr<Printer> aPrt;
     
-    boost::shared_ptr<vcl::PrinterController> pController( new SfxPrinterController( aComplete,
+    const beans::PropertyValue* pVal = rProps.getConstArray();
+    for( sal_Int32 i = 0; i < rProps.getLength(); i++ )
+    {
+        if( pVal[i].Name.equalsAscii( "PrinterName" ) )
+        {
+            aPrt.reset( new Printer( pVal[i].Name ) );
+            break;
+        }
+    }
+    
+    boost::shared_ptr<vcl::PrinterController> pController( new SfxPrinterController(
+                                                                               aPrt,
+                                                                               aComplete,
                                                                                aSelection,
                                                                                aViewProp,
                                                                                GetRenderable(),