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 .
20 #include "svx/XPropertyTable.hxx"
21 #include <vcl/svapp.hxx>
23 #include <vcl/virdev.hxx>
24 #include <svl/itemset.hxx>
25 #include <svx/dialogs.hrc>
26 #include <svx/dialmgr.hxx>
27 #include <svx/xtable.hxx>
28 #include <svx/xpool.hxx>
29 #include "svx/dlgutil.hxx"
30 #include <svx/xflhtit.hxx>
31 #include <svx/xflclit.hxx>
32 #include <svx/xfillit0.hxx>
34 #include <svx/svdorect.hxx>
35 #include <svx/svdmodel.hxx>
36 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
37 #include <svx/sdr/contact/displayinfo.hxx>
38 #include <svx/xlnclit.hxx>
40 using namespace ::com::sun::star
;
41 using namespace ::rtl
;
46 VirtualDevice
* mpVirtualDevice
;
48 SdrObject
* mpBackgroundObject
;
49 SdrObject
* mpHatchObject
;
52 impXHatchList(VirtualDevice
* pV
, SdrModel
* pM
, SdrObject
* pB
, SdrObject
* pH
)
53 : mpVirtualDevice(pV
),
55 mpBackgroundObject(pB
),
61 delete mpVirtualDevice
;
62 SdrObject::Free(mpBackgroundObject
);
63 SdrObject::Free(mpHatchObject
);
67 VirtualDevice
* getVirtualDevice() const { return mpVirtualDevice
; }
68 SdrObject
* getBackgroundObject() const { return mpBackgroundObject
; }
69 SdrObject
* getHatchObject() const { return mpHatchObject
; }
72 void XHatchList::impCreate()
76 const Point
aZero(0, 0);
77 const StyleSettings
& rStyleSettings
= Application::GetSettings().GetStyleSettings();
79 VirtualDevice
* pVirDev
= new VirtualDevice
;
80 OSL_ENSURE(0 != pVirDev
, "XDashList: no VirtualDevice created!" );
81 pVirDev
->SetMapMode(MAP_100TH_MM
);
82 const Size
aSize(pVirDev
->PixelToLogic(rStyleSettings
.GetListBoxPreviewDefaultPixelSize()));
83 pVirDev
->SetOutputSize(aSize
);
84 pVirDev
->SetDrawMode(rStyleSettings
.GetHighContrastMode()
85 ? DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
| DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
87 pVirDev
->SetBackground(rStyleSettings
.GetFieldColor());
89 SdrModel
* pSdrModel
= new SdrModel();
90 OSL_ENSURE(0 != pSdrModel
, "XDashList: no SdrModel created!" );
91 pSdrModel
->GetItemPool().FreezeIdRanges();
93 const Size
aSinglePixel(pVirDev
->PixelToLogic(Size(1, 1)));
94 const Rectangle
aBackgroundSize(aZero
, Size(aSize
.getWidth() - aSinglePixel
.getWidth(), aSize
.getHeight() - aSinglePixel
.getHeight()));
95 SdrObject
* pBackgroundObject
= new SdrRectObj(aBackgroundSize
);
96 OSL_ENSURE(0 != pBackgroundObject
, "XDashList: no BackgroundObject created!" );
97 pBackgroundObject
->SetModel(pSdrModel
);
98 pBackgroundObject
->SetMergedItem(XFillStyleItem(XFILL_SOLID
));
99 pBackgroundObject
->SetMergedItem(XFillColorItem(String(), rStyleSettings
.GetFieldColor()));
100 pBackgroundObject
->SetMergedItem(XLineStyleItem(XLINE_SOLID
));
101 pBackgroundObject
->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK
)));
103 SdrObject
* pHatchObject
= new SdrRectObj(aBackgroundSize
);
104 OSL_ENSURE(0 != pHatchObject
, "XDashList: no HatchObject created!" );
105 pHatchObject
->SetModel(pSdrModel
);
106 pHatchObject
->SetMergedItem(XFillStyleItem(XFILL_HATCH
));
107 pHatchObject
->SetMergedItem(XLineStyleItem(XLINE_NONE
));
109 mpData
= new impXHatchList(pVirDev
, pSdrModel
, pBackgroundObject
, pHatchObject
);
110 OSL_ENSURE(0 != mpData
, "XDashList: data creation went wrong!" );
114 void XHatchList::impDestroy()
120 XHatchList::XHatchList(const String
& rPath
, XOutdevItemPool
* pInPool
)
121 : XPropertyList( XHATCH_LIST
, rPath
, pInPool
),
126 XHatchList::~XHatchList()
132 XHatchEntry
* XHatchList::Replace(XHatchEntry
* pEntry
, long nIndex
)
134 return (XHatchEntry
*) XPropertyList::Replace(pEntry
, nIndex
);
137 XHatchEntry
* XHatchList::Remove(long nIndex
)
139 return (XHatchEntry
*) XPropertyList::Remove(nIndex
);
142 XHatchEntry
* XHatchList::GetHatch(long nIndex
) const
144 return (XHatchEntry
*) XPropertyList::Get(nIndex
, 0);
147 uno::Reference
< container::XNameContainer
> XHatchList::createInstance()
149 return uno::Reference
< container::XNameContainer
>(
150 SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY
);
153 sal_Bool
XHatchList::Create()
155 XubString
aStr( SVX_RES( RID_SVXSTR_HATCH
) );
158 aStr
.AppendAscii(" 1");
159 nLen
= aStr
.Len() - 1;
160 Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLACK
),XHATCH_SINGLE
,100, 0),aStr
));
161 aStr
.SetChar(nLen
, sal_Unicode('2'));
162 Insert(new XHatchEntry(XHatch(RGB_Color(COL_RED
),XHATCH_DOUBLE
, 80,450),aStr
));
163 aStr
.SetChar(nLen
, sal_Unicode('3'));
164 Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLUE
),XHATCH_TRIPLE
,120, 0),aStr
));
169 Bitmap
XHatchList::CreateBitmapForUI( long nIndex
)
172 VirtualDevice
* pVD
= mpData
->getVirtualDevice();
173 SdrObject
* pHatchObject
= mpData
->getHatchObject();
175 pHatchObject
->SetMergedItem(XFillStyleItem(XFILL_HATCH
));
176 pHatchObject
->SetMergedItem(XFillHatchItem(String(), GetHatch(nIndex
)->GetHatch()));
178 sdr::contact::SdrObjectVector aObjectVector
;
179 aObjectVector
.push_back(mpData
->getBackgroundObject());
180 aObjectVector
.push_back(pHatchObject
);
181 sdr::contact::ObjectContactOfObjListPainter
aPainter(*pVD
, aObjectVector
, 0);
182 sdr::contact::DisplayInfo aDisplayInfo
;
185 aPainter
.ProcessDisplay(aDisplayInfo
);
187 const Point
aZero(0, 0);
188 return pVD
->GetBitmap(aZero
, pVD
->GetOutputSize());
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */