summaryrefslogtreecommitdiffstats
path: root/sc/workben/tabview.cxx
blob: a010b3ac207d8b86d3e2e7c25914a923fb34456e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* -*- 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/.
 */

#include <sal/main.h>
#include <tools/extendapplicationenvironment.hxx>

#include <cppuhelper/bootstrap.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>

#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
#include <vcl/dialog.hxx>
#include <vcl/outdev.hxx>
#include <vcl/virdev.hxx>

#include "output.hxx"
#include "document.hxx"
#include "fillinfo.hxx"
#include "scdll.hxx"

using namespace ::com::sun::star;

class CalcTestApp : public Application
{
public:
    virtual int Main() override;
    virtual void Exception( ExceptionCategory nCategory ) override;
};

class TestWindow : public Dialog
{
    std::unique_ptr<ScDocument> mpDoc;
    public:
        TestWindow() :
            Dialog( nullptr ),
            mpDoc(new ScDocument)
        {
            mpDoc->InsertTab(0, "test");
            mpDoc->SetValue(0, 0, 0, 10);
            mpDoc->SetValue(2, 2, 0, 10);
            SetText( "OutDev grinding" );
            SetSizePixel( Size( 1024, 1024 ) );
            EnablePaint( true );
            Show();
        }

        ~TestWindow()
        {
            disposeOnce();
        }

        void dispose() override
        {
            Dialog::dispose();
        }

        virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
};

void TestWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
    rRenderContext.SetFillColor(Color(0, 255, 255));
    rRenderContext.DrawRect(tools::Rectangle(0, 0, 100, 100));
    ScTableInfo aTableInfo;
    mpDoc->FillInfo(aTableInfo, 0, 0, 10, 10, 0, 0.06666, 0.06666, false, false);
    ScOutputData aOutput(&rRenderContext, OUTTYPE_WINDOW, aTableInfo, mpDoc.get(), 0,
            0, 0, 0, 0, 10, 10, 0.06666, 0.06666);

    aOutput.SetGridColor(COL_BLACK);
    aOutput.SetSolidBackground(true);
    aOutput.DrawClear();
    aOutput.DrawDocumentBackground();
    aOutput.DrawGrid(rRenderContext, true, false);
    aOutput.DrawStrings();

    fflush(stdout);
}

void CalcTestApp::Exception( ExceptionCategory nCategory )
{
    switch( nCategory )
    {
        case ExceptionCategory::ResourceNotLoaded:
            Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
            break;
        default: break;
    }
}

int CalcTestApp::Main()
{
    ScDLL::Init();
    ScGlobal::Init();
    ScopedVclPtrInstance<TestWindow> aWindow;
    aWindow->Execute();
    return 0;
}

SAL_IMPLEMENT_MAIN()
{
    try
    {
        bool bHelp = false;

        for( sal_uInt16 i = 0; i < Application::GetCommandLineParamCount(); i++ )
        {
            OUString aParam = Application::GetCommandLineParam( i );

            if( aParam == "--help" || aParam == "-h" )
                    bHelp = true;
        }

        if( bHelp )
        {
            printf( "sc\n" );
            return EXIT_SUCCESS;
        }

        tools::extendApplicationEnvironment();

        uno::Reference< uno::XComponentContext > xContext = cppu::defaultBootstrap_InitialComponentContext();
        uno::Reference< lang::XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), uno::UNO_QUERY );

        if( !xServiceManager.is() )
            Application::Abort( "Failed to bootstrap" );

        comphelper::setProcessServiceFactory( xServiceManager );

        InitVCL();

        CalcTestApp aApp;
        aApp.Main();

        DeInitVCL();
    }
    catch (const css::uno::Exception& e)
    {
        SAL_WARN("vcl.app", "Fatal exception: " << e.Message);
        return EXIT_FAILURE;
    }
    catch (const std::exception& e)
    {
        SAL_WARN("vcl.app", "Fatal exception: " << e.what());
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */