[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sw/inc sw/source

Michael Stahl mst at kemper.freedesktop.org
Wed Dec 21 07:46:57 PST 2011


 sw/inc/printdata.hxx              |   11 +++++++++--
 sw/inc/unotxdoc.hxx               |    3 +--
 sw/source/core/view/printdata.cxx |   14 ++++++++++++--
 sw/source/ui/inc/view.hxx         |    3 +--
 sw/source/ui/uiview/view.cxx      |   18 ++++--------------
 sw/source/ui/uno/unotxdoc.cxx     |   33 +++++++++++++++++++++------------
 sw/source/ui/uno/unotxvw.cxx      |    8 --------
 7 files changed, 48 insertions(+), 42 deletions(-)

New commits:
commit 871ad55dccbd7121e005a66e3c51f55a236d2b04
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Dec 21 16:39:22 2011 +0100

    sw: fdo#39159 fdo#40482: temp selection print doc:
    
    Ensure that the printing temp selection document is not destroyed
    prematurely by SwXTextView::NotifySelChanged, called via
    ViewOptionAdjustStop, by retaining the temp doc object shell not
    at the View but in SwRenderData.
    
    Not restoring the view options for selections does not actually work,
    because having a selection surprisingly does not imply printing a
    temp document: the preview also uses a selection.
    (view option regression from cd690d2e72be410058376c416a40ff5d918fb0f7)
    (cherry picked from commit 89d2733e16ae6233deea6bef3193bd45c89b854c)

diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx
index 8d29336..02d56b8 100644
--- a/sw/inc/printdata.hxx
+++ b/sw/inc/printdata.hxx
@@ -28,10 +28,10 @@
 #ifndef SW_PRINTDATA_HXX
 #define SW_PRINTDATA_HXX
 
-
 #include <sal/types.h>
 #include <rtl/ustring.hxx>
 #include <vcl/print.hxx>
+#include <sfx2/objsh.hxx>
 
 #include <boost/scoped_ptr.hpp>
 
@@ -244,6 +244,10 @@ class SwRenderData
 
     rtl::OUString               m_aPageRange;
 
+    // temp print document -- must live longer than m_pViewOptionAdjust!
+    // also this is a Lock and not a Ref because Ref does not delete the doc
+    SfxObjectShellLock m_xTempDocShell;
+
     // the view options to be applied for printing
     ::boost::scoped_ptr<SwViewOptionAdjust_Impl> m_pViewOptionAdjust;
 
@@ -266,9 +270,12 @@ public:
     void CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt, OutputDevice *pOutDev );
     void DeletePostItData();
 
+    SfxObjectShellLock const& GetTempDocShell() const;
+    void SetTempDocShell(SfxObjectShellLock const&);
+
     bool IsViewOptionAdjust() const  { return m_pViewOptionAdjust != 0; }
     bool NeedNewViewOptionAdjust( const ViewShell& ) const;
-    void ViewOptionAdjustStart( ViewShell &rSh, const SwViewOption &rViewOptions, bool bIsTmpSelection );
+    void ViewOptionAdjustStart( ViewShell &rSh, const SwViewOption &rViewOptions);
     void ViewOptionAdjust( SwPrintData const* const pPrtOptions );
     void ViewOptionAdjustStop();
 
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 5d61a9a..42d646f 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -589,10 +589,9 @@ class SwViewOptionAdjust_Impl
 {
     ViewShell &    m_rShell;
     SwViewOption    m_aOldViewOptions;
-    bool m_bIsTmpSelection;
 
 public:
-    SwViewOptionAdjust_Impl( ViewShell& rSh, const SwViewOption &rViewOptions, bool bIsTmpSelection );
+    SwViewOptionAdjust_Impl( ViewShell& rSh, const SwViewOption &rViewOptions );
     ~SwViewOptionAdjust_Impl();
     void AdjustViewOptions( SwPrintData const* const pPrtOptions );
     bool checkShell( const ViewShell& rCompare ) const
diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx
index 47b1fa3..870ecbe 100644
--- a/sw/source/core/view/printdata.cxx
+++ b/sw/source/core/view/printdata.cxx
@@ -93,20 +93,30 @@ void SwRenderData::DeletePostItData()
     }
 }
 
+SfxObjectShellLock const& SwRenderData::GetTempDocShell() const
+{
+    return m_xTempDocShell;
+}
+void SwRenderData::SetTempDocShell(SfxObjectShellLock const& xShell)
+{
+    m_xTempDocShell = xShell;
+}
+
 bool SwRenderData::NeedNewViewOptionAdjust( const ViewShell& rCompare ) const
 {
     return m_pViewOptionAdjust ? ! m_pViewOptionAdjust->checkShell( rCompare ) : true;
 }
 
 
-void SwRenderData::ViewOptionAdjustStart( ViewShell &rSh, const SwViewOption &rViewOptions, bool bIsTmpSelection )
+void SwRenderData::ViewOptionAdjustStart(
+        ViewShell &rSh, const SwViewOption &rViewOptions)
 {
     if (m_pViewOptionAdjust)
     {
         OSL_FAIL("error: there should be no ViewOptionAdjust active when calling this function" );
     }
     m_pViewOptionAdjust.reset(
-            new SwViewOptionAdjust_Impl( rSh, rViewOptions, bIsTmpSelection ));
+            new SwViewOptionAdjust_Impl( rSh, rViewOptions ));
 }
 
 
diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx
index 45e4405..1290883 100755
--- a/sw/source/ui/inc/view.hxx
+++ b/sw/source/ui/inc/view.hxx
@@ -643,8 +643,7 @@ public:
 
     void NotifyDBChanged();
 
-    SfxObjectShellLock & GetTmpSelectionDoc();
-    SfxObjectShellLock & GetOrCreateTmpSelectionDoc();
+    SfxObjectShellLock CreateTmpSelectionDoc();
 
     void        AddTransferable(SwTransferable& rTransferable);
 
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index d9489a6..b3bbf87 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -1798,22 +1798,12 @@ void SwView::NotifyDBChanged()
 }
 
 /*--------------------------------------------------------------------
-    Beschreibung:   Drucken
+    Printing
  --------------------------------------------------------------------*/
-SfxObjectShellLock & SwView::GetTmpSelectionDoc()
+SfxObjectShellLock SwView::CreateTmpSelectionDoc()
 {
-    return GetViewImpl()->GetTmpSelectionDoc();
-}
-
-SfxObjectShellLock & SwView::GetOrCreateTmpSelectionDoc()
-{
-    SfxObjectShellLock &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc();
-    if (!rxTmpDoc.Is())
-    {
-        SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl();
-        rxTmpDoc = pImpl->BuildTmpSelectionDoc();
-    }
-    return rxTmpDoc;
+    SwXTextView *const pImpl = GetViewImpl()->GetUNOObject_Impl();
+    return pImpl->BuildTmpSelectionDoc();
 }
 
 void SwView::AddTransferable(SwTransferable& rTransferable)
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
index 6ac9808..120cb6d 100644
--- a/sw/source/ui/uno/unotxdoc.cxx
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -2425,7 +2425,18 @@ SwDoc * SwXTextDocument::GetRenderDoc(
             const TypeId aSwViewTypeId = TYPE(SwView);
             if (rpView  &&  rpView->IsA(aSwViewTypeId))
             {
-                SfxObjectShellLock xDocSh(((SwView*)rpView)->GetOrCreateTmpSelectionDoc());
+                if (!m_pRenderData)
+                {
+                    OSL_FAIL("GetRenderDoc: no renderdata");
+                    return 0;
+                }
+                SwView *const pSwView(static_cast<SwView *>(rpView));
+                SfxObjectShellLock xDocSh(m_pRenderData->GetTempDocShell());
+                if (!xDocSh.Is())
+                {
+                    xDocSh = pSwView->CreateTmpSelectionDoc();
+                    m_pRenderData->SetTempDocShell(xDocSh);
+                }
                 if (xDocSh.Is())
                 {
                     pDoc = ((SwDocShell*)&xDocSh)->GetDoc();
@@ -2555,7 +2566,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
                 if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) )
                     m_pRenderData->ViewOptionAdjustStop();
                 if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust())
-                    m_pRenderData->ViewOptionAdjustStart( *pViewShell, *pViewShell->GetViewOptions(), rSelection.hasValue() );
+                {
+                    m_pRenderData->ViewOptionAdjustStart(
+                        *pViewShell, *pViewShell->GetViewOptions() );
+                }
             }
 
             m_pRenderData->MakeSwPrtOptions( pRenderDocShell,
@@ -3842,21 +3856,16 @@ void SwXDocumentPropertyHelper::onChange()
        m_pDoc->SetModified();
 }
 
-SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( ViewShell& rSh, const SwViewOption &rViewOptions, bool bIsTmpSelection ) :
-    m_rShell( rSh ),
-    m_aOldViewOptions( rViewOptions ),
-    m_bIsTmpSelection( bIsTmpSelection )
+SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl(
+            ViewShell& rSh, const SwViewOption &rViewOptions)
+    : m_rShell( rSh )
+    , m_aOldViewOptions( rViewOptions )
 {
 }
 
 SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl()
 {
-    //fdo#39159 don't restore original view options on a temporary document
-    //selection, it triggers throwing away the current view. Presumably we can
-    //forget about it in the temporary document case as unimportant to restore
-    //the original view settings
-    if (!m_bIsTmpSelection)
-        m_rShell.ApplyViewOptions( m_aOldViewOptions );
+    m_rShell.ApplyViewOptions( m_aOldViewOptions );
 }
 
 void
diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx
index 3635eb4..aa676ca 100644
--- a/sw/source/ui/uno/unotxvw.cxx
+++ b/sw/source/ui/uno/unotxvw.cxx
@@ -882,14 +882,6 @@ void SwXTextView::NotifySelChanged()
 {
     OSL_ENSURE( m_pView, "view is missing" );
 
-    // destroy temporary document with selected text that is used
-    // in PDF export of (multi-)selections.
-    if (m_pView && m_pView->GetTmpSelectionDoc().Is())
-    {
-        m_pView->GetTmpSelectionDoc()->DoClose();
-        m_pView->GetTmpSelectionDoc() = 0;
-    }
-
     uno::Reference< uno::XInterface >  xInt = (cppu::OWeakObject*)(SfxBaseController*)this;
 
      lang::EventObject aEvent(xInt);


More information about the Libreoffice-commits mailing list