Hi Mikhail,

Sorry I found my last mail did not reach the mailing list, so this is a resending.

In attachment is the patch I made after our last discussion, sorry for being late, but I've been trying and failed to find out the cause of a defect in it: although the temporary frame is set with the "MakeVisible" property false, a frame with oversize zoom rate pops out and vanishes in a second when print() is called.

Could you please have a look at the patch and see if something is missed?

Thank you and Best Regards,


Mikhail Voitenko
Hi Felix,

As we have discussed, there is still a problem with printing of embedded objects in running state. As we have recognized the problem was the missing view of the objects. The only way to fix the problem seems to be creation of hidden view in this case.

Lets first integrate the solution into the embedded object implementation. Later it could be moved to the document implementation to allow printing of documents without view.

So instead of requesting of XPrintable in doVerb() method, I would suggest to create a new method DocumentHolder::PrintDocument(). It should check whether there is m_xFrame member, if there is one the method can just get XPrintable interface from the document and print it.

If there is no m_xFrame, that means that the document has no view and a temporary frame should be created and closed after printing. The creation should be similar to the implementation in DocumentHolder::GetDocFrame() implementation.

You can probably start with investigation of the mentioned implementation and implementing of DocumentHolder::PrintDocument() method. We can discuss it tomorrow on irc meeting.

Thanks,
Mikhail.


Index: embeddedobj/source/commonembedding/embedobj.cxx
===================================================================
--- embeddedobj/source/commonembedding/embedobj.cxx     (revision 267538)
+++ embeddedobj/source/commonembedding/embedobj.cxx     (working copy)
@@ -88,7 +88,7 @@
                if ( m_aVerbTable[nInd][0] == nVerb )
                        return m_aVerbTable[nInd][1];
 
-       throw lang::IllegalArgumentException(); // TODO: unexpected verb 
provided
+       return -1;
 }
 
 //----------------------------------------------
@@ -547,18 +547,18 @@
                                                                                
uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) 
);
 
        // for internal documents this call is just a duplicate of changeState
-       sal_Int32 nNewState = -1;
-       try
-       {
-               nNewState = ConvertVerbToState_Impl( nVerbID );
-       }
-       catch( uno::Exception& )
-       {}
+       sal_Int32 nNewState = ConvertVerbToState_Impl( nVerbID );
 
        if ( nNewState == -1 )
        {
-               // TODO/LATER: Save Copy as... verb ( -8 ) is implemented by 
container
+               // TODO/LATER: Save Copy as... verb ( 
embed::EmbedVerbs::OLEVERB_SAVECOPYAS ) is implemented by container
                // TODO/LATER: check if the verb is a supported one and if it 
is produce related operation
+        if ( nVerbID == embed::EmbedVerbs::OLEVERB_PRINT )
+        {
+            if ( m_nObjectState == embed::EmbedStates::LOADED )
+                SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
+            m_pDocHolder->PrintDocument();
+        }
        }
        else
                changeState( nNewState );
Index: embeddedobj/source/general/docholder.cxx
===================================================================
--- embeddedobj/source/general/docholder.cxx    (revision 267538)
+++ embeddedobj/source/general/docholder.cxx    (working copy)
@@ -77,6 +77,9 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/embed/StateChangeInProgressException.hpp>
 
+#include <com/sun/star/view/XPrintable.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
 #include <com/sun/star/embed/EmbedMisc.hpp>
 #include <com/sun/star/embed/EmbedStates.hpp>
 #include <osl/diagnose.h>
@@ -531,7 +534,7 @@
 
     if ( m_xComponent.is() )
        {
-        if ( !LoadDocToFrame( sal_True ) )
+        if ( !LoadDocToFrame( sal_True, m_xFrame ) )
         {
             CloseFrame();
             return sal_False;
@@ -924,7 +927,7 @@
         // TODO/LATER: get it for the real aspect
         awt::Size aSize;
         GetExtent( embed::Aspects::MSOLE_CONTENT, &aSize );
-        LoadDocToFrame(sal_False);
+        LoadDocToFrame( sal_False, m_xFrame );
 
                if ( xOwnLM.is() )
                {
@@ -1013,19 +1016,19 @@
        }
 
        if ( m_xFrame.is() )
-        LoadDocToFrame(sal_False);
+        LoadDocToFrame( sal_False, m_xFrame );
 }
 
 //---------------------------------------------------------------------------
-sal_Bool DocumentHolder::LoadDocToFrame( sal_Bool bInPlace )
+sal_Bool DocumentHolder::LoadDocToFrame( sal_Bool bInPlace, uno::Reference< 
frame::XFrame >& xFrame )
 {
-    if ( m_xFrame.is() && m_xComponent.is() )
+    if ( xFrame.is() && m_xComponent.is() )
        {
         uno::Reference < frame::XModel > xDoc( m_xComponent, uno::UNO_QUERY );
         if ( xDoc.is() )
         {
             // load new document in to the frame
-            uno::Reference< frame::XComponentLoader > xComponentLoader( 
m_xFrame, uno::UNO_QUERY );
+            uno::Reference< frame::XComponentLoader > xComponentLoader( 
xFrame, uno::UNO_QUERY );
             if( !xComponentLoader.is() )
                 throw uno::RuntimeException();
 
@@ -1063,7 +1066,7 @@
         {
             uno::Reference < frame::XSynchronousFrameLoader > xLoader( 
m_xComponent, uno::UNO_QUERY );
             if ( xLoader.is() )
-                return xLoader->load( uno::Sequence < beans::PropertyValue 
>(), m_xFrame );
+                return xLoader->load( uno::Sequence < beans::PropertyValue 
>(), xFrame );
             else
                 return sal_False;
         }
@@ -1366,3 +1369,55 @@
     // deactivation is too unspecific to be useful; usually we only trigger 
code from activation
     // so UIDeactivation is actively triggered by the container
 }
+
+void DocumentHolder::PrintDocument()
+// TODO/LATER: This should be moved to the document implementation to allow 
printing of documents without view.
+{
+    if ( !m_xFrame.is() )
+    {
+        uno::Reference< lang::XSingleServiceFactory > xFrameFact(
+            m_xFactory->createInstance( ::rtl::OUString::createFromAscii( 
"com.sun.star.frame.TaskCreator" ) ),
+            uno::UNO_QUERY_THROW );
+
+        beans::NamedValue aArgs;
+        aArgs.Name = ::rtl::OUString::createFromAscii( "MakeVisible" );
+        aArgs.Value <<= sal_False;
+
+        uno::Sequence< uno::Any > aOutplaceFrameProps( 1 );
+        aOutplaceFrameProps[0] <<= aArgs;
+
+        uno::Reference< frame::XFrame > xFrame;
+        xFrame.set( xFrameFact->createInstanceWithArguments( 
aOutplaceFrameProps ), uno::UNO_QUERY_THROW );
+
+        if ( LoadDocToFrame( sal_False, xFrame ) )
+        {        
+            uno::Reference < view::XPrintable > xDoc ( m_xComponent, 
uno::UNO_QUERY );
+            if ( xDoc.is() )
+            {
+                uno::Sequence < beans::PropertyValue > aPrinterArgs( 1 );
+                aPrinterArgs[0].Name = 
::rtl::OUString::createFromAscii("Wait");
+                aPrinterArgs[0].Value <<= sal_True;
+                xDoc->print( aPrinterArgs );
+            }
+        }
+
+        uno::Reference<util::XCloseable> xCloseable( xFrame,uno::UNO_QUERY );
+        if( xCloseable.is() )
+            try {
+                xCloseable->close( sal_True );
+            }
+            catch( const uno::Exception& ) {
+            }
+    }
+    else
+    {
+        uno::Reference < view::XPrintable > xDoc ( m_xComponent, 
uno::UNO_QUERY );
+        if ( xDoc.is() )
+        {
+            uno::Sequence < beans::PropertyValue > aPrinterArgs( 1 );
+            aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Wait");
+            aPrinterArgs[0].Value <<= sal_True;
+            xDoc->print( aPrinterArgs );
+        }        
+    }
+}
\ No newline at end of file
Index: embeddedobj/source/inc/docholder.hxx
===================================================================
--- embeddedobj/source/inc/docholder.hxx        (revision 267538)
+++ embeddedobj/source/inc/docholder.hxx        (working copy)
@@ -97,7 +97,8 @@
 
 
        ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > 
GetDocFrame();
-    sal_Bool LoadDocToFrame( sal_Bool );
+    sal_Bool LoadDocToFrame( sal_Bool,
+                ::com::sun::star::uno::Reference< 
::com::sun::star::frame::XFrame >& xFrame );
 
        ::com::sun::star::awt::Rectangle CalculateBorderedArea( const 
::com::sun::star::awt::Rectangle& aRect );
        ::com::sun::star::awt::Rectangle AddBorderToArea( const 
::com::sun::star::awt::Rectangle& aRect );
@@ -169,6 +170,8 @@
 
        void Show();
 
+    void PrintDocument();
+
        // sal_Bool SetVisArea( sal_Int64 nAspect, const 
::com::sun::star::awt::Rectangle& aRect );
        // sal_Bool GetVisArea( sal_Int64 nAspect, 
::com::sun::star::awt::Rectangle *pRect );
        sal_Bool SetExtent( sal_Int64 nAspect, const 
::com::sun::star::awt::Size& aSize );
Index: offapi/com/sun/star/embed/EmbedVerbs.idl
===================================================================
--- offapi/com/sun/star/embed/EmbedVerbs.idl    (revision 266626)
+++ offapi/com/sun/star/embed/EmbedVerbs.idl    (working copy)
@@ -77,6 +77,21 @@
         */
        const long MS_OLEVERB_DISCARDUNDOSTATE = -6;
 
+       
//------------------------------------------------------------------------
+       /** lets the object display its properties.
+        */
+       const long OLEVERB_PROPERTIES = -7;
+
+       
//------------------------------------------------------------------------
+       /** lets the object save copy as a file.
+        */
+       const long OLEVERB_SAVECOPYAS= -8;
+
+       
//------------------------------------------------------------------------
+       /** lets the object print itself.
+        */
+       const long OLEVERB_PRINT = -9;
+
 };
 
 //============================================================================
