1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <vcl/svpforlokit.hxx>
24 #include "headless/svpbmp.hxx"
25 #include "headless/svpinst.hxx"
26 #include "headless/svpvd.hxx"
27 #include "headless/svpgdi.hxx"
29 #include <basegfx/vector/b2ivector.hxx>
30 #include <basebmp/scanlineformats.hxx>
34 using namespace basegfx
;
35 using namespace basebmp
;
37 SvpSalVirtualDevice::~SvpSalVirtualDevice()
41 SalGraphics
* SvpSalVirtualDevice::AcquireGraphics()
43 SvpSalGraphics
* pGraphics
= new SvpSalGraphics();
44 pGraphics
->setDevice( m_aDevice
);
45 m_aGraphics
.push_back( pGraphics
);
49 void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics
* pGraphics
)
51 m_aGraphics
.remove( dynamic_cast<SvpSalGraphics
*>(pGraphics
) );
55 bool SvpSalVirtualDevice::SetSize( long nNewDX
, long nNewDY
)
57 return SetSizeUsingBuffer( nNewDX
, nNewDY
, basebmp::RawMemorySharedArray(), false );
60 bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX
, long nNewDY
,
61 const basebmp::RawMemorySharedArray
&pBuffer
,
64 B2IVector
aDevSize( nNewDX
, nNewDY
);
65 if( aDevSize
.getX() == 0 )
67 if( aDevSize
.getY() == 0 )
69 if( ! m_aDevice
.get() || m_aDevice
->getSize() != aDevSize
)
71 SvpSalInstance
* pInst
= SvpSalInstance::s_pDefaultInstance
;
73 basebmp::Format nFormat
= pInst
->getFormatForBitCount( m_nBitCount
);
74 sal_Int32 nStride
= basebmp::getBitmapDeviceStrideForWidth(nFormat
, aDevSize
.getX());
76 if ( m_nBitCount
== 1 )
78 std::vector
< basebmp::Color
> aDevPal(2);
79 aDevPal
[0] = basebmp::Color( 0, 0, 0 );
80 aDevPal
[1] = basebmp::Color( 0xff, 0xff, 0xff );
81 m_aDevice
= createBitmapDevice( aDevSize
, bTopDown
, nFormat
, nStride
,
82 PaletteMemorySharedVector( new std::vector
< basebmp::Color
>(aDevPal
) ) );
87 createBitmapDevice( aDevSize
, bTopDown
, nFormat
, nStride
, pBuffer
, PaletteMemorySharedVector() )
88 : createBitmapDevice( aDevSize
, bTopDown
, nFormat
, nStride
);
91 // update device in existing graphics
92 for( std::list
< SvpSalGraphics
* >::iterator it
= m_aGraphics
.begin();
93 it
!= m_aGraphics
.end(); ++it
)
94 (*it
)->setDevice( m_aDevice
);
100 void InitSvpForLibreOfficeKit()
102 ImplSVData
* pSVData
= ImplGetSVData();
103 SvpSalInstance
* pSalInstance
= static_cast< SvpSalInstance
* >(pSVData
->mpDefInst
);
104 pSalInstance
->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA
);
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */