Kaydet (Commit) 5d8ce0db authored tarafından Rafael Dominguez's avatar Rafael Dominguez Kaydeden (comit) Luboš Luňák

Overload InsertBookmarkAsObject to use std::vector instead of List.

This are the hardest ones to port, since the rExchangeList parameter uses
the last position from InsertBookmarkAsPage in InsertBookmarkAsObject, so
the best idea i came up with to avoid doing nasty stuffs was erase procesed
objects in InsertBookmarkAsPage and add an extra parameter to
InsertBookmarkAsObject that recalculates object count when rExchangeList
has items but its manipulated by InsertBookmarkAsPage first like it occurs
in function SdDrawDocument::InsertBookmark.
üst a8daf5ff
......@@ -383,6 +383,11 @@ public:
sal_Bool bLink, ::sd::DrawDocShell* pBookmarkDocSh,
Point* pObjPos);
sal_Bool InsertBookmarkAsObject(const std::vector<rtl::OUString> &rBookmarkList,
std::vector<rtl::OUString> &rExchangeList,
sal_Bool bLink, ::sd::DrawDocShell* pBookmarkDocSh,
Point* pObjPos, bool bCalcObjCount = false);
SD_DLLPUBLIC void CloseBookmarkDoc();
SdrObject* GetObj(const String& rObjName) const;
......
......@@ -1733,6 +1733,195 @@ sal_Bool SdDrawDocument::InsertBookmarkAsObject(
return bOK;
}
/*************************************************************************
|*
|* Fuegt ein Bookmark als Objekt ein
|*
\************************************************************************/
sal_Bool SdDrawDocument::InsertBookmarkAsObject(
const std::vector<rtl::OUString> &rBookmarkList,
std::vector<rtl::OUString> &rExchangeList, // Liste der zu verwendenen Namen
sal_Bool /* bLink */,
::sd::DrawDocShell* pBookmarkDocSh,
Point* pObjPos, bool bCalcObjCount)
{
sal_Bool bOK = sal_True;
sal_Bool bOLEObjFound = sal_False;
::sd::View* pBMView = NULL;
SdDrawDocument* pBookmarkDoc = NULL;
String aBookmarkName;
if (pBookmarkDocSh)
{
pBookmarkDoc = pBookmarkDocSh->GetDoc();
if (pBookmarkDocSh->GetMedium())
{
aBookmarkName = pBookmarkDocSh->GetMedium()->GetName();
}
}
else if ( mxBookmarkDocShRef.Is() )
{
pBookmarkDoc = mxBookmarkDocShRef->GetDoc();
aBookmarkName = maBookmarkFile;
}
else
{
return sal_False;
}
if (rBookmarkList.empty())
{
pBMView = new ::sd::View(*pBookmarkDoc, (OutputDevice*) NULL);
pBMView->EndListening(*pBookmarkDoc);
pBMView->MarkAll();
}
else
{
SdrPage* pPage;
SdrPageView* pPV;
std::vector<rtl::OUString>::const_iterator pIter;
for ( pIter = rBookmarkList.begin(); pIter != rBookmarkList.end(); ++pIter )
{
/******************************************************************
* Namen der Bookmarks aus Liste holen
******************************************************************/
String aBMName (*pIter);
SdrObject* pObj = pBookmarkDoc->GetObj(aBMName);
if (pObj)
{
// Objekt gefunden
if (pObj->GetObjInventor() == SdrInventor &&
pObj->GetObjIdentifier() == OBJ_OLE2)
{
bOLEObjFound = sal_True;
}
if (!pBMView)
{
// View erstmalig erzeugen
pBMView = new ::sd::View(*pBookmarkDoc, (OutputDevice*) NULL);
pBMView->EndListening(*pBookmarkDoc);
}
pPage = pObj->GetPage();
if (pPage->IsMasterPage())
{
pPV = pBMView->ShowSdrPage(pBMView->GetModel()->GetMasterPage(pPage->GetPageNum()));
}
else
{
pPV = pBMView->GetSdrPageView();
if( !pPV || (pPV->GetPage() != pPage))
pPV = pBMView->ShowSdrPage(pPage);
}
pBMView->MarkObj(pObj, pPV, sal_False);
}
}
}
if (pBMView)
{
/**********************************************************************
* Selektierte Objekte einfuegen
**********************************************************************/
::sd::View* pView = new ::sd::View(*this, (OutputDevice*) NULL);
pView->EndListening(*this);
// Seite bestimmen, auf der die Objekte eingefuegt werden sollen
SdrPage* pPage = GetSdPage(0, PK_STANDARD);
if (mpDocSh)
{
::sd::ViewShell* pViewSh = mpDocSh->GetViewShell();
if (pViewSh)
{
// Welche Seite wird denn aktuell angezeigt?
SdrPageView* pPV = pViewSh->GetView()->GetSdrPageView();
if (pPV)
{
pPage = pPV->GetPage();
}
else if (pViewSh->GetActualPage())
{
pPage = pViewSh->GetActualPage();
}
}
}
Point aObjPos;
if (pObjPos)
{
aObjPos = *pObjPos;
}
else
{
aObjPos = Rectangle(Point(), pPage->GetSize()).Center();
}
sal_uLong nCountBefore = 0;
if (!rExchangeList.empty() || bCalcObjCount)
{
// OrdNums sortieren und Anzahl Objekte vor dem Einfuegen bestimmen
pPage->RecalcObjOrdNums();
nCountBefore = pPage->GetObjCount();
}
if (bOLEObjFound)
pBMView->GetDoc().SetAllocDocSh(sal_True);
SdDrawDocument* pTmpDoc = (SdDrawDocument*) pBMView->GetAllMarkedModel();
bOK = pView->Paste(*pTmpDoc, aObjPos, pPage);
if (bOLEObjFound)
pBMView->GetDoc().SetAllocDocSh(sal_False);
if (!bOLEObjFound)
delete pTmpDoc; // Wird ansonsten von der DocShell zerstoert
delete pView;
if (!rExchangeList.empty())
{
// Anzahl Objekte nach dem Einfuegen bestimmen
sal_uLong nCount = pPage->GetObjCount();
std::vector<rtl::OUString>::const_iterator pIter = rExchangeList.begin();
for (sal_uLong nObj = nCountBefore; nObj < nCount; nObj++)
{
// Zuverwendener Name aus Exchange-Liste holen
if (pIter != rExchangeList.end())
{
String aExchangeName (*pIter);
if (pPage->GetObj(nObj))
{
pPage->GetObj(nObj)->SetName(aExchangeName);
}
++pIter;
}
}
}
}
delete pBMView;
return bOK;
}
/*************************************************************************
|*
|* Beendet das Einfuegen von Bookmarks
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment