LibreOffice Module svx (master)  1
svdetc.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 #include <sal/config.h>
21 
22 #include <officecfg/Office/Common.hxx>
23 #include <svtools/colorcfg.hxx>
24 #include <svx/svdetc.hxx>
25 #include <svx/svdedxv.hxx>
26 #include <svx/svdmodel.hxx>
27 #include <svx/svdoutl.hxx>
28 #include <vcl/bitmapaccess.hxx>
29 #include <editeng/eeitem.hxx>
30 #include <svl/itemset.hxx>
31 #include <svl/whiter.hxx>
32 #include <svx/xgrad.hxx>
33 #include <svx/xfillit0.hxx>
34 #include <svx/xflclit.hxx>
35 #include <svx/xflhtit.hxx>
36 #include <svx/xbtmpit.hxx>
37 #include <svx/xflgrit.hxx>
38 #include <svx/svdoole2.hxx>
39 #include <svl/itempool.hxx>
40 #include <tools/debug.hxx>
41 #include <unotools/configmgr.hxx>
43 #include <unotools/syslocale.hxx>
44 #include <svx/xflbckit.hxx>
45 #include <svx/extrusionbar.hxx>
46 #include <svx/fontworkbar.hxx>
47 #include <vcl/svapp.hxx>
48 #include <vcl/settings.hxx>
50 #include <svx/svdpage.hxx>
51 #include <svx/svdpagv.hxx>
52 #include <svx/svdotable.hxx>
53 #include <svx/sdrhittesthelper.hxx>
54 
55 #include <com/sun/star/frame/XModel.hpp>
56 #include <com/sun/star/embed/XEmbeddedObject.hpp>
57 
58 using namespace ::com::sun::star;
59 
60 // Global data of the DrawingEngine
62  : pSysLocale(nullptr)
63  , pLocaleData(nullptr)
64 {
66  {
67  svx::ExtrusionBar::RegisterInterface();
68  svx::FontworkBar::RegisterInterface();
69  }
70 }
71 
73 {
74  if ( !pSysLocale )
76  return pSysLocale;
77 }
79 {
80  if ( !pLocaleData )
82  return pLocaleData;
83 }
84 
85 namespace {
86 
87 struct TheSdrGlobalData: public rtl::Static<SdrGlobalData, TheSdrGlobalData> {};
88 
89 }
90 
92  return TheSdrGlobalData::get();
93 }
94 
96 {
98  nSize = officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::get();
99  else
100  nSize = 100;
101  pTimer.reset( new AutoTimer( "svx OLEObjCache pTimer UnloadCheck" ) );
102  pTimer->SetInvokeHandler( LINK(this, OLEObjCache, UnloadCheckHdl) );
103  pTimer->SetTimeout(20000);
104  pTimer->SetStatic();
105 }
106 
108 {
109  pTimer->Stop();
110 }
111 
112 IMPL_LINK_NOARG(OLEObjCache, UnloadCheckHdl, Timer*, void)
113 {
114  if (nSize >= maObjs.size())
115  return;
116 
117  // more objects than configured cache size try to remove objects
118  // of course not the freshly inserted one at nIndex=0
119  size_t nCount2 = maObjs.size();
120  size_t nIndex = nCount2-1;
121  while( nIndex && nCount2 > nSize )
122  {
123  SdrOle2Obj* pUnloadObj = maObjs[nIndex--];
124  if (!pUnloadObj)
125  continue;
126 
127  try
128  {
129  // it is important to get object without reinitialization to avoid reentrance
130  uno::Reference< embed::XEmbeddedObject > xUnloadObj = pUnloadObj->GetObjRef_NoInit();
131 
132  bool bUnload = SdrOle2Obj::CanUnloadRunningObj( xUnloadObj, pUnloadObj->GetAspect() );
133 
134  // check whether the object can be unloaded before looking for the parent objects
135  if ( xUnloadObj.is() && bUnload )
136  {
137  uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY );
138  if ( xUnloadModel.is() )
139  {
140  for (SdrOle2Obj* pCacheObj : maObjs)
141  {
142  if ( pCacheObj && pCacheObj != pUnloadObj )
143  {
144  uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel();
145  if ( xUnloadModel == xParentModel )
146  bUnload = false; // the object has running embedded objects
147  }
148  }
149  }
150  }
151 
152  if ( bUnload && UnloadObj(pUnloadObj) )
153  // object was successfully unloaded
154  nCount2--;
155  }
156  catch( uno::Exception& )
157  {}
158  }
159 }
160 
162 {
163  if (!maObjs.empty())
164  {
165  SdrOle2Obj* pExistingObj = maObjs.front();
166  if ( pObj == pExistingObj )
167  // the object is already on the top, nothing has to be changed
168  return;
169  }
170 
171  // get the old position of the object to know whether it is already in container
172  std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj);
173  bool bFound = it != maObjs.end();
174 
175  if (bFound)
176  maObjs.erase(it);
177  // insert object into first position
178  maObjs.insert(maObjs.begin(), pObj);
179 
180  // if a new object was inserted, recalculate the cache
181  if (!bFound)
182  pTimer->Invoke();
183 
184  if (!bFound || !pTimer->IsActive())
185  pTimer->Start();
186 }
187 
189 {
190  std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj);
191  if (it != maObjs.end())
192  maObjs.erase(it);
193  if (maObjs.empty())
194  pTimer->Stop();
195 }
196 
197 size_t OLEObjCache::size() const
198 {
199  return maObjs.size();
200 }
201 
203 {
204  return maObjs[nPos];
205 }
206 
207 const SdrOle2Obj* OLEObjCache::operator[](size_t nPos) const
208 {
209  return maObjs[nPos];
210 }
211 
213 {
214  bool bUnloaded = false;
215  if (pObj)
216  {
217  //#i80528# The old mechanism is completely useless, only taking into account if
218  // in all views the GrafDraft feature is used. This will nearly never have been the
219  // case since no one ever used this option.
220 
221  // A much better (and working) criteria would be the VOC contact count.
222  // The question is what will happen when i make it work now suddenly? I
223  // will try it for 2.4.
224  const sdr::contact::ViewContact& rViewContact = pObj->GetViewContact();
225  const bool bVisible(rViewContact.HasViewObjectContacts());
226 
227  if(!bVisible)
228  {
229  bUnloaded = pObj->Unload();
230  }
231  }
232 
233  return bUnloaded;
234 }
235 
236 bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol)
237 {
238  drawing::FillStyle eFill=rSet.Get(XATTR_FILLSTYLE).GetValue();
239  bool bRetval = false;
240 
241  switch(eFill)
242  {
243  case drawing::FillStyle_SOLID:
244  {
245  rCol = rSet.Get(XATTR_FILLCOLOR).GetColorValue();
246  bRetval = true;
247 
248  break;
249  }
250  case drawing::FillStyle_HATCH:
251  {
252  Color aCol1(rSet.Get(XATTR_FILLHATCH).GetHatchValue().GetColor());
253  Color aCol2(COL_WHITE);
254 
255  // when hatched background is activated, use object fill color as hatch color
256  bool bFillHatchBackground = rSet.Get(XATTR_FILLBACKGROUND).GetValue();
257  if(bFillHatchBackground)
258  {
259  aCol2 = rSet.Get(XATTR_FILLCOLOR).GetColorValue();
260  }
261 
262  const basegfx::BColor aAverageColor(basegfx::average(aCol1.getBColor(), aCol2.getBColor()));
263  rCol = Color(aAverageColor);
264  bRetval = true;
265 
266  break;
267  }
268  case drawing::FillStyle_GRADIENT: {
269  const XGradient& rGrad=rSet.Get(XATTR_FILLGRADIENT).GetGradientValue();
270  Color aCol1(rGrad.GetStartColor());
271  Color aCol2(rGrad.GetEndColor());
272  const basegfx::BColor aAverageColor(basegfx::average(aCol1.getBColor(), aCol2.getBColor()));
273  rCol = Color(aAverageColor);
274  bRetval = true;
275 
276  break;
277  }
278  case drawing::FillStyle_BITMAP:
279  {
280  Bitmap aBitmap(rSet.Get(XATTR_FILLBITMAP).GetGraphicObject().GetGraphic().GetBitmapEx().GetBitmap());
281  const Size aSize(aBitmap.GetSizePixel());
282  const sal_uInt32 nWidth = aSize.Width();
283  const sal_uInt32 nHeight = aSize.Height();
284  if (nWidth <= 0 || nHeight <= 0)
285  return bRetval;
286 
287  Bitmap::ScopedReadAccess pAccess(aBitmap);
288 
289  if (pAccess)
290  {
291  sal_uInt32 nRt(0);
292  sal_uInt32 nGn(0);
293  sal_uInt32 nBl(0);
294  const sal_uInt32 nMaxSteps(8);
295  const sal_uInt32 nXStep((nWidth > nMaxSteps) ? nWidth / nMaxSteps : 1);
296  const sal_uInt32 nYStep((nHeight > nMaxSteps) ? nHeight / nMaxSteps : 1);
297  sal_uInt32 nCount(0);
298 
299  for(sal_uInt32 nY(0); nY < nHeight; nY += nYStep)
300  {
301  for(sal_uInt32 nX(0); nX < nWidth; nX += nXStep)
302  {
303  const BitmapColor& rCol2 = pAccess->GetColor(nY, nX);
304 
305  nRt += rCol2.GetRed();
306  nGn += rCol2.GetGreen();
307  nBl += rCol2.GetBlue();
308  nCount++;
309  }
310  }
311 
312  nRt /= nCount;
313  nGn /= nCount;
314  nBl /= nCount;
315 
316  rCol = Color(sal_uInt8(nRt), sal_uInt8(nGn), sal_uInt8(nBl));
317 
318  bRetval = true;
319  }
320  break;
321  }
322  default: break;
323  }
324 
325  return bRetval;
326 }
327 
328 std::unique_ptr<SdrOutliner> SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel& rModel)
329 {
330  SfxItemPool* pPool = &rModel.GetItemPool();
331  std::unique_ptr<SdrOutliner> pOutl(new SdrOutliner( pPool, nOutlinerMode ));
332  pOutl->SetEditTextObjectPool( pPool );
333  pOutl->SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(rModel.GetStyleSheetPool()));
334  pOutl->SetDefTab(rModel.GetDefaultTabulator());
336  pOutl->SetAsianCompressionMode(rModel.GetCharCompressType());
337  pOutl->SetKernAsianPunctuation(rModel.IsKernAsianPunctuation());
338  pOutl->SetAddExtLeading(rModel.IsAddExtLeading());
339  return pOutl;
340 }
341 
342 std::vector<Link<SdrObjCreatorParams, SdrObject*>>& ImpGetUserMakeObjHdl()
343 {
344  SdrGlobalData& rGlobalData=GetSdrGlobalData();
345  return rGlobalData.aUserMakeObjHdl;
346 }
347 
348 bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnlyEE)
349 {
350  bool bHas=false;
351  bool bOnly=true;
352  bool bLookOnly=pbOnlyEE!=nullptr;
353  SfxWhichIter aIter(rSet);
354  sal_uInt16 nWhich=aIter.FirstWhich();
355  while (((bLookOnly && bOnly) || !bHas) && nWhich!=0) {
356  // For bInklDefaults, the entire Which range is decisive,
357  // in other cases only the set items are.
358  // Disabled and DontCare are regarded as holes in the Which range.
359  SfxItemState eState=rSet.GetItemState(nWhich);
360  if ((eState==SfxItemState::DEFAULT && bInklDefaults) || eState==SfxItemState::SET) {
361  if (nWhich<EE_ITEMS_START || nWhich>EE_ITEMS_END) bOnly=false;
362  else bHas=true;
363  }
364  nWhich=aIter.NextWhich();
365  }
366  if (!bHas) bOnly=false;
367  if (pbOnlyEE!=nullptr) *pbOnlyEE=bOnly;
368  return bHas;
369 }
370 
371 std::unique_ptr<sal_uInt16[]> RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd)
372 {
373  // Six possible cases (per range):
374  // [Beg..End] Range, to delete
375  // [b..e] [b..e] [b..e] Cases 1,3,2: doesn't matter, delete, doesn't matter + Ranges
376  // [b........e] [b........e] Cases 4,5 : shrink range | in
377  // [b......................e] Case 6 : splitting + pOldWhichTable
378  sal_uInt16 nCount=0;
379  while (pOldWhichTable[nCount]!=0) nCount++;
380  nCount++; // nCount should now be an odd number (0 for end of array)
381  DBG_ASSERT((nCount&1)==1,"RemoveWhichRange: WhichTable doesn't have an odd number of entries.");
382  sal_uInt16 nAlloc=nCount;
383  // check necessary size of new array
384  sal_uInt16 nNum=nCount-1;
385  while (nNum!=0) {
386  nNum-=2;
387  sal_uInt16 nBeg=pOldWhichTable[nNum];
388  sal_uInt16 nEnd=pOldWhichTable[nNum+1];
389  if (nEnd<nRangeBeg) /*nCase=1*/ ;
390  else if (nBeg>nRangeEnd) /* nCase=2 */ ;
391  else if (nBeg>=nRangeBeg && nEnd<=nRangeEnd) /* nCase=3 */ nAlloc-=2;
392  else if (nEnd<=nRangeEnd) /* nCase=4 */;
393  else if (nBeg>=nRangeBeg) /* nCase=5*/ ;
394  else /* nCase=6 */ nAlloc+=2;
395  }
396 
397  std::unique_ptr<sal_uInt16[]> pNewWhichTable(new sal_uInt16[nAlloc]);
398  memcpy(pNewWhichTable.get(), pOldWhichTable, nAlloc*sizeof(sal_uInt16));
399  pNewWhichTable[nAlloc-1]=0; // in case 3, there's no 0 at the end.
400  // now remove the unwanted ranges
401  nNum=nAlloc-1;
402  while (nNum!=0) {
403  nNum-=2;
404  sal_uInt16 nBeg=pNewWhichTable[nNum];
405  sal_uInt16 nEnd=pNewWhichTable[nNum+1];
406  unsigned nCase=0;
407  if (nEnd<nRangeBeg) nCase=1;
408  else if (nBeg>nRangeEnd) nCase=2;
409  else if (nBeg>=nRangeBeg && nEnd<=nRangeEnd) nCase=3;
410  else if (nEnd<=nRangeEnd) nCase=4;
411  else if (nBeg>=nRangeBeg) nCase=5;
412  else nCase=6;
413  switch (nCase) {
414  case 3: {
415  unsigned nTailBytes=(nCount-(nNum+2))*sizeof(sal_uInt16);
416  memcpy(&pNewWhichTable[nNum],&pNewWhichTable[nNum+2],nTailBytes);
417  nCount-=2; // remember: array is now smaller
418  } break;
419  case 4: pNewWhichTable[nNum+1]=nRangeBeg-1; break;
420  case 5: pNewWhichTable[nNum]=nRangeEnd+1; break;
421  case 6: {
422  unsigned nTailBytes=(nCount-(nNum+2))*sizeof(sal_uInt16);
423  memcpy(&pNewWhichTable[nNum+4],&pNewWhichTable[nNum+2],nTailBytes);
424  nCount+=2; // remember:array is now larger
425  pNewWhichTable[nNum+2]=nRangeEnd+1;
426  pNewWhichTable[nNum+3]=pNewWhichTable[nNum+1];
427  pNewWhichTable[nNum+1]=nRangeBeg-1;
428  } break;
429  } // switch
430  }
431  return pNewWhichTable;
432 }
433 
434 
436 {
437  maLink = _rLink;
438  m_nSumCurAction = 0;
439 
440  m_nObjCount = 0;
441  m_nCurObj = 0;
442 
443  m_nActionCount = 0;
444  m_nCurAction = 0;
445 
446  m_nInsertCount = 0;
447  m_nCurInsert = 0;
448 }
449 
450 void SvdProgressInfo::Init( size_t nObjCount )
451 {
452  m_nObjCount = nObjCount;
453 }
454 
455 bool SvdProgressInfo::ReportActions( size_t nActionCount )
456 {
457  m_nSumCurAction += nActionCount;
458  m_nCurAction += nActionCount;
461 
462  return maLink.Call(nullptr);
463 }
464 
465 void SvdProgressInfo::ReportInserts( size_t nInsertCount )
466 {
467  m_nSumCurAction += nInsertCount;
468  m_nCurInsert += nInsertCount;
469 
470  maLink.Call(nullptr);
471 }
472 
473 void SvdProgressInfo::ReportRescales( size_t nRescaleCount )
474 {
475  m_nSumCurAction += nRescaleCount;
476  maLink.Call(nullptr);
477 }
478 
479 void SvdProgressInfo::SetActionCount( size_t nActionCount )
480 {
481  m_nActionCount = nActionCount;
482 }
483 
484 void SvdProgressInfo::SetInsertCount( size_t nInsertCount )
485 {
486  m_nInsertCount = nInsertCount;
487 }
488 
490 {
491  m_nActionCount = 0;
492  m_nCurAction = 0;
493 
494  m_nInsertCount = 0;
495  m_nCurInsert = 0;
496 
497  m_nCurObj++;
498  ReportActions(0);
499 }
500 
501 // #i101872# isolate GetTextEditBackgroundColor to tooling; it will anyways only be used as long
502 // as text edit is not running on overlay
503 
504 namespace
505 {
506  bool impGetSdrObjListFillColor(
507  const SdrObjList& rList,
508  const Point& rPnt,
509  const SdrPageView& rTextEditPV,
510  const SdrLayerIDSet& rVisLayers,
511  Color& rCol)
512  {
513  bool bRet(false);
514  bool bMaster(rList.getSdrPageFromSdrObjList() && rList.getSdrPageFromSdrObjList()->IsMasterPage());
515 
516  for(size_t no(rList.GetObjCount()); !bRet && no > 0; )
517  {
518  no--;
519  SdrObject* pObj = rList.GetObj(no);
520  SdrObjList* pOL = pObj->GetSubList();
521 
522  if(pOL)
523  {
524  // group object
525  bRet = impGetSdrObjListFillColor(*pOL, rPnt, rTextEditPV, rVisLayers, rCol);
526  }
527  else
528  {
529  SdrTextObj* pText = dynamic_cast< SdrTextObj * >(pObj);
530 
531  // Exclude zero master page object (i.e. background shape) from color query
532  if(pText
533  && pObj->IsClosedObj()
534  && (!bMaster || (!pObj->IsNotVisibleAsMaster() && 0 != no))
535  && pObj->GetCurrentBoundRect().IsInside(rPnt)
536  && !pText->IsHideContour()
537  && SdrObjectPrimitiveHit(*pObj, rPnt, 0, rTextEditPV, &rVisLayers, false))
538  {
539  bRet = GetDraftFillColor(pObj->GetMergedItemSet(), rCol);
540  }
541  }
542  }
543 
544  return bRet;
545  }
546 
547  bool impGetSdrPageFillColor(
548  const SdrPage& rPage,
549  const Point& rPnt,
550  const SdrPageView& rTextEditPV,
551  const SdrLayerIDSet& rVisLayers,
552  Color& rCol,
553  bool bSkipBackgroundShape)
554  {
555  bool bRet(impGetSdrObjListFillColor(rPage, rPnt, rTextEditPV, rVisLayers, rCol));
556 
557  if(!bRet && !rPage.IsMasterPage())
558  {
559  if(rPage.TRG_HasMasterPage())
560  {
561  SdrLayerIDSet aSet(rVisLayers);
562  aSet &= rPage.TRG_GetMasterPageVisibleLayers();
563  SdrPage& rMasterPage = rPage.TRG_GetMasterPage();
564 
565  // Don't fall back to background shape on
566  // master pages. This is later handled by
567  // GetBackgroundColor, and is necessary to cater for
568  // the silly ordering: 1. shapes, 2. master page
569  // shapes, 3. page background, 4. master page
570  // background.
571  bRet = impGetSdrPageFillColor(rMasterPage, rPnt, rTextEditPV, aSet, rCol, true);
572  }
573  }
574 
575  // Only now determine background color from background shapes
576  if(!bRet && !bSkipBackgroundShape)
577  {
578  rCol = rPage.GetPageBackgroundColor();
579  return true;
580  }
581 
582  return bRet;
583  }
584 
585  Color impCalcBackgroundColor(
586  const tools::Rectangle& rArea,
587  const SdrPageView& rTextEditPV,
588  const SdrPage& rPage)
589  {
590  svtools::ColorConfig aColorConfig;
591  Color aBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
592  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
593 
594  if(!rStyleSettings.GetHighContrastMode())
595  {
596  // search in page
597  const sal_uInt16 SPOTCOUNT(5);
598  Point aSpotPos[SPOTCOUNT];
599  Color aSpotColor[SPOTCOUNT];
600  sal_uInt32 nHeight( rArea.GetSize().Height() );
601  sal_uInt32 nWidth( rArea.GetSize().Width() );
602  sal_uInt32 nWidth14 = nWidth / 4;
603  sal_uInt32 nHeight14 = nHeight / 4;
604  sal_uInt32 nWidth34 = ( 3 * nWidth ) / 4;
605  sal_uInt32 nHeight34 = ( 3 * nHeight ) / 4;
606 
607  sal_uInt16 i;
608  for ( i = 0; i < SPOTCOUNT; i++ )
609  {
610  // five spots are used
611  switch ( i )
612  {
613  case 0 :
614  {
615  // Center-Spot
616  aSpotPos[i] = rArea.Center();
617  }
618  break;
619 
620  case 1 :
621  {
622  // TopLeft-Spot
623  aSpotPos[i] = rArea.TopLeft();
624  aSpotPos[i].AdjustX(nWidth14 );
625  aSpotPos[i].AdjustY(nHeight14 );
626  }
627  break;
628 
629  case 2 :
630  {
631  // TopRight-Spot
632  aSpotPos[i] = rArea.TopLeft();
633  aSpotPos[i].AdjustX(nWidth34 );
634  aSpotPos[i].AdjustY(nHeight14 );
635  }
636  break;
637 
638  case 3 :
639  {
640  // BottomLeft-Spot
641  aSpotPos[i] = rArea.TopLeft();
642  aSpotPos[i].AdjustX(nWidth14 );
643  aSpotPos[i].AdjustY(nHeight34 );
644  }
645  break;
646 
647  case 4 :
648  {
649  // BottomRight-Spot
650  aSpotPos[i] = rArea.TopLeft();
651  aSpotPos[i].AdjustX(nWidth34 );
652  aSpotPos[i].AdjustY(nHeight34 );
653  }
654  break;
655 
656  }
657 
658  aSpotColor[i] = COL_WHITE;
659  impGetSdrPageFillColor(rPage, aSpotPos[i], rTextEditPV, rTextEditPV.GetVisibleLayers(), aSpotColor[i], false);
660  }
661 
662  sal_uInt16 aMatch[SPOTCOUNT];
663 
664  for ( i = 0; i < SPOTCOUNT; i++ )
665  {
666  // were same spot colors found?
667  aMatch[i] = 0;
668 
669  for ( sal_uInt16 j = 0; j < SPOTCOUNT; j++ )
670  {
671  if( j != i )
672  {
673  if( aSpotColor[i] == aSpotColor[j] )
674  {
675  aMatch[i]++;
676  }
677  }
678  }
679  }
680 
681  // highest weight to center spot
682  aBackground = aSpotColor[0];
683 
684  for ( sal_uInt16 nMatchCount = SPOTCOUNT - 1; nMatchCount > 1; nMatchCount-- )
685  {
686  // which spot color was found most?
687  for ( i = 0; i < SPOTCOUNT; i++ )
688  {
689  if( aMatch[i] == nMatchCount )
690  {
691  aBackground = aSpotColor[i];
692  nMatchCount = 1; // break outer for-loop
693  break;
694  }
695  }
696  }
697  }
698 
699  return aBackground;
700  }
701 } // end of anonymous namespace
702 
704 {
705  svtools::ColorConfig aColorConfig;
706  Color aBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
707  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
708 
709  if(!rStyleSettings.GetHighContrastMode())
710  {
711  bool bFound(false);
712  SdrTextObj* pText = rView.GetTextEditObject();
713 
714  if(pText && pText->IsClosedObj())
715  {
716  sdr::table::SdrTableObj* pTable = dynamic_cast< sdr::table::SdrTableObj * >( pText );
717 
718  if( pTable )
719  bFound = GetDraftFillColor(pTable->GetActiveCellItemSet(), aBackground );
720 
721  if( !bFound )
722  bFound=GetDraftFillColor(pText->GetMergedItemSet(), aBackground);
723  }
724 
725  if(!bFound && pText)
726  {
727  SdrPageView* pTextEditPV = rView.GetTextEditPageView();
728 
729  if(pTextEditPV)
730  {
731  Point aPvOfs(pText->GetTextEditOffset());
732  const SdrPage* pPg = pTextEditPV->GetPage();
733 
734  if(pPg)
735  {
736  tools::Rectangle aSnapRect( pText->GetSnapRect() );
737  aSnapRect.Move(aPvOfs.X(), aPvOfs.Y());
738 
739  return impCalcBackgroundColor(aSnapRect, *pTextEditPV, *pPg);
740  }
741  }
742  }
743  }
744 
745  return aBackground;
746 }
747 
748 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Point TopLeft() const
SdrPage & TRG_GetMasterPage() const
Definition: svdpage.cxx:1573
long Width() const
void ReportRescales(size_t nRescaleCount)
Definition: svdetc.cxx:473
#define XATTR_FILLHATCH
Definition: xdef.hxx:110
sal_Int32 nIndex
bool SearchOutlinerItems(const SfxItemSet &rSet, bool bInklDefaults, bool *pbOnlyEE)
Search an ItemSet for Outliner/EditEngine Items.
Definition: svdetc.cxx:348
bool bVisible
OutlinerMode
bool IsNotVisibleAsMaster() const
Definition: svdobj.hxx:882
bool IsClosedObj() const
Definition: svdobj.hxx:787
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:853
const SvtSysLocale * GetSysLocale()
Definition: svdetc.cxx:72
CharCompressType GetCharCompressType() const
Definition: svdmodel.hxx:559
const LocaleDataWrapper * GetLocaleDataPtr() const
Color GetPageBackgroundColor() const
deprecated returns an averaged background color of this page
Definition: svdpage.cxx:1739
bool IsKernAsianPunctuation() const
Definition: svdmodel.hxx:562
long Height() const
SdrTextObj * GetTextEditObject() const
Definition: svdedxv.hxx:223
std::vector< Link< SdrObjCreatorParams, SdrObject * > > & ImpGetUserMakeObjHdl()
Definition: svdetc.cxx:342
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
void SetNextObject()
Definition: svdetc.cxx:489
#define XATTR_FILLGRADIENT
Definition: xdef.hxx:109
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:766
size_t GetObjCount() const
Definition: svdpage.cxx:760
std::unique_ptr< sal_uInt16[]> RemoveWhichRange(const sal_uInt16 *pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd)
Definition: svdetc.cxx:371
sal_uInt16 FirstWhich()
B2DTuple average(const B2DTuple &rOld1, const B2DTuple &rOld2)
virtual const tools::Rectangle & GetSnapRect() const override
Definition: svdoattr.cxx:48
SVXCORE_DLLPUBLIC ~OLEObjCache()
Definition: svdetc.cxx:107
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:646
#define XATTR_FILLCOLOR
Definition: xdef.hxx:108
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:244
sal_uInt16 NextWhich()
void Move(long nHorzMoveDelta, long nVertMoveDelta)
const Color & GetStartColor() const
Definition: xgrad.hxx:67
const SvtSysLocale * pSysLocale
Definition: svdetc.hxx:184
static bool IsFuzzing()
int nCount
void Init(size_t _nObjCount)
Definition: svdetc.cxx:450
const LocaleDataWrapper * GetLocaleData()
Definition: svdetc.cxx:78
void RemoveObj(SdrOle2Obj *pObj)
Definition: svdetc.cxx:188
SdrObject * SdrObjectPrimitiveHit(const SdrObject &rObject, const Point &rPnt, sal_uInt16 nTol, const SdrPageView &rSdrPageView, const SdrLayerIDSet *pVisiLayer, bool bTextOnly, drawinglayer::primitive2d::Primitive2DContainer *pHitContainer)
const LocaleDataWrapper * pLocaleData
Definition: svdetc.hxx:185
std::vector< SdrOle2Obj * > maObjs
Definition: svdetc.hxx:161
const Point & GetTextEditOffset() const
Definition: svdotext.hxx:216
static bool Unload(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
SVX_DLLPRIVATE css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef_NoInit() const
Definition: svdoole2.cxx:1817
static bool UnloadObj(SdrOle2Obj *pObj)
Definition: svdetc.cxx:212
size_t nSize
Definition: svdetc.hxx:163
void SetInsertCount(size_t _nInsertCount)
Definition: svdetc.cxx:484
void SetActionCount(size_t _nActionCount)
Definition: svdetc.cxx:479
bool HasViewObjectContacts() const
const SdrLayerIDSet & GetVisibleLayers() const
Definition: svdpagv.hxx:215
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
int i
bool IsAddExtLeading() const
Definition: svdmodel.hxx:565
size_t m_nSumCurAction
Definition: svdetc.hxx:114
size_t m_nObjCount
Definition: svdetc.hxx:122
const SdrLayerIDSet & TRG_GetMasterPageVisibleLayers() const
Definition: svdpage.cxx:1579
size_t m_nInsertCount
Definition: svdetc.hxx:119
size_t m_nActionCount
Definition: svdetc.hxx:116
size_t m_nCurInsert
Definition: svdetc.hxx:120
Link< void *, bool > maLink
Definition: svdetc.hxx:125
static bool CanUnloadRunningObj(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
Definition: svdoole2.cxx:1679
bool IsHideContour() const
Definition: svdotext.cxx:1730
bool IsInside(const Point &rPOINT) const
bool IsMasterPage() const
Definition: svdpage.hxx:451
size_t m_nCurAction
Definition: svdetc.hxx:117
#define XATTR_FILLSTYLE
Definition: xdef.hxx:107
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:485
Abstract DrawObject.
Definition: svdobj.hxx:312
bool ReportActions(size_t nActionCount)
Definition: svdetc.cxx:455
Size GetSize() const
const SfxItemSet & GetActiveCellItemSet() const
Definition: svdotable.cxx:1270
SdrGlobalData & GetSdrGlobalData()
Definition: svdetc.cxx:91
const std::shared_ptr< SvxForbiddenCharactersTable > & GetForbiddenCharsTable() const
Definition: svdmodel.hxx:556
SfxItemState
sal_Int64 GetAspect() const
Definition: svdoole2.cxx:763
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
IMPL_LINK_NOARG(OLEObjCache, UnloadCheckHdl, Timer *, void)
Definition: svdetc.cxx:112
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SdrPageView * GetTextEditPageView() const
Definition: svdedxv.cxx:1659
unsigned char sal_uInt8
SdrPage * GetPage() const
Definition: svdpagv.hxx:171
OLEObjCache()
Definition: svdetc.cxx:95
BitmapColor GetColor(long nY, long nX) const
SfxStyleSheetBasePool * GetStyleSheetPool() const
Definition: svdmodel.hxx:538
Color GetTextEditBackgroundColor(const SdrObjEditView &rView)
Definition: svdetc.cxx:703
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1883
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
Definition: svdetc.cxx:328
static void SetForbiddenCharsTable(const std::shared_ptr< SvxForbiddenCharactersTable > &xForbiddenChars)
SvdProgressInfo(const Link< void *, bool > &_pLink)
Definition: svdetc.cxx:435
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:139
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
void ReportInserts(size_t nInsertCount)
Definition: svdetc.cxx:465
#define XATTR_FILLBITMAP
Definition: xdef.hxx:111
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:314
std::vector< Link< SdrObjCreatorParams, SdrObject * > > aUserMakeObjHdl
Definition: svdetc.hxx:188
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
void InsertObj(SdrOle2Obj *pObj)
Definition: svdetc.cxx:161
SVXCORE_DLLPUBLIC SdrOle2Obj * operator[](size_t nPos)
Definition: svdetc.cxx:202
size_t m_nCurObj
Definition: svdetc.hxx:123
bool GetDraftFillColor(const SfxItemSet &rSet, Color &rCol)
Returns a replacement for an XFillStyle.
Definition: svdetc.cxx:236
SVXCORE_DLLPUBLIC size_t size() const
Definition: svdetc.cxx:197
Point Center() const
const Color & GetEndColor() const
Definition: xgrad.hxx:68
std::unique_ptr< AutoTimer > pTimer
Definition: svdetc.hxx:164
sal_uInt16 GetDefaultTabulator() const
Definition: svdmodel.hxx:337
#define XATTR_FILLBACKGROUND
Definition: xdef.hxx:126
#define EE_ITEMS_END