diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-04-15 09:42:32 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-04-16 11:16:05 +0100 |
commit | eb1c0480050a1328287c4a85468afbec50b0e29d (patch) | |
tree | 044b94745a027b1620ebb5320731275dc86e7b18 | |
parent | 253ffdf2b0c22247e6208e0881838b1896c63116 (diff) |
Resolves: fdo#36815 enable printing WYSIWYG sidewindow comments
in order for that to happen the document has to be scaled down
so that the comments outside the border of the sheet of paper
can be brought inside the printable area
Change-Id: Ifafb8eec10a4ea3ea0014097728888603e61e5a4
-rw-r--r-- | sw/inc/PostItMgr.hxx | 3 | ||||
-rw-r--r-- | sw/inc/SidebarWin.hxx | 2 | ||||
-rw-r--r-- | sw/inc/printdata.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/uibase/docvw/PostItMgr.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/uibase/docvw/SidebarTxtControl.cxx | 40 | ||||
-rw-r--r-- | sw/source/core/uibase/docvw/SidebarTxtControl.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/uibase/docvw/SidebarWin.cxx | 55 | ||||
-rw-r--r-- | sw/source/core/uibase/inc/optpage.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/view/printdata.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/view/vprint.cxx | 49 | ||||
-rw-r--r-- | sw/source/ui/config/optdlg.src | 1 | ||||
-rw-r--r-- | sw/source/ui/config/optpage.cxx | 6 | ||||
-rw-r--r-- | sw/uiconfig/swriter/ui/printoptionspage.ui | 23 |
14 files changed, 200 insertions, 8 deletions
diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index 304321508208..4f994199dd2e 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -33,6 +33,7 @@ #include <SidebarWindowsTypes.hxx> #include <svl/lstner.hxx> +class OutputDevice; class SwWrtShell; class SwDoc; class SwView; @@ -279,6 +280,8 @@ class SwPostItMgr: public SfxListener const sal_Int32 nIndex ); void GetAllSidebarWinForFrm( const SwFrm& rFrm, std::vector< Window* >* pChildren ); + + void DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage); }; #endif diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx index 630ef1668242..8ab89a501606 100644 --- a/sw/inc/SidebarWin.hxx +++ b/sw/inc/SidebarWin.hxx @@ -176,6 +176,8 @@ class SwSidebarWin : public Window void ChangeSidebarItem( SwSidebarItem& rSidebarItem ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE; + virtual void Draw(OutputDevice* pDev, const Point&, const Size&, sal_uLong) SAL_OVERRIDE; + protected: virtual void DataChanged( const DataChangedEvent& aEvent) SAL_OVERRIDE; virtual void LoseFocus() SAL_OVERRIDE; diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 4ff41e202acd..748c6940e724 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -292,6 +292,7 @@ public: #define POSTITS_ONLY 1 #define POSTITS_ENDDOC 2 #define POSTITS_ENDPAGE 3 +#define POSTITS_INMARGINS 4 namespace sw { diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index eb3133a39f98..a5cbf3bf3665 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6172,7 +6172,7 @@ static void lcl_paintBitmapExToRect(OutputDevice *pOut, const Point& aPoint, con SwAlignRect( aPageRect, _pViewShell ); const SwPostItMgr *pMgr = _pViewShell->GetPostItMgr(); - if (pMgr && pMgr->ShowNotes() && pMgr->HasNotes()) // do not show anything in print preview + if (pMgr /*&& pMgr->ShowNotes()*/ && pMgr->HasNotes()) // do not show anything in print preview { sal_Int32 nScrollerHeight = pMgr->GetSidebarScrollerHeight(); const Rectangle &aVisRect = _pViewShell->VisArea().SVRect(); diff --git a/sw/source/core/uibase/docvw/PostItMgr.cxx b/sw/source/core/uibase/docvw/PostItMgr.cxx index 4193ad61c7e3..e63ce8b7b2cf 100644 --- a/sw/source/core/uibase/docvw/PostItMgr.cxx +++ b/sw/source/core/uibase/docvw/PostItMgr.cxx @@ -823,6 +823,22 @@ bool SwPostItMgr::BorderOverPageBorder(unsigned long aPage) const return false; } +void SwPostItMgr::DrawNotesForPage(OutputDevice *pOutDev, sal_uInt32 nPage) +{ + assert(nPage < mPages.size()); + if (nPage >= mPages.size()) + return; + for(SwSidebarItem_iterator i = mPages[nPage]->mList->begin(); i != mPages[nPage]->mList->end(); ++i) + { + SwSidebarWin* pPostIt = (*i)->pPostIt; + if (!pPostIt) + continue; + Point aPoint(mpEditWin->PixelToLogic(pPostIt->GetPosPixel())); + Size aSize(pPostIt->PixelToLogic(pPostIt->GetSizePixel())); + pPostIt->Draw(pOutDev, aPoint, aSize, 0); + } +} + void SwPostItMgr::Scroll(const long lScroll,const unsigned long aPage) { OSL_ENSURE((lScroll % GetScrollSize() )==0,"SwPostItMgr::Scroll: scrolling by wrong value"); diff --git a/sw/source/core/uibase/docvw/SidebarTxtControl.cxx b/sw/source/core/uibase/docvw/SidebarTxtControl.cxx index 421bd0a8f3f0..4e84a0be9333 100644 --- a/sw/source/core/uibase/docvw/SidebarTxtControl.cxx +++ b/sw/source/core/uibase/docvw/SidebarTxtControl.cxx @@ -119,6 +119,46 @@ void SidebarTxtControl::RequestHelp(const HelpEvent &rEvt) } } +void SidebarTxtControl::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, sal_uLong) +{ + if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + { + if ( mrSidebarWin.IsMouseOverSidebarWin() || + HasFocus() ) + { + pDev->DrawGradient( Rectangle( Point(0,0) + rPt, PixelToLogic(GetSizePixel()) ), + Gradient( GradientStyle_LINEAR, + mrSidebarWin.ColorDark(), + mrSidebarWin.ColorDark() ) ); + } + else + { + pDev->DrawGradient( Rectangle( Point(0,0) + rPt, PixelToLogic(GetSizePixel()) ), + Gradient( GradientStyle_LINEAR, + mrSidebarWin.ColorLight(), + mrSidebarWin.ColorDark())); + } + } + + if ( GetTextView() ) + { + GetTextView()->GetOutliner()->Draw(pDev, Rectangle(rPt, rSz)); + } + + if ( mrSidebarWin.GetLayoutStatus()==SwPostItHelper::DELETED ) + { + SetLineColor(mrSidebarWin.GetChangeColor()); + pDev->DrawLine( PixelToLogic( GetPosPixel(), pDev->GetMapMode() ), + PixelToLogic( GetPosPixel() + + Point( GetSizePixel().Width(), + GetSizePixel().Height() ), pDev->GetMapMode() ) ); + pDev->DrawLine( PixelToLogic( GetPosPixel() + + Point( GetSizePixel().Width(),0), pDev->GetMapMode() ), + PixelToLogic( GetPosPixel() + + Point( 0, GetSizePixel().Height() ), pDev->GetMapMode() ) ); + } +} + void SidebarTxtControl::Paint( const Rectangle& rRect) { if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) diff --git a/sw/source/core/uibase/docvw/SidebarTxtControl.hxx b/sw/source/core/uibase/docvw/SidebarTxtControl.hxx index ae524a094f71..edb9efd8b9d2 100644 --- a/sw/source/core/uibase/docvw/SidebarTxtControl.hxx +++ b/sw/source/core/uibase/docvw/SidebarTxtControl.hxx @@ -66,6 +66,8 @@ class SidebarTxtControl : public Control DECL_LINK( OnlineSpellCallback, SpellCallbackInfo*); virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE; + + virtual void Draw(OutputDevice* pDev, const Point&, const Size&, sal_uLong) SAL_OVERRIDE; }; } } // end of namespace sw::sidebarwindows diff --git a/sw/source/core/uibase/docvw/SidebarWin.cxx b/sw/source/core/uibase/docvw/SidebarWin.cxx index 930b95b9a460..ef6d4d35faf1 100644 --- a/sw/source/core/uibase/docvw/SidebarWin.cxx +++ b/sw/source/core/uibase/docvw/SidebarWin.cxx @@ -72,10 +72,12 @@ #include <ndtxt.hxx> #include <sw_primitivetypes2d.hxx> +#include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <drawinglayer/primitive2d/primitivetools2d.hxx> #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <drawinglayer/processor2d/processorfromoutputdevice.hxx> #include <drawinglayer/primitive2d/shadowprimitive2d.hxx> namespace sw { namespace sidebarwindows { @@ -224,6 +226,59 @@ void SwSidebarWin::Paint( const Rectangle& rRect) } } +void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, sal_uLong nInFlags) +{ + if (mpMetadataAuthor->IsVisible() ) + { + //draw left over space + if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) + { + pDev->SetFillColor(COL_BLACK); + } + else + { + pDev->SetFillColor(mColorDark); + } + pDev->SetLineColor(); + pDev->DrawRect( Rectangle( rPt, rSz ) ); + } + + if (mpMetadataAuthor->IsVisible()) + { + Font aOrigFont(mpMetadataAuthor->GetControlFont()); + Size aSize(PixelToLogic(mpMetadataAuthor->GetSizePixel())); + Point aPos(PixelToLogic(mpMetadataAuthor->GetPosPixel())); + aPos += rPt; + Font aFont( mpMetadataAuthor->GetSettings().GetStyleSettings().GetFieldFont() ); + mpMetadataAuthor->SetControlFont( aFont ); + mpMetadataAuthor->Draw(pDev, aPos, aSize, nInFlags); + mpMetadataAuthor->SetControlFont( aOrigFont ); + } + + if (mpMetadataDate->IsVisible()) + { + Font aOrigFont(mpMetadataDate->GetControlFont()); + Size aSize(PixelToLogic(mpMetadataDate->GetSizePixel())); + Point aPos(PixelToLogic(mpMetadataDate->GetPosPixel())); + aPos += rPt; + Font aFont( mpMetadataDate->GetSettings().GetStyleSettings().GetFieldFont() ); + mpMetadataDate->SetControlFont( aFont ); + mpMetadataDate->Draw(pDev, aPos, aSize, nInFlags); + mpMetadataDate->SetControlFont( aOrigFont ); + } + + mpSidebarTxtControl->Draw(pDev, rPt, rSz, nInFlags); + + const drawinglayer::primitive2d::Primitive2DSequence& rSequence = mpAnchor->getOverlayObjectPrimitive2DSequence(); + const drawinglayer::geometry::ViewInformation2D aNewViewInfos; + drawinglayer::processor2d::BaseProcessor2D * pProcessor = + drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice( + *pDev, aNewViewInfos ); + + pProcessor->process(rSequence); + delete pProcessor; +} + void SwSidebarWin::SetPosSizePixelRect( long nX, long nY, long nWidth, diff --git a/sw/source/core/uibase/inc/optpage.hxx b/sw/source/core/uibase/inc/optpage.hxx index 2cbbe728b26e..5e20bf405f91 100644 --- a/sw/source/core/uibase/inc/optpage.hxx +++ b/sw/source/core/uibase/inc/optpage.hxx @@ -104,6 +104,7 @@ class SwAddPrinterTabPage : public SfxTabPage RadioButton* m_pOnlyRB; RadioButton* m_pEndRB; RadioButton* m_pEndPageRB; + RadioButton* m_pInMarginsRB; CheckBox* m_pPrintEmptyPagesCB; CheckBox* m_pPaperFromSetupCB; diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx index 473940d99267..9bf1a45964fd 100644 --- a/sw/source/core/view/printdata.cxx +++ b/sw/source/core/view/printdata.cxx @@ -170,8 +170,8 @@ SwPrintUIOptions::SwPrintUIOptions( { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); - OSL_ENSURE( aLocalizedStrings.Count() >= 30, "resource incomplete" ); - if( aLocalizedStrings.Count() < 30 ) // bad resource ? + OSL_ENSURE( aLocalizedStrings.Count() >= 31, "resource incomplete" ); + if( aLocalizedStrings.Count() < 31 ) // bad resource ? return; // printing HTML sources does not have any valid UI options. @@ -320,11 +320,12 @@ SwPrintUIOptions::SwPrintUIOptions( OUString(), aContentsOpt); // create a list box for notes content const sal_Int16 nPrintPostIts = rDefaultPrintData.GetPrintPostIts(); - aChoices.realloc( 4 ); + aChoices.realloc( 5 ); aChoices[0] = aLocalizedStrings.GetString( 13 ); aChoices[1] = aLocalizedStrings.GetString( 14 ); aChoices[2] = aLocalizedStrings.GetString( 15 ); aChoices[3] = aLocalizedStrings.GetString( 16 ); + aChoices[4] = aLocalizedStrings.GetString( 30 ); aHelpIds.realloc( 2 ); aHelpIds[0] = ".HelpID:vcl:PrintDialog:PrintAnnotationMode:FixedText"; aHelpIds[1] = ".HelpID:vcl:PrintDialog:PrintAnnotationMode:ListBox"; diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 74841b529cad..b680e522f429 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -69,6 +69,7 @@ #include <viscrs.hxx> #include <fmtpdsc.hxx> #include <globals.hrc> +#include "PostItMgr.hxx" using namespace ::com::sun::star; @@ -454,13 +455,33 @@ sal_Bool SwViewShell::PrintOrPDFExport( // output device is now provided by a call from outside the Writer) pOutDev->Push(); + // fdo#36815 for comments in margins print to a metafile + // and then scale that metafile down so that the comments + // will fit on the real page, and replay that scaled + // output to the real outputdevice + GDIMetaFile *pOrigRecorder(NULL); + GDIMetaFile *pMetaFile(NULL); + sal_Int16 nPostItMode = rPrintData.GetPrintPostIts(); + if (nPostItMode == POSTITS_INMARGINS) + { + //get and disable the existing recorder + pOrigRecorder = pOutDev->GetConnectMetaFile(); + pOutDev->SetConnectMetaFile(NULL); + // turn off output to the device + pOutDev->EnableOutput(false); + // just record the rendering commands to the metafile + // instead + pMetaFile = new GDIMetaFile; + pMetaFile->Record(pOutDev); + } + // Print/PDF export for (multi-)selection has already generated a // temporary document with the selected text. // (see XRenderable implementation in unotxdoc.cxx) // It is implemented this way because PDF export calls this Prt function // once per page and we do not like to always have the temporary document // to be created that often here. - SwViewShell *pShell = new SwViewShell( *this, 0, pOutDev ); + SwViewShell *pShell = new SwViewShell(*this, 0, pOutDev); SdrView *pDrawView = pShell->GetDrawView(); if (pDrawView) @@ -502,13 +523,37 @@ sal_Bool SwViewShell::PrintOrPDFExport( ::SetSwVisArea( pViewSh2, pStPage->Frm() ); - pShell->InitPrt( pOutDev ); + pShell->InitPrt(pOutDev); ::SetSwVisArea( pViewSh2, pStPage->Frm() ); pStPage->GetUpper()->Paint( pStPage->Frm(), &rPrintData ); SwPaintQueue::Repaint(); + + if (nPostItMode == POSTITS_INMARGINS) + { + SwPostItMgr *pPostItManager = pShell->GetPostItMgr(); + pPostItManager->CalcRects(); + pPostItManager->LayoutPostIts(); + pPostItManager->DrawNotesForPage(pOutDev, nPage-1); + + //Now scale the recorded page down so the notes + //will fit in the final page + pMetaFile->Stop(); + pMetaFile->WindStart(); + double fScale = 0.75; + pMetaFile->Scale( fScale, fScale ); + pMetaFile->WindStart(); + + //Enable output the the device again + pOutDev->EnableOutput(true); + //Restore the original recorder + pOutDev->SetConnectMetaFile(pOrigRecorder); + //play back the scaled page + pMetaFile->Play(pOutDev); + delete pMetaFile; + } } delete pShell; diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 748560a2fab8..b5ae69cf1691 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -71,6 +71,7 @@ StringArray STR_PRINTOPTUI < "~All pages"; >; < "Pa~ges"; >; < "~Selection"; >; + < "Place in margins"; >; }; }; diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index e57265df7164..602896bf04f3 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -312,6 +312,7 @@ SwAddPrinterTabPage::SwAddPrinterTabPage(Window* pParent, get(m_pOnlyRB, "only"); get(m_pEndRB, "end"); get(m_pEndPageRB, "endpage"); + get(m_pInMarginsRB, "inmargins"); get(m_pPrintEmptyPagesCB, "blankpages"); get(m_pPaperFromSetupCB, "papertray"); get(m_pFaxLB, "fax"); @@ -332,6 +333,7 @@ SwAddPrinterTabPage::SwAddPrinterTabPage(Window* pParent, m_pPaperFromSetupCB->SetClickHdl( aLk ); m_pPrintEmptyPagesCB->SetClickHdl( aLk ); m_pEndPageRB->SetClickHdl( aLk ); + m_pInMarginsRB->SetClickHdl( aLk ); m_pEndRB->SetClickHdl( aLk ); m_pOnlyRB->SetClickHdl( aLk ); m_pNoRB->SetClickHdl( aLk ); @@ -398,6 +400,8 @@ bool SwAddPrinterTabPage::FillItemSet( SfxItemSet& rCoreSet ) POSTITS_ENDDOC; if (m_pEndPageRB->IsChecked()) aAddPrinterAttr.nPrintPostIts = POSTITS_ENDPAGE; + if (m_pInMarginsRB->IsChecked()) aAddPrinterAttr.nPrintPostIts = + POSTITS_INMARGINS; OUString sFax = m_pFaxLB->GetSelectEntry(); aAddPrinterAttr.sFaxName = sNone == sFax ? aEmptyOUStr : sFax; @@ -431,6 +435,7 @@ void SwAddPrinterTabPage::Reset( const SfxItemSet& ) m_pOnlyRB->Check (pAddPrinterAttr->nPrintPostIts== POSTITS_ONLY ) ; m_pEndRB->Check (pAddPrinterAttr->nPrintPostIts== POSTITS_ENDDOC ) ; m_pEndPageRB->Check (pAddPrinterAttr->nPrintPostIts== POSTITS_ENDPAGE ) ; + m_pInMarginsRB->Check (pAddPrinterAttr->nPrintPostIts== POSTITS_INMARGINS ) ; m_pFaxLB->SelectEntry( pAddPrinterAttr->sFaxName ); } if (m_pProspectCB->IsChecked()) @@ -461,6 +466,7 @@ IMPL_LINK_NOARG_INLINE_START(SwAddPrinterTabPage, AutoClickHdl) m_pOnlyRB->Enable( !bIsProspect ); m_pEndRB->Enable( !bIsProspect ); m_pEndPageRB->Enable( !bIsProspect ); + m_pInMarginsRB->Enable( !bIsProspect ); return 0; } IMPL_LINK_NOARG_INLINE_END(SwAddPrinterTabPage, AutoClickHdl) diff --git a/sw/uiconfig/swriter/ui/printoptionspage.ui b/sw/uiconfig/swriter/ui/printoptionspage.ui index 0bf9afe34aa0..95e5ae2e4399 100644 --- a/sw/uiconfig/swriter/ui/printoptionspage.ui +++ b/sw/uiconfig/swriter/ui/printoptionspage.ui @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.16.1 --> <interface> - <!-- interface-requires gtk+ 3.0 --> + <requires lib="gtk+" version="3.0"/> <object class="GtkBox" id="PrintOptionsPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -344,7 +345,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">none</property> + <property name="group">inmargins</property> </object> <packing> <property name="left_attach">0</property> @@ -353,6 +354,24 @@ <property name="height">1</property> </packing> </child> + <child> + <object class="GtkRadioButton" id="inmargins"> + <property name="label" translatable="yes">In margins</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <property name="group">none</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> </object> </child> </object> |