/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace cppu; // Forward declaration static void Main(); SAL_IMPLEMENT_MAIN() { try { tools::extendApplicationEnvironment(); Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext(); Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY ); if( !xServiceManager.is() ) Application::Abort( "Failed to bootstrap" ); comphelper::setProcessServiceFactory( xServiceManager ); InitVCL(); ::Main(); DeInitVCL(); } catch (const Exception&) { TOOLS_WARN_EXCEPTION("vcl.app", "Fatal"); return 1; } catch (const std::exception &e) { fprintf(stderr, "fatal error: %s\n", e.what()); return 1; } return 0; } class MyWin : public WorkWindow { Bitmap m_aBitmap; public: MyWin( vcl::Window* pParent, WinBits nWinStyle ); virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect ) override; }; void Main() { ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_APP | WB_STDWORK ); aMainWin->SetText( "VCL - Workbench" ); aMainWin->Show(); Application::Execute(); } MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) : WorkWindow( pParent, nWinStyle ), m_aBitmap( Size( 256, 256 ), 32 ) { // prepare an alpha mask BitmapWriteAccess* pAcc = m_aBitmap.AcquireWriteAccess(); for( int nX = 0; nX < 256; nX++ ) { for( int nY = 0; nY < 256; nY++ ) { double fRed = 255.0-1.5*sqrt(static_cast(nX*nX+nY*nY)); if( fRed < 0.0 ) fRed = 0.0; double fGreen = 255.0-1.5*sqrt(static_cast((255-nX)*(255-nX)+nY*nY)); if( fGreen < 0.0 ) fGreen = 0.0; double fBlue = 255.0-1.5*sqrt(static_cast((128-nX)*(128-nX)+(255-nY)*(255-nY))); if( fBlue < 0.0 ) fBlue = 0.0; pAcc->SetPixel( nY, nX, BitmapColor( sal_uInt8(fRed), sal_uInt8(fGreen), sal_uInt8(fBlue) ) ); } } Bitmap::ReleaseAccess( pAcc ); } static Point project( const Point& rPoint ) { const double angle_x = M_PI / 6.0; const double angle_z = M_PI / 6.0; // transform planar coordinates to 3d double x = rPoint.X(); double y = rPoint.Y(); // rotate around X axis double x1 = x; double y1 = y * cos( angle_x ); double z1 = y * sin( angle_x ); // rotate around Z axis double x2 = x1 * cos( angle_z ) + y1 * sin( angle_z ); //double y2 = y1 * cos( angle_z ) - x1 * sin( angle_z ); double z2 = z1; return Point( static_cast(x2), static_cast(z2) ); } static Color approachColor( const Color& rFrom, const Color& rTo ) { Color aColor; sal_uInt8 nDiff; // approach red if( rFrom.GetRed() < rTo.GetRed() ) { nDiff = rTo.GetRed() - rFrom.GetRed(); aColor.SetRed( rFrom.GetRed() + std::min( nDiff, 10 ) ); } else if( rFrom.GetRed() > rTo.GetRed() ) { nDiff = rFrom.GetRed() - rTo.GetRed(); aColor.SetRed( rFrom.GetRed() - std::min( nDiff, 10 ) ); } else aColor.SetRed( rFrom.GetRed() ); // approach Green if( rFrom.GetGreen() < rTo.GetGreen() ) { nDiff = rTo.GetGreen() - rFrom.GetGreen(); aColor.SetGreen( rFrom.GetGreen() + std::min( nDiff, 10 ) ); } else if( rFrom.GetGreen() > rTo.GetGreen() ) { nDiff = rFrom.GetGreen() - rTo.GetGreen(); aColor.SetGreen( rFrom.GetGreen() - std::min( nDiff, 10 ) ); } else aColor.SetGreen( rFrom.GetGreen() ); // approach blue if( rFrom.GetBlue() < rTo.GetBlue() ) { nDiff = rTo.GetBlue() - rFrom.GetBlue(); aColor.SetBlue( rFrom.GetBlue() + std::min( nDiff, 10 ) ); } else if( rFrom.GetBlue() > rTo.GetBlue() ) { nDiff = rFrom.GetBlue() - rTo.GetBlue(); aColor.SetBlue( rFrom.GetBlue() - std::min( nDiff, 10 ) ); } else aColor.SetBlue( rFrom.GetBlue() ); return aColor; } #define DELTA 5.0 void MyWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) { WorkWindow::Paint(rRenderContext, rRect); rRenderContext.Push(); MapMode aMapMode(MapUnit::Map100thMM); rRenderContext.SetMapMode(aMapMode); Size aPaperSize = rRenderContext.GetOutputSize(); Point aCenter(aPaperSize.Width() / 2 - 300, (aPaperSize.Height() - 8400) / 2 + 8400); Point aP1(aPaperSize.Width() / 48, 0), aP2(aPaperSize.Width() / 40, 0); Point aPoint; rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), aPaperSize)); rRenderContext.DrawRect(tools::Rectangle(Point(100, 100), Size(aPaperSize.Width() - 200, aPaperSize.Height() - 200))); rRenderContext.DrawRect(tools::Rectangle(Point(200, 200), Size(aPaperSize.Width() - 400, aPaperSize.Height() - 400))); rRenderContext.DrawRect(tools::Rectangle(Point(300, 300), Size(aPaperSize.Width() - 600, aPaperSize.Height() - 600))); const int nFontCount = rRenderContext.GetDevFontCount(); const int nFontSamples = (nFontCount < 15) ? nFontCount : 15; for (int i = 0; i < nFontSamples; ++i) { FontMetric aFont = rRenderContext.GetDevFont((i * nFontCount) / nFontSamples); aFont.SetFontHeight(400 + (i % 7) * 100); aFont.SetOrientation(i * (3600 / nFontSamples)); rRenderContext.SetFont(aFont); sal_uInt8 nRed = (i << 6) & 0xC0; sal_uInt8 nGreen = (i << 4) & 0xC0; sal_uInt8 nBlue = (i << 2) & 0xC0; rRenderContext.SetTextColor(Color(nRed, nGreen, nBlue)); OUStringBuffer aPrintText(1024); aPrintText.append( "SVP test program" ); rRenderContext.DrawText(tools::Rectangle(Point((aPaperSize.Width() - 4000) / 2, 2000), Size(aPaperSize.Width() - 2100, aPaperSize.Height() - 4000)), aPrintText.makeStringAndClear(), DrawTextFlags::MultiLine); } rRenderContext.SetFillColor(); DrawRect(tools::Rectangle(Point(aPaperSize.Width() - 4000, 1000), Size(3000, 3000))); rRenderContext.DrawBitmap(Point(aPaperSize.Width() - 4000, 1000), Size( 3000,3000 ), m_aBitmap); Color const aWhite(0xff, 0xff, 0xff); Color const aBlack(0, 0, 0); Color const aLightRed(0xff, 0, 0); Color const aDarkRed(0x40, 0, 0); Color const aLightBlue(0, 0, 0xff); Color const aDarkBlue(0,0,0x40); Color const aLightGreen(0, 0xff, 0); Color const aDarkGreen(0, 0x40, 0); Gradient aGradient(GradientStyle::Linear, aBlack, aWhite); aGradient.SetAngle(900); rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 4500), Size(aPaperSize.Width() - 2000, 500)), aGradient); aGradient.SetStartColor(aDarkRed); aGradient.SetEndColor(aLightBlue); rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 5300), Size(aPaperSize.Width() - 2000, 500)), aGradient); aGradient.SetStartColor(aDarkBlue); aGradient.SetEndColor(aLightGreen); rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 6100), Size(aPaperSize.Width() - 2000, 500)), aGradient); aGradient.SetStartColor(aDarkGreen); aGradient.SetEndColor(aLightRed); rRenderContext.DrawGradient(tools::Rectangle(Point(1000, 6900), Size(aPaperSize.Width() - 2000, 500)), aGradient); LineInfo aLineInfo(LineStyle::Solid, 200); const double sind = sin(basegfx::deg2rad(DELTA)); const double cosd = cos(basegfx::deg2rad(DELTA)); const double factor = 1 + (DELTA / 1000.0); int n = 0; Color aLineColor(0, 0, 0); Color aApproachColor(0, 0, 200); while (aP2.X() < aCenter.X() && n++ < 680) { aLineInfo.SetWidth(n / 3); aLineColor = approachColor(aLineColor, aApproachColor); rRenderContext.SetLineColor(aLineColor); // switch approach color if (aApproachColor.IsRGBEqual(aLineColor)) { if (aApproachColor.GetRed()) aApproachColor = Color(0, 0, 200); else if (aApproachColor.GetGreen()) aApproachColor = Color(200, 0, 0); else aApproachColor = Color(0, 200, 0); } rRenderContext.DrawLine(project(aP1) + aCenter, project(aP2) + aCenter, aLineInfo); aPoint.setX( static_cast((static_cast(aP1.X())*cosd - static_cast(aP1.Y())*sind)*factor) ); aPoint.setY( static_cast((static_cast(aP1.Y())*cosd + static_cast(aP1.X())*sind)*factor) ); aP1 = aPoint; aPoint.setX( static_cast((static_cast(aP2.X())*cosd - static_cast(aP2.Y())*sind)*factor) ); aPoint.setY( static_cast((static_cast(aP2.Y())*cosd + static_cast(aP2.X())*sind)*factor) ); aP2 = aPoint; } rRenderContext.Pop(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ llel'>feature/calc-parallel LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-07-04reduce number of framework librariesNoel Grandin
Change-Id: If2bf85301eb1523a636d031f6e5a9f78cb1ee06b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97871 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-10an uno -> a unoCaolán McNamara
Change-Id: I538db88f8477dd2d2ad25c372928fec6c11d979d Reviewed-on: https://gerrit.libreoffice.org/72105 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-02-19tdf#42949 Fix IWYU warnings in include/framework/Gabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: Ia9616f644a68ec6da22e646ba0d919a3489a9481 Reviewed-on: https://gerrit.libreoffice.org/67745 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2018-07-13merge IUndoManager into SfxUndoManagerNoel Grandin
SfxUndoManager is the only implementation of the IUnderManager "interface", and it lives in the same header. Plus this way we can get rid of some covariant parameters, which will make using std::unique_ptr easier. Change-Id: I6661b9876b18da830bead78794d237886cd3c5c9 Reviewed-on: https://gerrit.libreoffice.org/57317 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-09spelling mutext->mutexNoel Grandin
Change-Id: If844c07d0d50d1bb9b0a1877c0fde4a198bcf781
2016-02-09Remove excess newlinesChris Sherlock
A ridiculously fast way of doing this is: for i in $(pcregrep -l -M -r --include='.*[hc]xx$' \ --exclude-dir=workdir --exclude-dir=instdir '^ {3,}' .) do perl -0777 -i -pe 's/^ {3,}/ /gm' $i done Change-Id: Iebb93eccbee9e4fc5c4380474ba595858a27ac2c Reviewed-on: https://gerrit.libreoffice.org/22224 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2015-10-22com::sun::star->css in include/frameworkNoel Grandin
Change-Id: I60874ab8d3cc9adaea8757d6888e341accce2083 Reviewed-on: https://gerrit.libreoffice.org/19494 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-02-16boost::foo_ptr->std::foo_ptrCaolán McNamara
Change-Id: I9219619b538b6530a89f5932ac51eb3b62eb396a