22 #include <officecfg/Office/Common.hxx>
55 #include <com/sun/star/frame/XModel.hpp>
56 #include <com/sun/star/embed/XEmbeddedObject.hpp>
63 , pLocaleData(nullptr)
67 svx::ExtrusionBar::RegisterInterface();
68 svx::FontworkBar::RegisterInterface();
87 struct TheSdrGlobalData:
public rtl::Static<SdrGlobalData, TheSdrGlobalData> {};
92 return TheSdrGlobalData::get();
98 nSize = officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::get();
103 pTimer->SetTimeout(20000);
114 if (nSize >= maObjs.size())
119 size_t nCount2 = maObjs.size();
120 size_t nIndex = nCount2-1;
121 while( nIndex && nCount2 > nSize )
130 uno::Reference< embed::XEmbeddedObject > xUnloadObj = pUnloadObj->
GetObjRef_NoInit();
135 if ( xUnloadObj.is() && bUnload )
137 uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY );
138 if ( xUnloadModel.is() )
142 if ( pCacheObj && pCacheObj != pUnloadObj )
144 uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel();
145 if ( xUnloadModel == xParentModel )
152 if ( bUnload && UnloadObj(pUnloadObj) )
156 catch( uno::Exception& )
166 if ( pObj == pExistingObj )
172 std::vector<SdrOle2Obj*>::iterator it = std::find(
maObjs.begin(),
maObjs.end(), pObj);
173 bool bFound = it !=
maObjs.end();
184 if (!bFound || !
pTimer->IsActive())
190 std::vector<SdrOle2Obj*>::iterator it = std::find(
maObjs.begin(),
maObjs.end(), pObj);
214 bool bUnloaded =
false;
229 bUnloaded = pObj->
Unload();
239 bool bRetval =
false;
243 case drawing::FillStyle_SOLID:
250 case drawing::FillStyle_HATCH:
257 if(bFillHatchBackground)
263 rCol =
Color(aAverageColor);
268 case drawing::FillStyle_GRADIENT: {
273 rCol =
Color(aAverageColor);
278 case drawing::FillStyle_BITMAP:
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)
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);
299 for(sal_uInt32 nY(0); nY < nHeight; nY += nYStep)
301 for(sal_uInt32 nX(0); nX < nWidth; nX += nXStep)
305 nRt += rCol2.GetRed();
306 nGn += rCol2.GetGreen();
307 nBl += rCol2.GetBlue();
331 std::unique_ptr<SdrOutliner> pOutl(
new SdrOutliner( pPool, nOutlinerMode ));
332 pOutl->SetEditTextObjectPool( pPool );
333 pOutl->SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(rModel.
GetStyleSheetPool()));
352 bool bLookOnly=pbOnlyEE!=
nullptr;
355 while (((bLookOnly && bOnly) || !bHas) && nWhich!=0) {
360 if ((eState==SfxItemState::DEFAULT && bInklDefaults) || eState==SfxItemState::SET) {
361 if (nWhich<EE_ITEMS_START || nWhich>
EE_ITEMS_END) bOnly=
false;
366 if (!bHas) bOnly=
false;
367 if (pbOnlyEE!=
nullptr) *pbOnlyEE=bOnly;
371 std::unique_ptr<sal_uInt16[]>
RemoveWhichRange(
const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd)
379 while (pOldWhichTable[nCount]!=0) nCount++;
381 DBG_ASSERT((nCount&1)==1,
"RemoveWhichRange: WhichTable doesn't have an odd number of entries.");
382 sal_uInt16 nAlloc=nCount;
384 sal_uInt16 nNum=nCount-1;
387 sal_uInt16 nBeg=pOldWhichTable[nNum];
388 sal_uInt16 nEnd=pOldWhichTable[nNum+1];
389 if (nEnd<nRangeBeg) ;
390 else if (nBeg>nRangeEnd) ;
391 else if (nBeg>=nRangeBeg && nEnd<=nRangeEnd) nAlloc-=2;
392 else if (nEnd<=nRangeEnd) ;
393 else if (nBeg>=nRangeBeg) ;
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;
404 sal_uInt16 nBeg=pNewWhichTable[nNum];
405 sal_uInt16 nEnd=pNewWhichTable[nNum+1];
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;
415 unsigned nTailBytes=(nCount-(nNum+2))*
sizeof(sal_uInt16);
416 memcpy(&pNewWhichTable[nNum],&pNewWhichTable[nNum+2],nTailBytes);
419 case 4: pNewWhichTable[nNum+1]=nRangeBeg-1;
break;
420 case 5: pNewWhichTable[nNum]=nRangeEnd+1;
break;
422 unsigned nTailBytes=(nCount-(nNum+2))*
sizeof(sal_uInt16);
423 memcpy(&pNewWhichTable[nNum+4],&pNewWhichTable[nNum+2],nTailBytes);
425 pNewWhichTable[nNum+2]=nRangeEnd+1;
426 pNewWhichTable[nNum+3]=pNewWhichTable[nNum+1];
427 pNewWhichTable[nNum+1]=nRangeBeg-1;
431 return pNewWhichTable;
506 bool impGetSdrObjListFillColor(
516 for(
size_t no(rList.
GetObjCount()); !bRet && no > 0; )
525 bRet = impGetSdrObjListFillColor(*pOL, rPnt, rTextEditPV, rVisLayers, rCol);
547 bool impGetSdrPageFillColor(
553 bool bSkipBackgroundShape)
555 bool bRet(impGetSdrObjListFillColor(rPage, rPnt, rTextEditPV, rVisLayers, rCol));
571 bRet = impGetSdrPageFillColor(rMasterPage, rPnt, rTextEditPV, aSet, rCol,
true);
576 if(!bRet && !bSkipBackgroundShape)
585 Color impCalcBackgroundColor(
594 if(!rStyleSettings.GetHighContrastMode())
597 const sal_uInt16 SPOTCOUNT(5);
598 Point aSpotPos[SPOTCOUNT];
599 Color aSpotColor[SPOTCOUNT];
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;
608 for ( i = 0; i < SPOTCOUNT; i++ )
616 aSpotPos[i] = rArea.
Center();
624 aSpotPos[i].AdjustX(nWidth14 );
625 aSpotPos[i].AdjustY(nHeight14 );
633 aSpotPos[i].AdjustX(nWidth34 );
634 aSpotPos[i].AdjustY(nHeight14 );
642 aSpotPos[i].AdjustX(nWidth14 );
643 aSpotPos[i].AdjustY(nHeight34 );
651 aSpotPos[i].AdjustX(nWidth34 );
652 aSpotPos[i].AdjustY(nHeight34 );
659 impGetSdrPageFillColor(rPage, aSpotPos[i], rTextEditPV, rTextEditPV.
GetVisibleLayers(), aSpotColor[i],
false);
662 sal_uInt16 aMatch[SPOTCOUNT];
664 for ( i = 0; i < SPOTCOUNT; i++ )
669 for ( sal_uInt16 j = 0; j < SPOTCOUNT; j++ )
673 if( aSpotColor[i] == aSpotColor[j] )
682 aBackground = aSpotColor[0];
684 for ( sal_uInt16 nMatchCount = SPOTCOUNT - 1; nMatchCount > 1; nMatchCount-- )
687 for ( i = 0; i < SPOTCOUNT; i++ )
689 if( aMatch[i] == nMatchCount )
691 aBackground = aSpotColor[i];
709 if(!rStyleSettings.GetHighContrastMode())
737 aSnapRect.
Move(aPvOfs.X(), aPvOfs.Y());
739 return impCalcBackgroundColor(aSnapRect, *pTextEditPV, *pPg);
#define LINK(Instance, Class, Member)
SdrPage & TRG_GetMasterPage() const
void ReportRescales(size_t nRescaleCount)
bool SearchOutlinerItems(const SfxItemSet &rSet, bool bInklDefaults, bool *pbOnlyEE)
Search an ItemSet for Outliner/EditEngine Items.
bool IsNotVisibleAsMaster() const
virtual const tools::Rectangle & GetCurrentBoundRect() const
const SvtSysLocale * GetSysLocale()
CharCompressType GetCharCompressType() const
const LocaleDataWrapper * GetLocaleDataPtr() const
Color GetPageBackgroundColor() const
deprecated returns an averaged background color of this page
bool IsKernAsianPunctuation() const
SdrTextObj * GetTextEditObject() const
std::vector< Link< SdrObjCreatorParams, SdrObject * > > & ImpGetUserMakeObjHdl()
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
std::unique_ptr< sal_uInt16[]> RemoveWhichRange(const sal_uInt16 *pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd)
constexpr sal_uInt16 EE_ITEMS_END(EE_FEATURE_END)
B2DTuple average(const B2DTuple &rOld1, const B2DTuple &rOld2)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
virtual const tools::Rectangle & GetSnapRect() const override
SVXCORE_DLLPUBLIC ~OLEObjCache()
virtual SdrObjList * GetSubList() const
constexpr TypedWhichId< XFillBackgroundItem > XATTR_FILLBACKGROUND(XATTR_FILL_FIRST+19)
sdr::contact::ViewContact & GetViewContact() const
const Color & GetStartColor() const
const SvtSysLocale * pSysLocale
void Init(size_t _nObjCount)
const LocaleDataWrapper * GetLocaleData()
void RemoveObj(SdrOle2Obj *pObj)
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
std::vector< SdrOle2Obj * > maObjs
const Point & GetTextEditOffset() const
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
static bool UnloadObj(SdrOle2Obj *pObj)
void SetInsertCount(size_t _nInsertCount)
void SetActionCount(size_t _nActionCount)
const SdrLayerIDSet & GetVisibleLayers() const
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
bool IsAddExtLeading() const
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
const SdrLayerIDSet & TRG_GetMasterPageVisibleLayers() const
BitmapColor GetColor(tools::Long nY, tools::Long nX) const
Link< void *, bool > maLink
tools::Long Width() const
static bool CanUnloadRunningObj(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
bool IsHideContour() const
bool IsMasterPage() const
bool TRG_HasMasterPage() const
bool ReportActions(size_t nActionCount)
const SfxItemSet & GetActiveCellItemSet() const
SdrGlobalData & GetSdrGlobalData()
const std::shared_ptr< SvxForbiddenCharactersTable > & GetForbiddenCharsTable() const
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
sal_Int64 GetAspect() const
IMPL_LINK_NOARG(OLEObjCache, UnloadCheckHdl, Timer *, void)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SdrPageView * GetTextEditPageView() const
SdrPage * GetPage() const
SfxStyleSheetBasePool * GetStyleSheetPool() const
Color GetTextEditBackgroundColor(const SdrObjEditView &rView)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
const SfxItemSet & GetMergedItemSet() const
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
static void SetForbiddenCharsTable(const std::shared_ptr< SvxForbiddenCharactersTable > &xForbiddenChars)
SvdProgressInfo(const Link< void *, bool > &_pLink)
tools::Long Height() const
virtual SdrPage * getSdrPageFromSdrObjList() const
void ReportInserts(size_t nInsertCount)
const SfxItemPool & GetItemPool() const
std::vector< Link< SdrObjCreatorParams, SdrObject * > > aUserMakeObjHdl
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
void InsertObj(SdrOle2Obj *pObj)
SVXCORE_DLLPUBLIC SdrOle2Obj * operator[](size_t nPos)
bool GetDraftFillColor(const SfxItemSet &rSet, Color &rCol)
Returns a replacement for an XFillStyle.
SVXCORE_DLLPUBLIC size_t size() const
const Color & GetEndColor() const
std::unique_ptr< AutoTimer > pTimer
sal_uInt16 GetDefaultTabulator() const