/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// Global data of the DrawingEngine
SdrGlobalData::SdrGlobalData()
{ if (!comphelper::IsFuzzing())
{
svx::ExtrusionBar::RegisterInterface();
svx::FontworkBar::RegisterInterface();
}
}
OLEObjCache::OLEObjCache()
{ if (!comphelper::IsFuzzing())
{ // This limit is only useful on 32-bit windows, where we can run out of virtual memory (see tdf#95579) // For everything else, we are better off keeping it in main memory rather than using our hacky page-out thing #ifdefined _WIN32 && !defined _WIN64
mnSize = officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::get(); #else
mnSize = SAL_MAX_INT32; // effectively disable the page-out mechanism #endif
} else
mnSize = 100;
mpTimer.reset( new AutoTimer( "svx OLEObjCache pTimer UnloadCheck" ) );
mpTimer->SetInvokeHandler( LINK(this, OLEObjCache, UnloadCheckHdl) );
mpTimer->SetTimeout(20000);
mpTimer->SetStatic();
}
OLEObjCache::~OLEObjCache()
{
mpTimer->Stop();
}
IMPL_LINK_NOARG(OLEObjCache, UnloadCheckHdl, Timer*, void)
{ if (mnSize >= maObjs.size()) return;
// more objects than configured cache size try to remove objects // of course not the freshly inserted one at nIndex=0
size_t nCount2 = maObjs.size();
size_t nIndex = nCount2-1; while( nIndex && nCount2 > mnSize )
{
SdrOle2Obj* pUnloadObj = maObjs[nIndex--]; if (!pUnloadObj) continue;
try
{ // it is important to get object without reinitialization to avoid reentrance const uno::Reference< embed::XEmbeddedObject > & xUnloadObj = pUnloadObj->GetObjRef_NoInit();
void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
{ if (!maObjs.empty())
{
SdrOle2Obj* pExistingObj = maObjs.front(); if ( pObj == pExistingObj ) // the object is already on the top, nothing has to be changed return;
}
// get the old position of the object to know whether it is already in container
std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj); bool bFound = it != maObjs.end();
if (bFound)
maObjs.erase(it); // insert object into first position
maObjs.insert(maObjs.begin(), pObj);
// if a new object was inserted, recalculate the cache if (!bFound)
mpTimer->Invoke();
if (!bFound || !mpTimer->IsActive())
mpTimer->Start();
}
void OLEObjCache::RemoveObj(SdrOle2Obj* pObj)
{
std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj); if (it != maObjs.end())
maObjs.erase(it); if (maObjs.empty())
mpTimer->Stop();
}
//#i80528# The old mechanism is completely useless, only taking into account if // in all views the GrafDraft feature is used. This will nearly never have been the // case since no one ever used this option.
// A much better (and working) criteria would be the VOC contact count. // The question is what will happen when i make it work now suddenly? I // will try it for 2.4. const sdr::contact::ViewContact& rViewContact = rObj.GetViewContact(); constbool bVisible(rViewContact.HasViewObjectContacts());
if(!bVisible)
{
bUnloaded = rObj.Unload();
}
return bUnloaded;
}
std::optional<Color> GetDraftFillColor(const SfxItemSet& rSet)
{
drawing::FillStyle eFill=rSet.Get(XATTR_FILLSTYLE).GetValue();
Color aResult; switch(eFill)
{ case drawing::FillStyle_SOLID:
{
aResult = rSet.Get(XATTR_FILLCOLOR).GetColorValue(); break;
} case drawing::FillStyle_HATCH:
{
Color aCol1(rSet.Get(XATTR_FILLHATCH).GetHatchValue().GetColor());
Color aCol2(COL_WHITE);
// when hatched background is activated, use object fill color as hatch color bool bFillHatchBackground = rSet.Get(XATTR_FILLBACKGROUND).GetValue(); if(bFillHatchBackground)
{
aCol2 = rSet.Get(XATTR_FILLCOLOR).GetColorValue();
}
sal_uInt16 nTransparencyPercentage = rSet.Get(XATTR_FILLTRANSPARENCE).GetValue(); if (!nTransparencyPercentage) return aResult;
auto nTransparency = nTransparencyPercentage / 100.0; auto nOpacity = 1 - nTransparency;
svtools::ColorConfig aColorConfig;
Color aBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
// https://en.wikipedia.org/wiki/Alpha_compositing // We are here calculating transparency fill color against background with // To put it is simple words with example // I.E: fill is Red (FF0000) and background is pure white (FFFFFF) // If we add 50% transparency to fill color will look like Pink(ff7777)
// TODO: calculate this colors based on object in background and not just the doc color
aResult.SetRed(
std::min(aResult.GetRed() * nOpacity + aBackground.GetRed() * nTransparency, 255.0));
aResult.SetGreen(
std::min(aResult.GetGreen() * nOpacity + aBackground.GetGreen() * nTransparency, 255.0));
aResult.SetBlue(
std::min(aResult.GetBlue() * nOpacity + aBackground.GetBlue() * nTransparency, 255.0)); return aResult;
}
bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnlyEE)
{ bool bHas=false; bool bOnly=true; bool bLookOnly=pbOnlyEE!=nullptr;
SfxWhichIter aIter(rSet);
sal_uInt16 nWhich=aIter.FirstWhich(); while (((bLookOnly && bOnly) || !bHas) && nWhich!=0) { // For bInklDefaults, the entire Which range is decisive, // in other cases only the set items are. // Disabled and DontCare are regarded as holes in the Which range.
SfxItemState eState=aIter.GetItemState(); if ((eState==SfxItemState::DEFAULT && bInklDefaults) || eState==SfxItemState::SET) { if (nWhich<EE_ITEMS_START || nWhich>EE_ITEMS_END) bOnly=false; else bHas=true;
}
nWhich=aIter.NextWhich();
} if (!bHas) bOnly=false; if (pbOnlyEE!=nullptr) *pbOnlyEE=bOnly; return bHas;
}
WhichRangesContainer RemoveWhichRange(const WhichRangesContainer& pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd)
{ // Six possible cases (per range): // [Beg..End] [nRangeBeg, nRangeEnd], to delete // [b..e] [b..e] [b..e] Cases 1,3,2: doesn't matter, delete, doesn't matter + Ranges // [b........e] [b........e] Cases 4,5 : shrink range | in // [b......................e] Case 6 : splitting + pOldWhichTable
std::vector<WhichPair> buf; for (constauto & rPair : pOldWhichTable) { autoconst begin = rPair.first; autoconst end = rPair.second; if (end < nRangeBeg || begin > nRangeEnd) { // cases 1, 2
buf.push_back({begin, end});
} elseif (begin >= nRangeBeg && end <= nRangeEnd) { // case 3 // drop
} elseif (end <= nRangeEnd) { // case 4
buf.push_back({begin, nRangeBeg - 1});
} elseif (begin >= nRangeBeg) { // case 5
buf.push_back({nRangeEnd + 1, end});
} else { // case 6
buf.push_back({begin, nRangeBeg - 1});
buf.push_back({nRangeEnd + 1, end});
}
}
std::unique_ptr<WhichPair[]> pNewWhichTable(new WhichPair[buf.size()]);
std::copy(buf.begin(), buf.end(), pNewWhichTable.get()); return WhichRangesContainer(std::move(pNewWhichTable), buf.size());
}
// Don't fall back to background shape on // master pages. This is later handled by // GetBackgroundColor, and is necessary to cater for // the silly ordering: 1. shapes, 2. master page // shapes, 3. page background, 4. master page // background. if (auto oColor = impGetSdrPageFillColor(rMasterPage, rPnt, rTextEditPV, aSet, true)) return oColor;
}
}
// Only now determine background color from background shapes if(!bSkipBackgroundShape)
{ return rPage.GetPageBackgroundColor();
}
sal_uInt16 i; for ( i = 0; i < SPOTCOUNT; i++ )
{ // five spots are used switch ( i )
{ case 0 :
{ // Center-Spot
aSpotPos[i] = rArea.Center();
} break;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.