Index: officecfg/registry/data/org/openoffice/Office/Embedding.xcu
===================================================================
--- officecfg/registry/data/org/openoffice/Office/Embedding.xcu (revision 
266626)
+++ officecfg/registry/data/org/openoffice/Office/Embedding.xcu (working copy)
@@ -123,6 +123,21 @@
         <value>0</value>
       </prop>
     </node>
+    <node oor:name="DISCARDUNDOSTATE" oor:op="replace">
+      <prop oor:name="VerbUIName">
+        <value>Discard Undo State</value>
+        <value xml:lang="x-comment">Is not shown in UI. No translation is 
required.</value>
+      </prop>
+      <prop oor:name="VerbID">
+        <value>-6</value>
+      </prop>
+      <prop oor:name="VerbFlags">
+        <value>0</value>
+      </prop>
+      <prop oor:name="VerbAttributes">
+        <value>0</value>
+      </prop>
+    </node>
     <node oor:name="PROPERTIES" oor:op="replace">
       <prop oor:name="VerbUIName">
 
@@ -155,6 +170,22 @@
         <value>2</value>
       </prop>
     </node>
+    <node oor:name="PRINT" oor:op="replace">
+      <prop oor:name="VerbUIName">
+
+        <value xml:lang="en-US">P~rint</value>
+        <value xml:lang="x-comment">This verb will let the object be 
printed.</value>
+      </prop>
+      <prop oor:name="VerbID">
+        <value>-9</value>
+      </prop>
+      <prop oor:name="VerbFlags">
+        <value>0</value>
+      </prop>
+      <prop oor:name="VerbAttributes">
+        <value>2</value>
+      </prop>
+    </node>
   </node>
   <node oor:name="Objects">
     <node oor:name="970B1E81-CF2D-11CF-89CA-008029E4B0B1" oor:op="replace">
@@ -168,7 +199,7 @@
         <value>4294969728</value>
       </prop>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW IPACTIVATE PROPERTIES</value>
+        <value>PRIMARY SHOW IPACTIVATE PROPERTIES PRINT</value>
       </prop>
     </node>
     <node oor:name="4CAA7761-6B8B-11CF-89CA-008029E4B0B1" oor:op="replace">
@@ -182,7 +213,7 @@
         <value>2432</value>
       </prop>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW IPACTIVATE PROPERTIES</value>
+        <value>PRIMARY SHOW IPACTIVATE PROPERTIES PRINT</value>
       </prop>
     </node>
     <node oor:name="1A8A6701-DE58-11CF-89CA-008029E4B0B1" oor:op="replace">
@@ -196,7 +227,7 @@
         <value>2432</value>
       </prop>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW IPACTIVATE PROPERTIES</value>
+        <value>PRIMARY SHOW IPACTIVATE PROPERTIES PRINT</value>
       </prop>
     </node>
     <node oor:name="47BBB4CB-CE4C-4E80-A591-42D9AE74950F" oor:op="replace" 
install:module="calc">
@@ -208,7 +239,7 @@
       </prop>
       <prop oor:name="ObjectMiscStatus"/>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS</value>
+        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS 
PRINT</value>
       </prop>
     </node>
     <node oor:name="12DCAE26-281F-416F-A234-C3086127382E" oor:op="replace" 
install:module="chart">
@@ -222,7 +253,7 @@
         <value>1</value>
       </prop>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE</value>
+        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE PRINT</value>
       </prop>
     </node>
     <node oor:name="4BAB8970-8A3B-45B3-991C-CBEEAC6BD5E3" oor:op="replace" 
install:module="draw">
@@ -234,7 +265,7 @@
       </prop>
       <prop oor:name="ObjectMiscStatus"/>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS</value>
+        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS 
PRINT</value>
       </prop>
     </node>
     <node oor:name="9176E48A-637A-4D1F-803B-99D9BFAC1047" oor:op="replace" 
install:module="impress">
@@ -246,7 +277,7 @@
       </prop>
       <prop oor:name="ObjectMiscStatus"/>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS</value>
+        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS 
PRINT</value>
       </prop>
     </node>
     <node oor:name="078B7ABA-54FC-457F-8551-6147E776A997" oor:op="replace" 
install:module="math">
@@ -260,7 +291,7 @@
         <value>8589934592</value>
       </prop>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS</value>
+        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS 
PRINT</value>
       </prop>
     </node>
     <node oor:name="8BC6B165-B1B2-4EDD-AA47-DAE2EE689DD6" oor:op="replace" 
install:module="writer">
@@ -272,7 +303,7 @@
       </prop>
       <prop oor:name="ObjectMiscStatus"/>
       <prop oor:name="ObjectVerbs">
-        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS</value>
+        <value>PRIMARY SHOW OPEN HIDE UIACTIVATE IPACTIVATE SAVECOPYAS 
PRINT</value>
       </prop>
     </node>
   </node>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@framework.openoffice.org
For additional commands, e-mail: dev-h...@framework.openoffice.org

Reply via email to