LibreOffice Module svx (master)  1
XPropertyTable.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
21 #include <memory>
22 #include <svx/XPropertyTable.hxx>
23 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
24 #include <com/sun/star/drawing/LineDash.hpp>
25 #include <com/sun/star/awt/Gradient.hpp>
26 #include <com/sun/star/awt/XBitmap.hpp>
27 #include <com/sun/star/graphic/XGraphic.hpp>
28 #include <com/sun/star/drawing/Hatch.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <o3tl/any.hxx>
32 #include <vcl/svapp.hxx>
33 
34 #include <cppuhelper/implbase.hxx>
36 #include <svx/xdef.hxx>
37 
38 #include <svx/unoapi.hxx>
39 #include <editeng/unoprnms.hxx>
42 
43 using namespace com::sun::star;
44 using namespace ::cppu;
45 
46 namespace {
47 
48 class SvxUnoXPropertyTable : public WeakImplHelper< container::XNameContainer, lang::XServiceInfo >
49 {
50 private:
52  sal_Int16 const mnWhich;
53 
54  long getCount() const { return mpList ? mpList->Count() : 0; }
55  const XPropertyEntry* get(long index) const;
56 public:
57  SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw();
58 
60  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const = 0;
63  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const = 0;
64 
65  // XServiceInfo
66  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
67 
68  // XNameContainer
69  virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) override;
70  virtual void SAL_CALL removeByName( const OUString& Name ) override;
71 
72  // XNameReplace
73  virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) override;
74 
75  // XNameAccess
76  virtual uno::Any SAL_CALL getByName( const OUString& aName ) override;
77  virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
78  virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
79 
80  // XElementAccess
81  virtual sal_Bool SAL_CALL hasElements( ) override;
82 };
83 
84 }
85 
86 SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw()
87 : mpList( pList ), mnWhich( nWhich )
88 {
89 }
90 
91 const XPropertyEntry* SvxUnoXPropertyTable::get(long index) const
92 {
93  if( mpList )
94  return mpList->Get(index);
95  else
96  return nullptr;
97 }
98 
99 // XServiceInfo
100 sal_Bool SAL_CALL SvxUnoXPropertyTable::supportsService( const OUString& ServiceName )
101 {
102  return cppu::supportsService(this, ServiceName);
103 }
104 
105 // XNameContainer
106 void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const uno::Any& aElement )
107 {
108  SolarMutexGuard aGuard;
109 
110  if( nullptr == mpList )
111  throw lang::IllegalArgumentException();
112 
113  if( hasByName( aName ) )
114  throw container::ElementExistException();
115 
116  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
117 
118  std::unique_ptr<XPropertyEntry> pNewEntry(createEntry(aInternalName, aElement));
119  if (!pNewEntry)
120  throw lang::IllegalArgumentException();
121 
122  mpList->Insert(std::move(pNewEntry));
123 }
124 
125 void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name )
126 {
127  SolarMutexGuard aGuard;
128 
129  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, Name);
130 
131  const long nCount = getCount();
132  long i;
133  for( i = 0; i < nCount; i++ )
134  {
135  const XPropertyEntry* pEntry = get(i);
136  if (pEntry && aInternalName == pEntry->GetName())
137  {
138  mpList->Remove(i);
139  return;
140  }
141  }
142 
143  throw container::NoSuchElementException();
144 }
145 
146 // XNameReplace
147 void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const uno::Any& aElement )
148 {
149  SolarMutexGuard aGuard;
150 
151  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
152 
153  const long nCount = getCount();
154  long i;
155  for( i = 0; i < nCount; i++ )
156  {
157  const XPropertyEntry* pEntry = get(i);
158  if (pEntry && aInternalName == pEntry->GetName())
159  {
160  std::unique_ptr<XPropertyEntry> pNewEntry(createEntry(aInternalName, aElement));
161  if (!pNewEntry)
162  throw lang::IllegalArgumentException();
163 
164  mpList->Replace(std::move(pNewEntry), i);
165  return;
166  }
167  }
168 
169  throw container::NoSuchElementException();
170 }
171 
172 // XNameAccess
173 uno::Any SAL_CALL SvxUnoXPropertyTable::getByName( const OUString& aName )
174 {
175  SolarMutexGuard aGuard;
176 
177  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
178 
179  const long nCount = getCount();
180  long i;
181  for( i = 0; i < nCount; i++ )
182  {
183  const XPropertyEntry* pEntry = get(i);
184 
185  if (pEntry && aInternalName == pEntry->GetName())
186  return getAny( pEntry );
187  }
188 
189  throw container::NoSuchElementException();
190 }
191 
192 uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames()
193 {
194  SolarMutexGuard aGuard;
195 
196  const long nCount = getCount();
197  uno::Sequence< OUString > aNames( nCount );
198  OUString* pNames = aNames.getArray();
199  long i;
200  for( i = 0; i < nCount; i++ )
201  {
202  const XPropertyEntry* pEntry = get(i);
203 
204  if (pEntry)
205  *pNames++ = SvxUnogetApiNameForItem(mnWhich, pEntry->GetName());
206  }
207 
208  return aNames;
209 }
210 
211 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName )
212 {
213  SolarMutexGuard aGuard;
214 
215  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
216 
217  const long nCount = mpList?mpList->Count():0;
218  long i;
219  for( i = 0; i < nCount; i++ )
220  {
221  const XPropertyEntry* pEntry = get(i);
222  if (pEntry && aInternalName == pEntry->GetName())
223  return true;
224  }
225 
226  return false;
227 }
228 
229 // XElementAccess
230 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasElements( )
231 {
232  SolarMutexGuard aGuard;
233 
234  return getCount() != 0;
235 }
236 
237 namespace {
238 
239 class SvxUnoXColorTable : public SvxUnoXPropertyTable
240 {
241 public:
242  explicit SvxUnoXColorTable( XPropertyList* pList ) throw() : SvxUnoXPropertyTable( XATTR_LINECOLOR, pList ) {};
243 
244  // SvxUnoXPropertyTable
245  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
246  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
247 
248  // XElementAccess
249  virtual uno::Type SAL_CALL getElementType() override;
250 
251  // XServiceInfo
252  virtual OUString SAL_CALL getImplementationName( ) override;
253  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
254 };
255 
256 }
257 
258 uno::Reference< uno::XInterface > SvxUnoXColorTable_createInstance( XPropertyList* pList ) throw()
259 {
260  return static_cast<OWeakObject*>(new SvxUnoXColorTable( pList ));
261 }
262 
263 // SvxUnoXPropertyTable
264 uno::Any SvxUnoXColorTable::getAny( const XPropertyEntry* pEntry ) const throw()
265 {
266  return uno::Any( static_cast<sal_Int32>(static_cast<const XColorEntry*>(pEntry)->GetColor()) );
267 }
268 
269 std::unique_ptr<XPropertyEntry> SvxUnoXColorTable::createEntry(const OUString& rName, const uno::Any& rAny) const
270 {
271  Color aColor;
272  if( !(rAny >>= aColor) )
273  return std::unique_ptr<XPropertyEntry>();
274 
275  return std::make_unique<XColorEntry>(aColor, rName);
276 }
277 
278 // XElementAccess
279 uno::Type SAL_CALL SvxUnoXColorTable::getElementType()
280 {
281  return ::cppu::UnoType<sal_Int32>::get();
282 }
283 
284 // XServiceInfo
285 OUString SAL_CALL SvxUnoXColorTable::getImplementationName( )
286 {
287  return "SvxUnoXColorTable";
288 }
289 
290 uno::Sequence< OUString > SAL_CALL SvxUnoXColorTable::getSupportedServiceNames( )
291 {
292  return { "com.sun.star.drawing.ColorTable" };
293 }
294 
295 namespace {
296 
297 class SvxUnoXLineEndTable : public SvxUnoXPropertyTable
298 {
299 public:
300  explicit SvxUnoXLineEndTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEEND, pTable ) {};
301 
302  // SvxUnoXPropertyTable
303  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
304  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
305 
306  // XElementAccess
307  virtual uno::Type SAL_CALL getElementType() override;
308 
309  // XServiceInfo
310  virtual OUString SAL_CALL getImplementationName( ) override;
311  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
312 };
313 
314 }
315 
316 uno::Reference< uno::XInterface > SvxUnoXLineEndTable_createInstance( XPropertyList* pTable ) throw()
317 {
318  return static_cast<OWeakObject*>(new SvxUnoXLineEndTable( pTable ));
319 }
320 
321 // SvxUnoXPropertyTable
322 uno::Any SvxUnoXLineEndTable::getAny( const XPropertyEntry* pEntry ) const throw()
323 {
324  drawing::PolyPolygonBezierCoords aBezier;
325  basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd(),
326  aBezier );
327  return uno::Any(aBezier);
328 }
329 
330 std::unique_ptr<XPropertyEntry> SvxUnoXLineEndTable::createEntry(const OUString& rName, const uno::Any& rAny) const
331 {
332  auto pCoords = o3tl::tryAccess<drawing::PolyPolygonBezierCoords>(rAny);
333  if( !pCoords )
334  return std::unique_ptr<XLineEndEntry>();
335 
336  basegfx::B2DPolyPolygon aPolyPolygon;
337  if( pCoords->Coordinates.getLength() > 0 )
339 
340  // #86265# make sure polygon is closed
341  aPolyPolygon.setClosed(true);
342 
343  return std::make_unique<XLineEndEntry>(aPolyPolygon, rName);
344 }
345 
346 // XElementAccess
347 uno::Type SAL_CALL SvxUnoXLineEndTable::getElementType()
348 {
350 }
351 
352 // XServiceInfo
353 OUString SAL_CALL SvxUnoXLineEndTable::getImplementationName( )
354 {
355  return "SvxUnoXLineEndTable";
356 }
357 
358 uno::Sequence< OUString > SAL_CALL SvxUnoXLineEndTable::getSupportedServiceNames( )
359 {
360  return { "com.sun.star.drawing.LineEndTable" };
361 }
362 
363 namespace {
364 
365 class SvxUnoXDashTable : public SvxUnoXPropertyTable
366 {
367 public:
368  explicit SvxUnoXDashTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEDASH, pTable ) {};
369 
370  // SvxUnoXPropertyTable
371  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
372  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
373 
374  // XElementAccess
375  virtual uno::Type SAL_CALL getElementType() override;
376 
377  // XServiceInfo
378  virtual OUString SAL_CALL getImplementationName( ) override;
379  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
380 };
381 
382 }
383 
384 uno::Reference< uno::XInterface > SvxUnoXDashTable_createInstance( XPropertyList* pTable ) throw()
385 {
386  return static_cast<OWeakObject*>(new SvxUnoXDashTable( pTable ));
387 }
388 
389 // SvxUnoXPropertyTable
390 uno::Any SvxUnoXDashTable::getAny( const XPropertyEntry* pEntry ) const throw()
391 {
392  const XDash& rXD = static_cast<const XDashEntry*>(pEntry)->GetDash();
393 
394  drawing::LineDash aLineDash;
395 
396  aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
397  aLineDash.Dots = rXD.GetDots();
398  aLineDash.DotLen = rXD.GetDotLen();
399  aLineDash.Dashes = rXD.GetDashes();
400  aLineDash.DashLen = rXD.GetDashLen();
401  aLineDash.Distance = rXD.GetDistance();
402 
403  return uno::Any(aLineDash);
404 }
405 
406 std::unique_ptr<XPropertyEntry> SvxUnoXDashTable::createEntry(const OUString& rName, const uno::Any& rAny) const
407 {
408  drawing::LineDash aLineDash;
409  if(!(rAny >>= aLineDash))
410  return std::unique_ptr<XDashEntry>();
411 
412  XDash aXDash;
413 
414  aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
415  aXDash.SetDots(aLineDash.Dots);
416  aXDash.SetDotLen(aLineDash.DotLen);
417  aXDash.SetDashes(aLineDash.Dashes);
418  aXDash.SetDashLen(aLineDash.DashLen);
419  aXDash.SetDistance(aLineDash.Distance);
420 
421  return std::make_unique<XDashEntry>(aXDash, rName);
422 }
423 
424 // XElementAccess
425 uno::Type SAL_CALL SvxUnoXDashTable::getElementType()
426 {
428 }
429 
430 // XServiceInfo
431 OUString SAL_CALL SvxUnoXDashTable::getImplementationName( )
432 {
433  return "SvxUnoXDashTable";
434 }
435 
436 uno::Sequence< OUString > SAL_CALL SvxUnoXDashTable::getSupportedServiceNames( )
437 {
438  return { "com.sun.star.drawing.DashTable" };
439 }
440 
441 namespace {
442 
443 class SvxUnoXHatchTable : public SvxUnoXPropertyTable
444 {
445 public:
446  explicit SvxUnoXHatchTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLHATCH, pTable ) {};
447 
448  // SvxUnoXPropertyTable
449  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
450  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
451 
452  // XElementAccess
453  virtual uno::Type SAL_CALL getElementType() override;
454 
455  // XServiceInfo
456  virtual OUString SAL_CALL getImplementationName( ) override;
457  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
458 };
459 
460 }
461 
462 uno::Reference< uno::XInterface > SvxUnoXHatchTable_createInstance( XPropertyList* pTable ) throw()
463 {
464  return static_cast<OWeakObject*>(new SvxUnoXHatchTable( pTable ));
465 }
466 
467 // SvxUnoXPropertyTable
468 uno::Any SvxUnoXHatchTable::getAny( const XPropertyEntry* pEntry ) const throw()
469 {
470  const XHatch& aHatch = static_cast<const XHatchEntry*>(pEntry)->GetHatch();
471 
472  drawing::Hatch aUnoHatch;
473 
474  aUnoHatch.Style = aHatch.GetHatchStyle();
475  aUnoHatch.Color = sal_Int32(aHatch.GetColor());
476  aUnoHatch.Distance = aHatch.GetDistance();
477  aUnoHatch.Angle = aHatch.GetAngle();
478 
479  return uno::Any(aUnoHatch);
480 }
481 
482 std::unique_ptr<XPropertyEntry> SvxUnoXHatchTable::createEntry(const OUString& rName, const uno::Any& rAny) const
483 {
484  drawing::Hatch aUnoHatch;
485  if(!(rAny >>= aUnoHatch))
486  return std::unique_ptr<XHatchEntry>();
487 
488  XHatch aXHatch;
489  aXHatch.SetHatchStyle( aUnoHatch.Style );
490  aXHatch.SetColor( Color(aUnoHatch.Color) );
491  aXHatch.SetDistance( aUnoHatch.Distance );
492  aXHatch.SetAngle( aUnoHatch.Angle );
493 
494  return std::make_unique<XHatchEntry>(aXHatch, rName);
495 }
496 
497 // XElementAccess
498 uno::Type SAL_CALL SvxUnoXHatchTable::getElementType()
499 {
501 }
502 
503 // XServiceInfo
504 OUString SAL_CALL SvxUnoXHatchTable::getImplementationName( )
505 {
506  return "SvxUnoXHatchTable";
507 }
508 
509 uno::Sequence< OUString > SAL_CALL SvxUnoXHatchTable::getSupportedServiceNames( )
510 {
511  return { "com.sun.star.drawing.HatchTable" };
512 }
513 
514 namespace {
515 
516 class SvxUnoXGradientTable : public SvxUnoXPropertyTable
517 {
518 public:
519  explicit SvxUnoXGradientTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, pTable ) {};
520 
521  // SvxUnoXPropertyTable
522  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
523  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
524 
525  // XElementAccess
526  virtual uno::Type SAL_CALL getElementType() override;
527 
528  // XServiceInfo
529  virtual OUString SAL_CALL getImplementationName( ) override;
530  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
531 };
532 
533 }
534 
535 uno::Reference< uno::XInterface > SvxUnoXGradientTable_createInstance( XPropertyList* pTable ) throw()
536 {
537  return static_cast<OWeakObject*>(new SvxUnoXGradientTable( pTable ));
538 }
539 
540 // SvxUnoXPropertyTable
541 uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const throw()
542 {
543  const XGradient& aXGradient = static_cast<const XGradientEntry*>(pEntry)->GetGradient();
544  awt::Gradient aGradient;
545 
546  aGradient.Style = aXGradient.GetGradientStyle();
547  aGradient.StartColor = static_cast<sal_Int32>(aXGradient.GetStartColor());
548  aGradient.EndColor = static_cast<sal_Int32>(aXGradient.GetEndColor());
549  aGradient.Angle = static_cast<short>(aXGradient.GetAngle());
550  aGradient.Border = aXGradient.GetBorder();
551  aGradient.XOffset = aXGradient.GetXOffset();
552  aGradient.YOffset = aXGradient.GetYOffset();
553  aGradient.StartIntensity = aXGradient.GetStartIntens();
554  aGradient.EndIntensity = aXGradient.GetEndIntens();
555  aGradient.StepCount = aXGradient.GetSteps();
556 
557  return uno::Any(aGradient);
558 }
559 
560 std::unique_ptr<XPropertyEntry> SvxUnoXGradientTable::createEntry(const OUString& rName, const uno::Any& rAny) const
561 {
562  awt::Gradient aGradient;
563  if(!(rAny >>= aGradient))
564  return std::unique_ptr<XPropertyEntry>();
565 
566  XGradient aXGradient;
567 
568  aXGradient.SetGradientStyle( aGradient.Style );
569  aXGradient.SetStartColor( Color(aGradient.StartColor) );
570  aXGradient.SetEndColor( Color(aGradient.EndColor) );
571  aXGradient.SetAngle( aGradient.Angle );
572  aXGradient.SetBorder( aGradient.Border );
573  aXGradient.SetXOffset( aGradient.XOffset );
574  aXGradient.SetYOffset( aGradient.YOffset );
575  aXGradient.SetStartIntens( aGradient.StartIntensity );
576  aXGradient.SetEndIntens( aGradient.EndIntensity );
577  aXGradient.SetSteps( aGradient.StepCount );
578 
579  return std::make_unique<XGradientEntry>(aXGradient, rName);
580 }
581 
582 // XElementAccess
583 uno::Type SAL_CALL SvxUnoXGradientTable::getElementType()
584 {
586 }
587 
588 // XServiceInfo
589 OUString SAL_CALL SvxUnoXGradientTable::getImplementationName( )
590 {
591  return "SvxUnoXGradientTable";
592 }
593 
594 uno::Sequence< OUString > SAL_CALL SvxUnoXGradientTable::getSupportedServiceNames( )
595 {
596  return { "com.sun.star.drawing.GradientTable" };
597 }
598 
599 namespace {
600 
601 class SvxUnoXBitmapTable : public SvxUnoXPropertyTable
602 {
603 public:
604  explicit SvxUnoXBitmapTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLBITMAP, pTable ) {};
605 
606  // SvxUnoXPropertyTable
607  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const override;
608  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
609 
610  // XElementAccess
611  virtual uno::Type SAL_CALL getElementType() override;
612 
613  // XServiceInfo
614  virtual OUString SAL_CALL getImplementationName( ) override;
615  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
616 };
617 
618 }
619 
620 uno::Reference< uno::XInterface > SvxUnoXBitmapTable_createInstance( XPropertyList* pTable ) throw()
621 {
622  return static_cast<OWeakObject*>(new SvxUnoXBitmapTable( pTable ));
623 }
624 
625 // SvxUnoXPropertyTable
626 uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const
627 {
628  auto xBitmapEntry = static_cast<const XBitmapEntry*>(pEntry);
629  css::uno::Reference<css::awt::XBitmap> xBitmap(xBitmapEntry->GetGraphicObject().GetGraphic().GetXGraphic(), uno::UNO_QUERY);
630  return uno::Any(xBitmap);
631 }
632 
633 std::unique_ptr<XPropertyEntry> SvxUnoXBitmapTable::createEntry(const OUString& rName, const uno::Any& rAny) const
634 {
635  if (!rAny.has<uno::Reference<awt::XBitmap>>())
636  return std::unique_ptr<XPropertyEntry>();
637 
638  auto xBitmap = rAny.get<uno::Reference<awt::XBitmap>>();
639  if (!xBitmap.is())
640  return nullptr;
641 
642  uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
643  if (!xGraphic.is())
644  return nullptr;
645 
646  Graphic aGraphic(xGraphic);
647  if (aGraphic.IsNone())
648  return nullptr;
649 
650  GraphicObject aGraphicObject(aGraphic);
651  return std::make_unique<XBitmapEntry>(aGraphicObject, rName);
652 }
653 
654 // XElementAccess
655 uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType()
656 {
657  return ::cppu::UnoType<awt::XBitmap>::get();
658 }
659 
660 // XServiceInfo
661 OUString SAL_CALL SvxUnoXBitmapTable::getImplementationName( )
662 {
663  return "SvxUnoXBitmapTable";
664 }
665 
666 uno::Sequence< OUString > SAL_CALL SvxUnoXBitmapTable::getSupportedServiceNames( )
667 {
668  return { "com.sun.star.drawing.BitmapTable" };
669 }
670 
671 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyEntry * Get(long nIndex) const
Definition: xtable.cxx:134
#define XATTR_FILLHATCH
Definition: xdef.hxx:110
void SetHatchStyle(css::drawing::HatchStyle eNewStyle)
Definition: xhatch.hxx:44
void setClosed(bool bNew)
sal_uInt32 GetDistance() const
Definition: xdash.hxx:59
#define XATTR_FILLGRADIENT
Definition: xdef.hxx:109
OUString getImplementationName()
OUString SvxUnogetApiNameForItem(const sal_uInt16 nWhich, const OUString &rInternalName)
if the given name is a predefined name for the current language it is replaced by the corresponding a...
Definition: unoprov.cxx:1856
sal_uInt16 GetStartIntens() const
Definition: xgrad.hxx:73
void Insert(std::unique_ptr< XPropertyEntry > pEntry, long nIndex=std::numeric_limits< long >::max())
Definition: xtable.cxx:180
uno::Reference< uno::XInterface > SvxUnoXLineEndTable_createInstance(XPropertyList *pTable)
const Color & GetStartColor() const
Definition: xgrad.hxx:67
void Replace(std::unique_ptr< XPropertyEntry > pEntry, long nIndex)
Definition: xtable.cxx:195
sal_uInt16 GetYOffset() const
Definition: xgrad.hxx:72
Definition: xdash.hxx:31
uno::Reference< uno::XInterface > SvxUnoXBitmapTable_createInstance(XPropertyList *pTable)
OUString SvxUnogetInternalNameForItem(const sal_uInt16 nWhich, const OUString &rApiName)
if the given name is a predefined api name it is replaced by the predefined name for the current lang...
Definition: unoprov.cxx:1889
int nCount
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_uInt16 GetDots() const
Definition: xdash.hxx:55
css::drawing::DashStyle GetDashStyle() const
Definition: xdash.hxx:54
sal_uInt16 GetXOffset() const
Definition: xgrad.hxx:71
const OUString & GetName() const
uno::Reference< uno::XInterface > SvxUnoXDashTable_createInstance(XPropertyList *pTable)
long GetDistance() const
Definition: xhatch.hxx:51
sal_uInt16 GetBorder() const
Definition: xgrad.hxx:70
css::uno::Sequence< OUString > getSupportedServiceNames()
css::drawing::HatchStyle GetHatchStyle() const
Definition: xhatch.hxx:49
long GetAngle() const
Definition: xhatch.hxx:52
B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon(const css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsSource)
void SetGradientStyle(css::awt::GradientStyle eNewStyle)
Definition: xgrad.hxx:55
int i
long GetAngle() const
Definition: xgrad.hxx:69
sal_uInt16 GetSteps() const
Definition: xgrad.hxx:75
void Remove(long nIndex)
Definition: xtable.cxx:211
unsigned char sal_Bool
void SetDashStyle(css::drawing::DashStyle eNewStyle)
Definition: xdash.hxx:47
css::uno::Type const & get()
tuple index
#define XATTR_LINEDASH
Definition: xdef.hxx:91
const Color & GetColor() const
Definition: xhatch.hxx:50
css::awt::GradientStyle GetGradientStyle() const
Definition: xgrad.hxx:66
sal_uInt32 GetDotLen() const
Definition: xdash.hxx:56
#define XATTR_LINEEND
Definition: xdef.hxx:95
uno::Reference< uno::XInterface > SvxUnoXGradientTable_createInstance(XPropertyList *pTable)
long Count() const
Definition: xtable.cxx:124
EdgeEntry * mpList
#define XATTR_FILLBITMAP
Definition: xdef.hxx:111
uno::Reference< uno::XInterface > SvxUnoXHatchTable_createInstance(XPropertyList *pTable)
void B2DPolyPolygonToUnoPolyPolygonBezierCoords(const B2DPolyPolygon &rPolyPolygon, css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsRetval)
#define XATTR_LINECOLOR
Definition: xdef.hxx:93
sal_uInt32 GetDashLen() const
Definition: xdash.hxx:58
sal_uInt16 GetEndIntens() const
Definition: xgrad.hxx:74
Reference< XGraphic > xGraphic
uno::Reference< uno::XInterface > SvxUnoXColorTable_createInstance(XPropertyList *pList)
const Color & GetEndColor() const
Definition: xgrad.hxx:68
sal_uInt16 GetDashes() const
Definition: xdash.hxx:57