1c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c142477cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c142477cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c142477cSAndrew Rist  * distributed with this work for additional information
6c142477cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c142477cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c142477cSAndrew Rist  * "License"); you may not use this file except in compliance
9c142477cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10c142477cSAndrew Rist  *
11c142477cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12c142477cSAndrew Rist  *
13c142477cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c142477cSAndrew Rist  * software distributed under the License is distributed on an
15c142477cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c142477cSAndrew Rist  * KIND, either express or implied.  See the License for the
17c142477cSAndrew Rist  * specific language governing permissions and limitations
18c142477cSAndrew Rist  * under the License.
19c142477cSAndrew Rist  *
20c142477cSAndrew Rist  *************************************************************/
21c142477cSAndrew Rist 
22c142477cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterBitmapContainer.hxx"
28cdf0e10cSrcweir #include "PresenterConfigurationAccess.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <com/sun/star/deployment/XPackageInformationProvider.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/XPresenterHelper.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp>
33cdf0e10cSrcweir #include <com/sun/star/rendering/CompositeOperation.hpp>
34cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
35cdf0e10cSrcweir #include <boost/bind.hpp>
36cdf0e10cSrcweir #include <map>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using namespace ::com::sun::star;
39cdf0e10cSrcweir using namespace ::com::sun::star::uno;
40cdf0e10cSrcweir using namespace ::std;
41cdf0e10cSrcweir using ::rtl::OUString;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir namespace sdext { namespace presenter {
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace {
49cdf0e10cSrcweir static OUString gsNameProperty (A2S("Name"));
50cdf0e10cSrcweir static OUString gsNormalFileNameProperty (A2S("NormalFileName"));
51cdf0e10cSrcweir static OUString gsMouseOverFileNameProperty (A2S("MouseOverFileName"));
52cdf0e10cSrcweir static OUString gsButtonDownFileNameProperty (A2S("ButtonDownFileName"));
53cdf0e10cSrcweir static OUString gsDisabledFileNameProperty (A2S("DisabledFileName"));
54cdf0e10cSrcweir static OUString gsMaskFileNameProperty (A2S("MaskFileName"));
55cdf0e10cSrcweir static OUString gsXOffsetProperty (A2S("XOffset"));
56cdf0e10cSrcweir static OUString gsYOffsetProperty (A2S("YOffset"));
57cdf0e10cSrcweir static OUString gsXHotSpotProperty (A2S("XHotSpot"));
58cdf0e10cSrcweir static OUString gsYHotSpotProperty (A2S("YHotSpot"));
59cdf0e10cSrcweir static OUString gsReplacementColorProperty (A2S("ReplacementColor"));
60cdf0e10cSrcweir static OUString gsHorizontalTexturingModeProperty (A2S("HorizontalTexturingMode"));
61cdf0e10cSrcweir static OUString gsVerticalTexturingModeProperty (A2S("VerticalTexturingMode"));
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //===== PresenterBitmapContainer ==============================================
65cdf0e10cSrcweir 
PresenterBitmapContainer(const::rtl::OUString & rsConfigurationBase,const::boost::shared_ptr<PresenterBitmapContainer> & rpParentContainer,const css::uno::Reference<css::uno::XComponentContext> & rxComponentContext,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas,const css::uno::Reference<css::drawing::XPresenterHelper> & rxPresenterHelper)66cdf0e10cSrcweir PresenterBitmapContainer::PresenterBitmapContainer (
67cdf0e10cSrcweir     const ::rtl::OUString& rsConfigurationBase,
68cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer,
69cdf0e10cSrcweir     const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
70cdf0e10cSrcweir     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
71cdf0e10cSrcweir     const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper)
72cdf0e10cSrcweir     : mpParentContainer(rpParentContainer),
73cdf0e10cSrcweir       maIconContainer(),
74cdf0e10cSrcweir       mxCanvas(rxCanvas),
75cdf0e10cSrcweir       mxPresenterHelper(rxPresenterHelper)
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     Initialize(rxComponentContext);
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     // Get access to the configuration.
80cdf0e10cSrcweir     PresenterConfigurationAccess aConfiguration (
81cdf0e10cSrcweir         rxComponentContext,
82*79e0a548SAriel Constenla-Haile         A2S("org.openoffice.Office.PresenterScreen"),
83cdf0e10cSrcweir         PresenterConfigurationAccess::READ_ONLY);
84cdf0e10cSrcweir     Reference<container::XNameAccess> xBitmapList (
85cdf0e10cSrcweir         aConfiguration.GetConfigurationNode(rsConfigurationBase),
86cdf0e10cSrcweir         UNO_QUERY_THROW);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     LoadBitmaps(xBitmapList);
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
PresenterBitmapContainer(const css::uno::Reference<css::container::XNameAccess> & rxRootNode,const::boost::shared_ptr<PresenterBitmapContainer> & rpParentContainer,const css::uno::Reference<css::uno::XComponentContext> & rxComponentContext,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas,const css::uno::Reference<css::drawing::XPresenterHelper> & rxPresenterHelper)95cdf0e10cSrcweir PresenterBitmapContainer::PresenterBitmapContainer (
96cdf0e10cSrcweir     const css::uno::Reference<css::container::XNameAccess>& rxRootNode,
97cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterBitmapContainer>& rpParentContainer,
98cdf0e10cSrcweir     const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext,
99cdf0e10cSrcweir     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
100cdf0e10cSrcweir     const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper)
101cdf0e10cSrcweir     : mpParentContainer(rpParentContainer),
102cdf0e10cSrcweir       maIconContainer(),
103cdf0e10cSrcweir       mxCanvas(rxCanvas),
104cdf0e10cSrcweir       mxPresenterHelper(rxPresenterHelper)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     Initialize(rxComponentContext);
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     LoadBitmaps(rxRootNode);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 
Initialize(const css::uno::Reference<css::uno::XComponentContext> & rxComponentContext)114cdf0e10cSrcweir void PresenterBitmapContainer::Initialize (
115cdf0e10cSrcweir     const css::uno::Reference<css::uno::XComponentContext>& rxComponentContext)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir     if ( ! mxPresenterHelper.is())
118cdf0e10cSrcweir     {
119cdf0e10cSrcweir         // Create an object that is able to load the bitmaps in a format that is
120cdf0e10cSrcweir         // supported by the canvas.
121cdf0e10cSrcweir         Reference<lang::XMultiComponentFactory> xFactory (
122cdf0e10cSrcweir             rxComponentContext->getServiceManager(), UNO_QUERY);
123cdf0e10cSrcweir         if ( ! xFactory.is())
124cdf0e10cSrcweir             return;
125cdf0e10cSrcweir         mxPresenterHelper = Reference<drawing::XPresenterHelper>(
126cdf0e10cSrcweir             xFactory->createInstanceWithContext(
127cdf0e10cSrcweir                 A2S("com.sun.star.drawing.PresenterHelper"),
128cdf0e10cSrcweir                 rxComponentContext),
129cdf0e10cSrcweir             UNO_QUERY_THROW);
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
~PresenterBitmapContainer(void)136cdf0e10cSrcweir PresenterBitmapContainer::~PresenterBitmapContainer (void)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir     maIconContainer.clear();
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 
GetBitmap(const OUString & rsName) const144cdf0e10cSrcweir SharedBitmapDescriptor PresenterBitmapContainer::GetBitmap (
145cdf0e10cSrcweir     const OUString& rsName) const
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     BitmapContainer::const_iterator iSet (maIconContainer.find(rsName));
148cdf0e10cSrcweir     if (iSet != maIconContainer.end())
149cdf0e10cSrcweir         return iSet->second;
150cdf0e10cSrcweir     else if (mpParentContainer.get() != NULL)
151cdf0e10cSrcweir         return mpParentContainer->GetBitmap(rsName);
152cdf0e10cSrcweir     else
153cdf0e10cSrcweir         return SharedBitmapDescriptor();
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 
LoadBitmaps(const css::uno::Reference<css::container::XNameAccess> & rxBitmapList)159cdf0e10cSrcweir void PresenterBitmapContainer::LoadBitmaps (
160cdf0e10cSrcweir     const css::uno::Reference<css::container::XNameAccess>& rxBitmapList)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     if ( ! mxCanvas.is())
163cdf0e10cSrcweir         return;
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     if ( ! rxBitmapList.is())
166cdf0e10cSrcweir         return;
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     try
169cdf0e10cSrcweir     {
170cdf0e10cSrcweir         // Load all button bitmaps.
171cdf0e10cSrcweir         if (rxBitmapList.is())
172cdf0e10cSrcweir         {
173cdf0e10cSrcweir             PresenterConfigurationAccess::ForAll(
174cdf0e10cSrcweir                 rxBitmapList,
175cdf0e10cSrcweir                 ::boost::bind(&PresenterBitmapContainer::ProcessBitmap, this, _1, _2));
176cdf0e10cSrcweir         }
177cdf0e10cSrcweir     }
178cdf0e10cSrcweir     catch (Exception&)
179cdf0e10cSrcweir     {
180cdf0e10cSrcweir         OSL_ASSERT(false);
181cdf0e10cSrcweir     }
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 
LoadBitmap(const css::uno::Reference<css::container::XHierarchicalNameAccess> & rxNode,const::rtl::OUString & rsPath,const css::uno::Reference<css::drawing::XPresenterHelper> & rxPresenterHelper,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas,const SharedBitmapDescriptor & rpDefault)187cdf0e10cSrcweir SharedBitmapDescriptor PresenterBitmapContainer::LoadBitmap (
188cdf0e10cSrcweir     const css::uno::Reference<css::container::XHierarchicalNameAccess>& rxNode,
189cdf0e10cSrcweir     const ::rtl::OUString& rsPath,
190cdf0e10cSrcweir     const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
191cdf0e10cSrcweir     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
192cdf0e10cSrcweir     const SharedBitmapDescriptor& rpDefault)
193cdf0e10cSrcweir {
194cdf0e10cSrcweir     SharedBitmapDescriptor pBitmap;
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     if (rxNode.is())
197cdf0e10cSrcweir     {
198cdf0e10cSrcweir         try
199cdf0e10cSrcweir         {
200cdf0e10cSrcweir             Reference<beans::XPropertySet> xBitmapProperties (
201cdf0e10cSrcweir                 PresenterConfigurationAccess::GetConfigurationNode(rxNode, rsPath),
202cdf0e10cSrcweir                 UNO_QUERY);
203cdf0e10cSrcweir             if (xBitmapProperties.is())
204cdf0e10cSrcweir                 pBitmap = LoadBitmap(
205cdf0e10cSrcweir                     xBitmapProperties,
206cdf0e10cSrcweir                     rxPresenterHelper,
207cdf0e10cSrcweir                     rxCanvas,
208cdf0e10cSrcweir                     rpDefault);
209cdf0e10cSrcweir         }
210cdf0e10cSrcweir         catch (Exception&)
211cdf0e10cSrcweir         {
212cdf0e10cSrcweir             OSL_ASSERT(false);
213cdf0e10cSrcweir         }
214cdf0e10cSrcweir     }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir     return pBitmap;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 
ProcessBitmap(const OUString & rsKey,const Reference<beans::XPropertySet> & rxProperties)222cdf0e10cSrcweir void PresenterBitmapContainer::ProcessBitmap (
223cdf0e10cSrcweir     const OUString& rsKey,
224cdf0e10cSrcweir     const Reference<beans::XPropertySet>& rxProperties)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir     OUString sName;
227cdf0e10cSrcweir     if ( ! (PresenterConfigurationAccess::GetProperty(rxProperties, gsNameProperty) >>= sName))
228cdf0e10cSrcweir         sName = rsKey;
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     maIconContainer[sName] = LoadBitmap(
231cdf0e10cSrcweir         rxProperties,
232cdf0e10cSrcweir         mxPresenterHelper,
233cdf0e10cSrcweir         mxCanvas,
234cdf0e10cSrcweir         SharedBitmapDescriptor());
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 
LoadBitmap(const Reference<beans::XPropertySet> & rxProperties,const css::uno::Reference<css::drawing::XPresenterHelper> & rxPresenterHelper,const css::uno::Reference<css::rendering::XCanvas> & rxCanvas,const SharedBitmapDescriptor & rpDefault)240cdf0e10cSrcweir SharedBitmapDescriptor PresenterBitmapContainer::LoadBitmap (
241cdf0e10cSrcweir     const Reference<beans::XPropertySet>& rxProperties,
242cdf0e10cSrcweir     const css::uno::Reference<css::drawing::XPresenterHelper>& rxPresenterHelper,
243cdf0e10cSrcweir     const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
244cdf0e10cSrcweir     const SharedBitmapDescriptor& rpDefault)
245cdf0e10cSrcweir {
246cdf0e10cSrcweir     OSL_ASSERT(rxCanvas.is());
247cdf0e10cSrcweir     OSL_ASSERT(rxPresenterHelper.is());
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     SharedBitmapDescriptor pBitmap (new BitmapDescriptor(rpDefault));
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     if ( ! rxProperties.is())
252cdf0e10cSrcweir         return pBitmap;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     OUString sFileName;
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     // Load bitmaps.
257cdf0e10cSrcweir     if (PresenterConfigurationAccess::GetProperty(rxProperties, gsNormalFileNameProperty) >>= sFileName)
258cdf0e10cSrcweir         try
259cdf0e10cSrcweir         {
260cdf0e10cSrcweir             pBitmap->SetBitmap(
261cdf0e10cSrcweir                 BitmapDescriptor::Normal,
262*79e0a548SAriel Constenla-Haile                 rxPresenterHelper->loadBitmap(sFileName, rxCanvas));
263cdf0e10cSrcweir         }
264cdf0e10cSrcweir         catch (Exception&)
265cdf0e10cSrcweir         {}
266cdf0e10cSrcweir     if (PresenterConfigurationAccess::GetProperty(rxProperties, gsMouseOverFileNameProperty) >>= sFileName)
267cdf0e10cSrcweir         try
268cdf0e10cSrcweir         {
269cdf0e10cSrcweir             pBitmap->SetBitmap(
270cdf0e10cSrcweir                 BitmapDescriptor::MouseOver,
271*79e0a548SAriel Constenla-Haile                 rxPresenterHelper->loadBitmap(sFileName, rxCanvas));
272cdf0e10cSrcweir         }
273cdf0e10cSrcweir         catch (Exception&)
274cdf0e10cSrcweir         {}
275cdf0e10cSrcweir     if (PresenterConfigurationAccess::GetProperty(rxProperties, gsButtonDownFileNameProperty) >>= sFileName)
276cdf0e10cSrcweir         try
277cdf0e10cSrcweir         {
278cdf0e10cSrcweir             pBitmap->SetBitmap(
279cdf0e10cSrcweir                 BitmapDescriptor::ButtonDown,
280*79e0a548SAriel Constenla-Haile                 rxPresenterHelper->loadBitmap(sFileName, rxCanvas));
281cdf0e10cSrcweir         }
282cdf0e10cSrcweir         catch (Exception&)
283cdf0e10cSrcweir         {}
284cdf0e10cSrcweir     if (PresenterConfigurationAccess::GetProperty(rxProperties, gsDisabledFileNameProperty) >>= sFileName)
285cdf0e10cSrcweir         try
286cdf0e10cSrcweir         {
287cdf0e10cSrcweir             pBitmap->SetBitmap(
288cdf0e10cSrcweir                 BitmapDescriptor::Disabled,
289*79e0a548SAriel Constenla-Haile                 rxPresenterHelper->loadBitmap(sFileName, rxCanvas));
290cdf0e10cSrcweir         }
291cdf0e10cSrcweir         catch (Exception&)
292cdf0e10cSrcweir         {}
293cdf0e10cSrcweir     if (PresenterConfigurationAccess::GetProperty(rxProperties, gsMaskFileNameProperty) >>= sFileName)
294cdf0e10cSrcweir         try
295cdf0e10cSrcweir         {
296cdf0e10cSrcweir             pBitmap->SetBitmap(
297cdf0e10cSrcweir                 BitmapDescriptor::Mask,
298*79e0a548SAriel Constenla-Haile                 rxPresenterHelper->loadBitmap(sFileName, rxCanvas));
299cdf0e10cSrcweir         }
300cdf0e10cSrcweir         catch (Exception&)
301cdf0e10cSrcweir         {}
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     PresenterConfigurationAccess::GetProperty(rxProperties, gsXOffsetProperty) >>= pBitmap->mnXOffset;
305cdf0e10cSrcweir     PresenterConfigurationAccess::GetProperty(rxProperties, gsYOffsetProperty) >>= pBitmap->mnYOffset;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     PresenterConfigurationAccess::GetProperty(rxProperties, gsXHotSpotProperty) >>= pBitmap->mnXHotSpot;
308cdf0e10cSrcweir     PresenterConfigurationAccess::GetProperty(rxProperties, gsYHotSpotProperty) >>= pBitmap->mnYHotSpot;
309cdf0e10cSrcweir 
310cdf0e10cSrcweir     PresenterConfigurationAccess::GetProperty(rxProperties, gsReplacementColorProperty) >>= pBitmap->maReplacementColor;
311cdf0e10cSrcweir 
312cdf0e10cSrcweir     OUString sTexturingMode;
313cdf0e10cSrcweir     if (PresenterConfigurationAccess::GetProperty(rxProperties, gsHorizontalTexturingModeProperty) >>= sTexturingMode)
314cdf0e10cSrcweir         pBitmap->meHorizontalTexturingMode = StringToTexturingMode(sTexturingMode);
315cdf0e10cSrcweir     if (PresenterConfigurationAccess::GetProperty(rxProperties, gsVerticalTexturingModeProperty) >>= sTexturingMode)
316cdf0e10cSrcweir         pBitmap->meVerticalTexturingMode = StringToTexturingMode(sTexturingMode);
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     return pBitmap;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 
324cdf0e10cSrcweir PresenterBitmapContainer::BitmapDescriptor::TexturingMode
StringToTexturingMode(const OUString & rsTexturingMode)325cdf0e10cSrcweir     PresenterBitmapContainer::StringToTexturingMode (const OUString& rsTexturingMode)
326cdf0e10cSrcweir {
327cdf0e10cSrcweir     if (rsTexturingMode == A2S("Once"))
328cdf0e10cSrcweir         return PresenterBitmapContainer::BitmapDescriptor::Once;
329cdf0e10cSrcweir     else if (rsTexturingMode == A2S("Repeat"))
330cdf0e10cSrcweir         return PresenterBitmapContainer::BitmapDescriptor::Repeat;
331cdf0e10cSrcweir     else if (rsTexturingMode == A2S("Stretch"))
332cdf0e10cSrcweir         return PresenterBitmapContainer::BitmapDescriptor::Stretch;
333cdf0e10cSrcweir     else
334cdf0e10cSrcweir         return PresenterBitmapContainer::BitmapDescriptor::Once;
335cdf0e10cSrcweir }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 
340cdf0e10cSrcweir //===== PresenterBitmapContainer::BitmapSet ===================================
341cdf0e10cSrcweir 
BitmapDescriptor(void)342cdf0e10cSrcweir PresenterBitmapContainer::BitmapDescriptor::BitmapDescriptor (void)
343cdf0e10cSrcweir     : mnWidth(0),
344cdf0e10cSrcweir       mnHeight(0),
345cdf0e10cSrcweir       mnXOffset(0),
346cdf0e10cSrcweir       mnYOffset(0),
347cdf0e10cSrcweir       mnXHotSpot(0),
348cdf0e10cSrcweir       mnYHotSpot(0),
349cdf0e10cSrcweir       maReplacementColor(0x00000000),
350cdf0e10cSrcweir       meHorizontalTexturingMode(Once),
351cdf0e10cSrcweir       meVerticalTexturingMode(Once),
352cdf0e10cSrcweir       mxNormalBitmap(),
353cdf0e10cSrcweir       mxMouseOverBitmap(),
354cdf0e10cSrcweir       mxButtonDownBitmap(),
355cdf0e10cSrcweir       mxDisabledBitmap(),
356cdf0e10cSrcweir       mxMaskBitmap()
357cdf0e10cSrcweir {
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 
BitmapDescriptor(const::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor> & rpDefault)363cdf0e10cSrcweir PresenterBitmapContainer::BitmapDescriptor::BitmapDescriptor (
364cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterBitmapContainer::BitmapDescriptor>& rpDefault)
365cdf0e10cSrcweir     : mnWidth(0),
366cdf0e10cSrcweir       mnHeight(0),
367cdf0e10cSrcweir       mnXOffset(0),
368cdf0e10cSrcweir       mnYOffset(0),
369cdf0e10cSrcweir       mnXHotSpot(0),
370cdf0e10cSrcweir       mnYHotSpot(0),
371cdf0e10cSrcweir       maReplacementColor(0x00000000),
372cdf0e10cSrcweir       meHorizontalTexturingMode(Once),
373cdf0e10cSrcweir       meVerticalTexturingMode(Once),
374cdf0e10cSrcweir       mxNormalBitmap(),
375cdf0e10cSrcweir       mxMouseOverBitmap(),
376cdf0e10cSrcweir       mxButtonDownBitmap(),
377cdf0e10cSrcweir       mxDisabledBitmap(),
378cdf0e10cSrcweir       mxMaskBitmap()
379cdf0e10cSrcweir {
380cdf0e10cSrcweir     if (rpDefault.get() != NULL)
381cdf0e10cSrcweir     {
382cdf0e10cSrcweir         mnWidth = rpDefault->mnWidth;
383cdf0e10cSrcweir         mnHeight = rpDefault->mnHeight;
384cdf0e10cSrcweir         mnXOffset = rpDefault->mnXOffset;
385cdf0e10cSrcweir         mnYOffset = rpDefault->mnYOffset;
386cdf0e10cSrcweir         mnXHotSpot = rpDefault->mnXHotSpot;
387cdf0e10cSrcweir         mnYHotSpot = rpDefault->mnYHotSpot;
388cdf0e10cSrcweir         maReplacementColor = rpDefault->maReplacementColor;
389cdf0e10cSrcweir         meHorizontalTexturingMode = rpDefault->meHorizontalTexturingMode;
390cdf0e10cSrcweir         meVerticalTexturingMode = rpDefault->meVerticalTexturingMode;
391cdf0e10cSrcweir         mxNormalBitmap = rpDefault->mxNormalBitmap;
392cdf0e10cSrcweir         mxMouseOverBitmap = rpDefault->mxMouseOverBitmap;
393cdf0e10cSrcweir         mxButtonDownBitmap = rpDefault->mxButtonDownBitmap;
394cdf0e10cSrcweir         mxDisabledBitmap = rpDefault->mxDisabledBitmap;
395cdf0e10cSrcweir         mxMaskBitmap = rpDefault->mxMaskBitmap;
396cdf0e10cSrcweir     }
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 
400cdf0e10cSrcweir css::uno::Reference<css::rendering::XBitmap>
GetNormalBitmap(void) const401cdf0e10cSrcweir     PresenterBitmapContainer::BitmapDescriptor::GetNormalBitmap (void) const
402cdf0e10cSrcweir {
403cdf0e10cSrcweir     return mxNormalBitmap;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 
409cdf0e10cSrcweir css::uno::Reference<css::rendering::XBitmap>
GetBitmap(const Mode eMode,const bool bMissingDefaultsToNormal) const410cdf0e10cSrcweir     PresenterBitmapContainer::BitmapDescriptor::GetBitmap (
411cdf0e10cSrcweir         const Mode eMode,
412cdf0e10cSrcweir         const bool bMissingDefaultsToNormal) const
413cdf0e10cSrcweir {
414cdf0e10cSrcweir     switch (eMode)
415cdf0e10cSrcweir     {
416cdf0e10cSrcweir         case Normal:
417cdf0e10cSrcweir         default:
418cdf0e10cSrcweir             return mxNormalBitmap;
419cdf0e10cSrcweir 
420cdf0e10cSrcweir         case MouseOver:
421cdf0e10cSrcweir             if (mxMouseOverBitmap.is())
422cdf0e10cSrcweir                 return mxMouseOverBitmap;
423cdf0e10cSrcweir             else if (bMissingDefaultsToNormal)
424cdf0e10cSrcweir                 return mxNormalBitmap;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir         case ButtonDown:
427cdf0e10cSrcweir             if (mxButtonDownBitmap.is())
428cdf0e10cSrcweir                 return mxButtonDownBitmap;
429cdf0e10cSrcweir             else if (bMissingDefaultsToNormal)
430cdf0e10cSrcweir                 return mxNormalBitmap;
431cdf0e10cSrcweir 
432cdf0e10cSrcweir         case Disabled:
433cdf0e10cSrcweir             if (mxDisabledBitmap.is())
434cdf0e10cSrcweir                 return mxDisabledBitmap;
435cdf0e10cSrcweir             else if (bMissingDefaultsToNormal)
436cdf0e10cSrcweir                 return mxNormalBitmap;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir         case Mask:
439cdf0e10cSrcweir             return mxMaskBitmap;
440cdf0e10cSrcweir     }
441cdf0e10cSrcweir     return NULL;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 
SetBitmap(const Mode eMode,const css::uno::Reference<css::rendering::XBitmap> & rxBitmap)447cdf0e10cSrcweir void PresenterBitmapContainer::BitmapDescriptor::SetBitmap (
448cdf0e10cSrcweir     const Mode eMode,
449cdf0e10cSrcweir     const css::uno::Reference<css::rendering::XBitmap>& rxBitmap)
450cdf0e10cSrcweir {
451cdf0e10cSrcweir     switch (eMode)
452cdf0e10cSrcweir     {
453cdf0e10cSrcweir         case Normal:
454cdf0e10cSrcweir         default:
455cdf0e10cSrcweir             mxNormalBitmap = rxBitmap;
456cdf0e10cSrcweir             if (mxNormalBitmap.is())
457cdf0e10cSrcweir             {
458cdf0e10cSrcweir                 const geometry::IntegerSize2D aSize (mxNormalBitmap->getSize());
459cdf0e10cSrcweir                 mnWidth = aSize.Width;
460cdf0e10cSrcweir                 mnHeight = aSize.Height;
461cdf0e10cSrcweir             }
462cdf0e10cSrcweir             break;
463cdf0e10cSrcweir 
464cdf0e10cSrcweir         case MouseOver:
465cdf0e10cSrcweir             mxMouseOverBitmap = rxBitmap;
466cdf0e10cSrcweir             break;
467cdf0e10cSrcweir 
468cdf0e10cSrcweir         case ButtonDown:
469cdf0e10cSrcweir             mxButtonDownBitmap = rxBitmap;
470cdf0e10cSrcweir             break;
471cdf0e10cSrcweir 
472cdf0e10cSrcweir         case Disabled:
473cdf0e10cSrcweir             mxDisabledBitmap = rxBitmap;
474cdf0e10cSrcweir             break;
475cdf0e10cSrcweir 
476cdf0e10cSrcweir         case Mask:
477cdf0e10cSrcweir             mxMaskBitmap = rxBitmap;
478cdf0e10cSrcweir             break;
479cdf0e10cSrcweir     }
480cdf0e10cSrcweir }
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 
485cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
486