[Libreoffice-commits] core.git: vcl/source

Thorsten Behrens (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 27 15:41:14 UTC 2019


 vcl/source/gdi/pdfwriter_impl.cxx |  390 --------------------------------------
 1 file changed, 390 deletions(-)

New commits:
commit b7bc2105d5093543058716c12e4d88dffb00b752
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Sun Mar 10 02:13:57 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Mar 27 16:40:47 2019 +0100

    Remove stale testcode
    
    Change-Id: I64a0b9cd4a727349016aa307d5c4835158a93109
    Reviewed-on: https://gerrit.libreoffice.org/69822
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index e7a22e69ef56..f4c620bd13da 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -117,388 +117,6 @@ static bool g_bDebugDisableCompression = getenv("VCL_DEBUG_DISABLE_PDFCOMPRESSIO
 #define MAX_SIGNATURE_CONTENT_LENGTH 50000
 #endif
 
-#ifdef DO_TEST_PDF
-class PDFTestOutputStream : public PDFOutputStream
-{
-    public:
-    virtual ~PDFTestOutputStream();
-    virtual void write( const css::uno::Reference< css::io::XOutputStream >& xStream );
-};
-
-PDFTestOutputStream::~PDFTestOutputStream()
-{
-}
-
-void PDFTestOutputStream::write( const css::uno::Reference< css::io::XOutputStream >& xStream )
-{
-    OString aStr( "lalala\ntest\ntest\ntest" );
-    css::uno::Sequence< sal_Int8 > aData( aStr.getLength() );
-    memcpy( aData.getArray(), aStr.getStr(), aStr.getLength() );
-    xStream->writeBytes( aData );
-}
-
-// this test code cannot be used to test PDF/A-1 because it forces
-// control item (widgets) to bypass the structure controlling
-// the embedding of such elements in actual run
-void doTestCode()
-{
-    static const char* pHome = getenv( "HOME"  );
-    OUString aTestFile( "file://"  );
-    aTestFile += OUString( pHome, strlen( pHome ), RTL_TEXTENCODING_MS_1252 );
-    aTestFile += "/pdf_export_test.pdf";
-
-    PDFWriter::PDFWriterContext aContext;
-    aContext.URL            = aTestFile;
-    aContext.Version        = PDFWriter::PDF_1_4;
-    aContext.Tagged         = true;
-    aContext.InitialPage    = 2;
-    aContext.DocumentInfo.Title = "PDF export test document";
-    aContext.DocumentInfo.Producer = "VCL";
-
-    aContext.SignPDF        = true;
-    aContext.SignLocation   = "Burdur";
-    aContext.SignReason     = "Some valid reason to sign";
-    aContext.SignContact    = "signer at example.com";
-
-    css::uno::Reference< css::beans::XMaterialHolder > xEnc;
-    PDFWriter aWriter( aContext, xEnc );
-    aWriter.NewPage( 595, 842 );
-    aWriter.BeginStructureElement( PDFWriter::Document );
-    // set duration of 3 sec for first page
-    aWriter.SetAutoAdvanceTime( 3 );
-    aWriter.SetMapMode( MapMode( MapUnit::Map100thMM ) );
-
-    aWriter.SetFillColor( COL_LIGHTRED );
-    aWriter.SetLineColor( COL_LIGHTGREEN );
-    aWriter.DrawRect( Rectangle( Point( 2000, 200 ), Size( 8000, 3000 ) ), 5000, 2000 );
-
-    aWriter.SetFont( Font( OUString( "Times" ), Size( 0, 500 ) ) );
-    aWriter.SetTextColor( COL_BLACK );
-    aWriter.SetLineColor( COL_BLACK );
-    aWriter.SetFillColor( COL_LIGHTBLUE );
-
-    Rectangle aRect( Point( 5000, 5000 ), Size( 6000, 3000 ) );
-    aWriter.DrawRect( aRect );
-    aWriter.DrawText( aRect, OUString( "Link annot 1" ) );
-    sal_Int32 nFirstLink = aWriter.CreateLink( aRect );
-    PDFNote aNote;
-    aNote.Title = "A small test note";
-    aNote.Contents = "There is no business like show business like no business i know. Everything about it is appealing.";
-    aWriter.CreateNote( Rectangle( Point( aRect.Right(), aRect.Top() ), Size( 6000, 3000 ) ), aNote );
-
-    Rectangle aTargetRect( Point( 3000, 23000 ), Size( 12000, 6000 ) );
-    aWriter.SetFillColor( COL_LIGHTGREEN );
-    aWriter.DrawRect( aTargetRect );
-    aWriter.DrawText( aTargetRect, "Dest second link" );
-    sal_Int32 nSecondDest = aWriter.CreateDest( aTargetRect );
-
-    aWriter.BeginStructureElement( PDFWriter::Section );
-    aWriter.BeginStructureElement( PDFWriter::Heading );
-    aWriter.DrawText( Point(4500, 9000), "A small structure test" );
-    aWriter.EndStructureElement();
-    aWriter.BeginStructureElement( PDFWriter::Paragraph );
-    aWriter.SetStructureAttribute( PDFWriter::WritingMode, PDFWriter::LrTb );
-    aWriter.SetStructureAttribute( PDFWriter::TextDecorationType, PDFWriter::Underline );
-    aWriter.DrawText( Rectangle( Point( 4500, 10000 ), Size( 12000, 6000 ) ),
-                     "It was the best of PDF, it was the worst of PDF ... or so. This is a pretty nonsensical text to denote a paragraph. I suggest you stop reading it. Because if you read on you might get bored. So continue on your on risk. Hey, you're still here ? Why do you continue to read this as it is of no use at all ? OK, it's your time, but still... . Woah, i even get bored writing this, so let's end this here and now.",
-                      DrawTextFlags::MultiLine | DrawTextFlags::WordBreak
-                      );
-    aWriter.SetActualText( "It was the best of PDF, it was the worst of PDF ... or so. This is a pretty nonsensical text to denote a paragraph. I suggest you stop reading it. Because if you read on you might get bored. So continue on your on risk. Hey, you're still here ? Why do you continue to read this as it is of no use at all ? OK, it's your time, but still... . Woah, i even get bored writing this, so let's end this here and now." );
-    aWriter.SetAlternateText( "This paragraph contains some lengthy nonsense to test structural element emission of PDFWriter." );
-    aWriter.EndStructureElement();
-    aWriter.BeginStructureElement( PDFWriter::Paragraph );
-    aWriter.SetStructureAttribute( PDFWriter::WritingMode, PDFWriter::LrTb );
-    aWriter.DrawText( Rectangle( Point( 4500, 19000 ), Size( 12000, 1000 ) ),
-                      "This paragraph is nothing special either but ends on the next page structurewise",
-                      DrawTextFlags::MultiLine | DrawTextFlags::WordBreak
-                      );
-
-    aWriter.NewPage( 595, 842 );
-    // test AddStream interface
-    aWriter.AddStream( "text/plain", new PDFTestOutputStream(), true );
-    // set transitional mode
-    aWriter.SetPageTransition( PDFWriter::WipeRightToLeft, 1500 );
-    aWriter.SetMapMode( MapMode( MapUnit::Map100thMM ) );
-    aWriter.SetTextColor( COL_BLACK );
-    aWriter.SetFont( Font( OUString( "Times" ), Size( 0, 500 ) ) );
-    aWriter.DrawText( Rectangle( Point( 4500, 1500 ), Size( 12000, 3000 ) ),
-                      "Here's where all things come to an end ... well at least the paragraph from the last page.",
-                      DrawTextFlags::MultiLine | DrawTextFlags::WordBreak
-                      );
-    aWriter.EndStructureElement();
-
-    aWriter.SetFillColor( COL_LIGHTBLUE );
-    // disable structure
-    aWriter.BeginStructureElement( PDFWriter::NonStructElement );
-    aWriter.DrawRect( aRect );
-    aWriter.BeginStructureElement( PDFWriter::Paragraph );
-    aWriter.DrawText( aRect, "Link annot 2" );
-    sal_Int32 nSecondLink = aWriter.CreateLink( aRect );
-
-    aWriter.SetFillColor( COL_LIGHTGREEN );
-    aWriter.BeginStructureElement( PDFWriter::ListItem );
-    aWriter.DrawRect( aTargetRect );
-    aWriter.DrawText( aTargetRect, "Dest first link" );
-    sal_Int32 nFirstDest = aWriter.CreateDest( aTargetRect );
-    // enable structure
-    aWriter.EndStructureElement();
-
-    aWriter.EndStructureElement();
-    aWriter.EndStructureElement();
-    aWriter.BeginStructureElement( PDFWriter::Figure );
-    aWriter.BeginStructureElement( PDFWriter::Caption );
-    aWriter.DrawText( Point( 4500, 9000 ), "Some drawing stuff inside the structure" );
-    aWriter.EndStructureElement();
-
-    // test clipping
-    basegfx::B2DPolyPolygon aClip;
-    basegfx::B2DPolygon aClipPoly;
-    aClipPoly.append( basegfx::B2DPoint( 8250, 9600 ) );
-    aClipPoly.append( basegfx::B2DPoint( 16500, 11100 ) );
-    aClipPoly.append( basegfx::B2DPoint( 8250, 12600 ) );
-    aClipPoly.append( basegfx::B2DPoint( 4500, 11100 ) );
-    aClipPoly.setClosed( true );
-    aClip.append( aClipPoly );
-
-    aWriter.Push( PushFlags::CLIPREGION | PushFlags::FILLCOLOR );
-    aWriter.SetClipRegion( aClip );
-    aWriter.DrawEllipse( Rectangle( Point( 4500, 9600 ), Size( 12000, 3000 ) ) );
-    aWriter.MoveClipRegion( 1000, 500 );
-    aWriter.SetFillColor( COL_RED );
-    aWriter.DrawEllipse( Rectangle( Point( 4500, 9600 ), Size( 12000, 3000 ) ) );
-    aWriter.Pop();
-    // test transparency
-    // draw background
-    Rectangle aTranspRect( Point( 7500, 13500 ), Size( 9000, 6000 ) );
-    aWriter.SetFillColor( COL_LIGHTRED );
-    aWriter.DrawRect( aTranspRect );
-    aWriter.BeginTransparencyGroup();
-
-    aWriter.SetFillColor( COL_LIGHTGREEN );
-    aWriter.DrawEllipse( aTranspRect );
-    aWriter.SetTextColor( COL_LIGHTBLUE );
-    aWriter.DrawText( aTranspRect,
-                      "Some transparent text",
-                      DrawTextFlags::Center | DrawTextFlags::VCenter | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak );
-
-    aWriter.EndTransparencyGroup( aTranspRect, 50 );
-
-    // prepare an alpha mask
-    Bitmap aTransMask( Size( 256, 256 ), 8, &Bitmap::GetGreyPalette( 256 ) );
-    BitmapScopedWriteAccess pAcc(aTransMask);
-    for( int nX = 0; nX < 256; nX++ )
-        for( int nY = 0; nY < 256; nY++ )
-            pAcc->SetPixel( nX, nY, BitmapColor( (sal_uInt8)((nX+nY)/2) ) );
-    pAcc.reset();
-    aTransMask.SetPrefMapMode( MapUnit::MapMM );
-    aTransMask.SetPrefSize( Size( 10, 10 ) );
-
-    aWriter.DrawBitmap( Point( 600, 13500 ), Size( 3000, 3000 ), aTransMask );
-
-    aTranspRect = Rectangle( Point( 4200, 13500 ), Size( 3000, 3000 ) );
-    aWriter.SetFillColor( COL_LIGHTRED );
-    aWriter.DrawRect( aTranspRect );
-    aWriter.SetFillColor( COL_LIGHTGREEN );
-    aWriter.DrawEllipse( aTranspRect );
-    aWriter.SetTextColor( COL_LIGHTBLUE );
-    aWriter.DrawText( aTranspRect,
-                      "Some transparent text",
-                      DrawTextFlags::Center | DrawTextFlags::VCenter | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak );
-    aTranspRect = Rectangle( Point( 1500, 16500 ), Size( 4800, 3000 ) );
-    aWriter.SetFillColor( COL_LIGHTRED );
-    aWriter.DrawRect( aTranspRect );
-
-    Bitmap aImageBmp( Size( 256, 256 ), 24 );
-    pAcc = BitmapScopedWriteAccess(aImageBmp);
-    pAcc->SetFillColor( Color( 0xff, 0, 0xff ) );
-    pAcc->FillRect( Rectangle( Point( 0, 0 ), Size( 256, 256 ) ) );
-    pAcc.reset();
-    BitmapEx aBmpEx( aImageBmp, AlphaMask( aTransMask ) );
-    aWriter.DrawBitmapEx( Point( 1500, 19500 ), Size( 4800, 3000 ), aBmpEx );
-
-    aWriter.EndStructureElement();
-    aWriter.EndStructureElement();
-
-    LineInfo aLI( LineStyle::Dash, 3 );
-    aLI.SetDashCount( 2 );
-    aLI.SetDashLen( 50 );
-    aLI.SetDotCount( 2 );
-    aLI.SetDotLen( 25 );
-    aLI.SetDistance( 15 );
-    Point aLIPoints[] = { Point( 4000, 10000 ),
-                          Point( 8000, 12000 ),
-                          Point( 3000, 19000 ) };
-    tools::Polygon aLIPoly( 3, aLIPoints );
-    aWriter.SetLineColor( COL_BLUE );
-    aWriter.SetFillColor();
-    aWriter.DrawPolyLine( aLIPoly, aLI );
-
-    aLI.SetDashCount( 4 );
-    aLIPoly.Move( 1000, 1000 );
-    aWriter.DrawPolyLine( aLIPoly, aLI );
-
-    aWriter.NewPage( 595, 842 );
-    aWriter.SetMapMode( MapMode( MapUnit::Map100thMM ) );
-    Wallpaper aWall( aTransMask );
-    aWall.SetStyle( WallpaperStyle::Tile );
-    aWriter.DrawWallpaper( Rectangle( Point( 4400, 4200 ), Size( 10200, 6300 ) ), aWall );
-
-    aWriter.NewPage( 595, 842 );
-    aWriter.SetMapMode( MapMode( MapUnit::Map100thMM ) );
-    aWriter.SetFont( Font( OUString( "Times" ), Size( 0, 500 ) ) );
-    aWriter.SetTextColor( COL_BLACK );
-    aRect = Rectangle( Point( 4500, 6000 ), Size( 6000, 1500 ) );
-    aWriter.DrawRect( aRect );
-    aWriter.DrawText( aRect, "www.heise.de" );
-    sal_Int32 nURILink = aWriter.CreateLink( aRect );
-    aWriter.SetLinkURL( nURILink, OUString( "http://www.heise.de" ) );
-
-    aWriter.SetLinkDest( nFirstLink, nFirstDest );
-    aWriter.SetLinkDest( nSecondLink, nSecondDest );
-
-    // include a button
-    PDFWriter::PushButtonWidget aBtn;
-    aBtn.Name = "testButton";
-    aBtn.Description = "A test button";
-    aBtn.Text = "hit me";
-    aBtn.Location = Rectangle( Point( 4500, 9000 ), Size( 4500, 3000 ) );
-    aBtn.Border = aBtn.Background = true;
-    aWriter.CreateControl( aBtn );
-
-    // include a uri button
-    PDFWriter::PushButtonWidget aUriBtn;
-    aUriBtn.Name = "wwwButton";
-    aUriBtn.Description = "A URI button";
-    aUriBtn.Text = "to www";
-    aUriBtn.Location = Rectangle( Point( 9500, 9000 ), Size( 4500, 3000 ) );
-    aUriBtn.Border = aUriBtn.Background = true;
-    aUriBtn.URL = "http://www.heise.de";
-    aWriter.CreateControl( aUriBtn );
-
-    // include a dest button
-    PDFWriter::PushButtonWidget aDstBtn;
-    aDstBtn.Name = "destButton";
-    aDstBtn.Description = "A Dest button";
-    aDstBtn.Text = "to paragraph";
-    aDstBtn.Location = Rectangle( Point( 14500, 9000 ), Size( 4500, 3000 ) );
-    aDstBtn.Border = aDstBtn.Background = true;
-    aDstBtn.Dest = nFirstDest;
-    aWriter.CreateControl( aDstBtn );
-
-    PDFWriter::CheckBoxWidget aCBox;
-    aCBox.Name = "textCheckBox";
-    aCBox.Description = "A test check box";
-    aCBox.Text = "check me";
-    aCBox.Location = Rectangle( Point( 4500, 13500 ), Size( 3000, 750 ) );
-    aCBox.Checked = true;
-    aCBox.Border = aCBox.Background = false;
-    aWriter.CreateControl( aCBox );
-
-    PDFWriter::CheckBoxWidget aCBox2;
-    aCBox2.Name = "textCheckBox2";
-    aCBox2.Description = "Another test check box";
-    aCBox2.Text = "check me right";
-    aCBox2.Location = Rectangle( Point( 4500, 14250 ), Size( 3000, 750 ) );
-    aCBox2.Checked = true;
-    aCBox2.Border = aCBox2.Background = false;
-    aCBox2.ButtonIsLeft = false;
-    aWriter.CreateControl( aCBox2 );
-
-    PDFWriter::RadioButtonWidget aRB1;
-    aRB1.Name = "rb1_1";
-    aRB1.Description = "radio 1 button 1";
-    aRB1.Text = "Despair";
-    aRB1.Location = Rectangle( Point( 4500, 15000 ), Size( 6000, 1000 ) );
-    aRB1.Selected = true;
-    aRB1.RadioGroup = 1;
-    aRB1.Border = aRB1.Background = true;
-    aRB1.ButtonIsLeft = false;
-    aRB1.BorderColor = COL_LIGHTGREEN;
-    aRB1.BackgroundColor = COL_LIGHTBLUE;
-    aRB1.TextColor = COL_LIGHTRED;
-    aRB1.TextFont = Font( OUString( "Courier" ), Size( 0, 800 ) );
-    aWriter.CreateControl( aRB1 );
-
-    PDFWriter::RadioButtonWidget aRB2;
-    aRB2.Name = "rb2_1";
-    aRB2.Description = "radio 2 button 1";
-    aRB2.Text = "Joy";
-    aRB2.Location = Rectangle( Point( 10500, 15000 ), Size( 3000, 1000 ) );
-    aRB2.Selected = true;
-    aRB2.RadioGroup = 2;
-    aWriter.CreateControl( aRB2 );
-
-    PDFWriter::RadioButtonWidget aRB3;
-    aRB3.Name = "rb1_2";
-    aRB3.Description = "radio 1 button 2";
-    aRB3.Text = "Desperation";
-    aRB3.Location = Rectangle( Point( 4500, 16000 ), Size( 3000, 1000 ) );
-    aRB3.Selected = true;
-    aRB3.RadioGroup = 1;
-    aWriter.CreateControl( aRB3 );
-
-    PDFWriter::EditWidget aEditBox;
-    aEditBox.Name = "testEdit";
-    aEditBox.Description = "A test edit field";
-    aEditBox.Text = "A little test text";
-    aEditBox.TextStyle = DrawTextFlags::Left | DrawTextFlags::VCenter;
-    aEditBox.Location = Rectangle( Point( 10000, 18000 ), Size( 5000, 1500 ) );
-    aEditBox.MaxLen = 100;
-    aEditBox.Border = aEditBox.Background = true;
-    aEditBox.BorderColor = COL_BLACK;
-    aWriter.CreateControl( aEditBox );
-
-    // normal list box
-    PDFWriter::ListBoxWidget aLstBox;
-    aLstBox.Name = "testListBox";
-    aLstBox.Text = "One";
-    aLstBox.Description = "select me";
-    aLstBox.Location = Rectangle( Point( 4500, 18000 ), Size( 3000, 1500 ) );
-    aLstBox.Sort = true;
-    aLstBox.MultiSelect = true;
-    aLstBox.Border = aLstBox.Background = true;
-    aLstBox.BorderColor = COL_BLACK;
-    aLstBox.Entries.push_back( OUString( "One"  ) );
-    aLstBox.Entries.push_back( OUString( "Two"  ) );
-    aLstBox.Entries.push_back( OUString( "Three"  ) );
-    aLstBox.Entries.push_back( OUString( "Four"  ) );
-    aLstBox.SelectedEntries.push_back( 1 );
-    aLstBox.SelectedEntries.push_back( 2 );
-    aWriter.CreateControl( aLstBox );
-
-    // dropdown list box
-    aLstBox.Name = "testDropDownListBox";
-    aLstBox.DropDown = true;
-    aLstBox.Location = Rectangle( Point( 4500, 19500 ), Size( 3000, 500 ) );
-    aWriter.CreateControl( aLstBox );
-
-    // combo box
-    PDFWriter::ComboBoxWidget aComboBox;
-    aComboBox.Name = "testComboBox";
-    aComboBox.Text = "test a combobox";
-    aComboBox.Entries.push_back( OUString( "Larry"  ) );
-    aComboBox.Entries.push_back( OUString( "Curly"  ) );
-    aComboBox.Entries.push_back( OUString( "Moe"  ) );
-    aComboBox.Location = Rectangle( Point( 4500, 20000 ), Size( 3000, 500 ) );
-    aWriter.CreateControl( aComboBox );
-
-    // test outlines
-    sal_Int32 nPage1OL = aWriter.CreateOutlineItem();
-    aWriter.SetOutlineItemText( nPage1OL, OUString( "Page 1"  ) );
-    aWriter.SetOutlineItemDest( nPage1OL, nSecondDest );
-    aWriter.CreateOutlineItem( nPage1OL, OUString( "Dest 2"  ), nSecondDest );
-    aWriter.CreateOutlineItem( nPage1OL, OUString( "Dest 2 revisited"  ), nSecondDest );
-    aWriter.CreateOutlineItem( nPage1OL, OUString( "Dest 2 again"  ), nSecondDest );
-    sal_Int32 nPage2OL = aWriter.CreateOutlineItem();
-    aWriter.SetOutlineItemText( nPage2OL, OUString( "Page 2"  ) );
-    aWriter.CreateOutlineItem( nPage2OL, OUString( "Dest 1"  ), nFirstDest );
-
-    aWriter.EndStructureElement(); // close document
-
-    aWriter.Emit();
-}
-#endif
-
 static const sal_Int32 nLog10Divisor = 3;
 static const double fDivisor = 1000.0;
 
@@ -1702,14 +1320,6 @@ void PDFWriterImpl::PDFPage::appendWaveLine( sal_Int32 nWidth, sal_Int32 nY, sal
         m_bIsPDF_A2( false ),
         m_rOuterFace( i_rOuterFace )
 {
-#ifdef DO_TEST_PDF
-    static bool bOnce = true;
-    if( bOnce )
-    {
-        bOnce = false;
-        doTestCode();
-    }
-#endif
     m_aStructure.emplace_back( );
     m_aStructure[0].m_nOwnElement       = 0;
     m_aStructure[0].m_nParentElement    = 0;


More information about the Libreoffice-commits mailing list