Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "svx/XPropertyTable.hxx"
30 : : #include <vcl/svapp.hxx>
31 : :
32 : : #include <vcl/virdev.hxx>
33 : : #include <svl/itemset.hxx>
34 : : #include <svx/dialogs.hrc>
35 : : #include <svx/dialmgr.hxx>
36 : : #include <svx/xtable.hxx>
37 : : #include <svx/xpool.hxx>
38 : : #include "svx/dlgutil.hxx"
39 : : #include <svx/xflhtit.hxx>
40 : : #include <svx/xflclit.hxx>
41 : : #include <svx/xfillit0.hxx>
42 : :
43 : : #include <svx/svdorect.hxx>
44 : : #include <svx/svdmodel.hxx>
45 : : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
46 : : #include <svx/sdr/contact/displayinfo.hxx>
47 : : #include <svx/xlnclit.hxx>
48 : :
49 : : using namespace ::com::sun::star;
50 : : using namespace ::rtl;
51 : :
52 : : class impXHatchList
53 : : {
54 : : private:
55 : : VirtualDevice* mpVirtualDevice;
56 : : SdrModel* mpSdrModel;
57 : : SdrObject* mpBackgroundObject;
58 : : SdrObject* mpHatchObject;
59 : :
60 : : public:
61 : 0 : impXHatchList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pH)
62 : : : mpVirtualDevice(pV),
63 : : mpSdrModel(pM),
64 : : mpBackgroundObject(pB),
65 : 0 : mpHatchObject(pH)
66 : 0 : {}
67 : :
68 : 0 : ~impXHatchList()
69 : : {
70 [ # # ]: 0 : delete mpVirtualDevice;
71 : 0 : SdrObject::Free(mpBackgroundObject);
72 : 0 : SdrObject::Free(mpHatchObject);
73 [ # # ]: 0 : delete mpSdrModel;
74 : 0 : }
75 : :
76 : 0 : VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
77 : 0 : SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
78 : 0 : SdrObject* getHatchObject() const { return mpHatchObject; }
79 : : };
80 : :
81 : 0 : void XHatchList::impCreate()
82 : : {
83 [ # # ]: 0 : if(!mpData)
84 : : {
85 : 0 : const Point aZero(0, 0);
86 [ # # ]: 0 : const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
87 : :
88 [ # # ][ # # ]: 0 : VirtualDevice* pVirDev = new VirtualDevice;
89 : : OSL_ENSURE(0 != pVirDev, "XDashList: no VirtualDevice created!" );
90 [ # # ][ # # ]: 0 : pVirDev->SetMapMode(MAP_100TH_MM);
[ # # ]
91 [ # # ]: 0 : const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH, BITMAP_HEIGHT)));
92 [ # # ]: 0 : pVirDev->SetOutputSize(aSize);
93 : 0 : pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
94 : : ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
95 [ # # ][ # # ]: 0 : : DRAWMODE_DEFAULT);
96 : :
97 [ # # ][ # # ]: 0 : SdrModel* pSdrModel = new SdrModel();
98 : : OSL_ENSURE(0 != pSdrModel, "XDashList: no SdrModel created!" );
99 [ # # ]: 0 : pSdrModel->GetItemPool().FreezeIdRanges();
100 : :
101 [ # # ]: 0 : const Size aSinglePixel(pVirDev->PixelToLogic(Size(1, 1)));
102 [ # # ]: 0 : const Rectangle aBackgroundSize(aZero, Size(aSize.getWidth() - aSinglePixel.getWidth(), aSize.getHeight() - aSinglePixel.getHeight()));
103 [ # # ][ # # ]: 0 : SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
104 : : OSL_ENSURE(0 != pBackgroundObject, "XDashList: no BackgroundObject created!" );
105 [ # # ]: 0 : pBackgroundObject->SetModel(pSdrModel);
106 [ # # ][ # # ]: 0 : pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID));
[ # # ]
107 [ # # ][ # # ]: 0 : pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor()));
[ # # ][ # # ]
[ # # ]
108 [ # # ][ # # ]: 0 : pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_SOLID));
[ # # ]
109 [ # # ][ # # ]: 0 : pBackgroundObject->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK)));
[ # # ][ # # ]
[ # # ]
110 : :
111 [ # # ][ # # ]: 0 : SdrObject* pHatchObject = new SdrRectObj(aBackgroundSize);
112 : : OSL_ENSURE(0 != pHatchObject, "XDashList: no HatchObject created!" );
113 [ # # ]: 0 : pHatchObject->SetModel(pSdrModel);
114 [ # # ][ # # ]: 0 : pHatchObject->SetMergedItem(XFillStyleItem(XFILL_HATCH));
[ # # ]
115 [ # # ][ # # ]: 0 : pHatchObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
[ # # ]
116 : :
117 [ # # ]: 0 : mpData = new impXHatchList(pVirDev, pSdrModel, pBackgroundObject, pHatchObject);
118 : : OSL_ENSURE(0 != mpData, "XDashList: data creation went wrong!" );
119 : : }
120 : 0 : }
121 : :
122 : 0 : void XHatchList::impDestroy()
123 : : {
124 [ # # ]: 0 : delete mpData;
125 : 0 : mpData = NULL;
126 : 0 : }
127 : :
128 : 3339 : XHatchList::XHatchList( const String& rPath,
129 : : XOutdevItemPool* pInPool )
130 : : : XPropertyList( XHATCH_LIST, rPath, pInPool ),
131 : 3339 : mpData( NULL )
132 : : {
133 [ + - ][ + - ]: 3339 : pBmpList = new BitmapList_impl();
134 : 3339 : }
135 : :
136 : 3234 : XHatchList::~XHatchList()
137 : : {
138 [ - + ][ # # ]: 3234 : delete mpData;
139 : 3234 : mpData = NULL;
140 [ - + ]: 6468 : }
141 : :
142 : 0 : XHatchEntry* XHatchList::Replace(XHatchEntry* pEntry, long nIndex )
143 : : {
144 : 0 : return (XHatchEntry*) XPropertyList::Replace(pEntry, nIndex);
145 : : }
146 : :
147 : 0 : XHatchEntry* XHatchList::Remove(long nIndex)
148 : : {
149 : 0 : return (XHatchEntry*) XPropertyList::Remove(nIndex);
150 : : }
151 : :
152 : 0 : XHatchEntry* XHatchList::GetHatch(long nIndex) const
153 : : {
154 : 0 : return (XHatchEntry*) XPropertyList::Get(nIndex, 0);
155 : : }
156 : :
157 : 11 : uno::Reference< container::XNameContainer > XHatchList::createInstance()
158 : : {
159 : : return uno::Reference< container::XNameContainer >(
160 [ + - ]: 11 : SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY );
161 : : }
162 : :
163 : 0 : sal_Bool XHatchList::Create()
164 : : {
165 [ # # ][ # # ]: 0 : XubString aStr( SVX_RES( RID_SVXSTR_HATCH ) );
166 : : xub_StrLen nLen;
167 : :
168 [ # # ]: 0 : aStr.AppendAscii(" 1");
169 : 0 : nLen = aStr.Len() - 1;
170 [ # # ][ # # ]: 0 : Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLACK),XHATCH_SINGLE,100, 0),aStr));
[ # # ][ # # ]
[ # # ]
171 [ # # ]: 0 : aStr.SetChar(nLen, sal_Unicode('2'));
172 [ # # ][ # # ]: 0 : Insert(new XHatchEntry(XHatch(RGB_Color(COL_RED ),XHATCH_DOUBLE, 80,450),aStr));
[ # # ][ # # ]
[ # # ]
173 [ # # ]: 0 : aStr.SetChar(nLen, sal_Unicode('3'));
174 [ # # ][ # # ]: 0 : Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLUE ),XHATCH_TRIPLE,120, 0),aStr));
[ # # ][ # # ]
[ # # ]
175 : :
176 [ # # ]: 0 : return( sal_True );
177 : : }
178 : :
179 : 0 : sal_Bool XHatchList::CreateBitmapsForUI()
180 : : {
181 : 0 : impCreate();
182 : :
183 [ # # ]: 0 : for( long i = 0; i < Count(); i++)
184 : : {
185 [ # # ]: 0 : Bitmap* pBmp = CreateBitmapForUI( i, sal_False );
186 : : DBG_ASSERT( pBmp, "XHatchList: Bitmap(UI) konnte nicht erzeugt werden!" );
187 : :
188 [ # # ]: 0 : if( pBmp )
189 : : {
190 [ # # ]: 0 : if ( (size_t)i < pBmpList->size() ) {
191 [ # # ][ # # ]: 0 : pBmpList->insert( pBmpList->begin() + i, pBmp );
192 : : } else {
193 [ # # ]: 0 : pBmpList->push_back( pBmp );
194 : : }
195 : : }
196 : : }
197 : :
198 : 0 : impDestroy();
199 : :
200 : 0 : return( sal_True );
201 : : }
202 : :
203 : 0 : Bitmap* XHatchList::CreateBitmapForUI( long nIndex, sal_Bool bDelete )
204 : : {
205 [ # # ]: 0 : impCreate();
206 : 0 : VirtualDevice* pVD = mpData->getVirtualDevice();
207 : 0 : SdrObject* pHatchObject = mpData->getHatchObject();
208 : :
209 [ # # ][ # # ]: 0 : pHatchObject->SetMergedItem(XFillStyleItem(XFILL_HATCH));
[ # # ]
210 [ # # ][ # # ]: 0 : pHatchObject->SetMergedItem(XFillHatchItem(String(), GetHatch(nIndex)->GetHatch()));
[ # # ][ # # ]
[ # # ][ # # ]
211 : :
212 [ # # ]: 0 : sdr::contact::SdrObjectVector aObjectVector;
213 [ # # ]: 0 : aObjectVector.push_back(mpData->getBackgroundObject());
214 [ # # ]: 0 : aObjectVector.push_back(pHatchObject);
215 [ # # ]: 0 : sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
216 [ # # ]: 0 : sdr::contact::DisplayInfo aDisplayInfo;
217 : :
218 [ # # ]: 0 : aPainter.ProcessDisplay(aDisplayInfo);
219 : :
220 : 0 : const Point aZero(0, 0);
221 [ # # ][ # # ]: 0 : Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
[ # # ]
222 : :
223 [ # # ]: 0 : if(bDelete)
224 [ # # ]: 0 : impDestroy();
225 : :
226 [ # # ][ # # ]: 0 : return pBitmap;
227 : : }
228 : :
229 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|